Skip to content

Commit 81d81f6

Browse files
committed
ux: text styles in Interactive Rebase dialog
Signed-off-by: leo <longshuang@msn.cn>
1 parent 6760119 commit 81d81f6

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/Converters/InteractiveRebaseActionConverters.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SourceGit.Converters
66
public static class InteractiveRebaseActionConverters
77
{
88
public static readonly FuncValueConverter<Models.InteractiveRebaseAction, IBrush> ToIconBrush =
9-
new FuncValueConverter<Models.InteractiveRebaseAction, IBrush>(v =>
9+
new(v =>
1010
{
1111
return v switch
1212
{
@@ -20,6 +20,12 @@ public static class InteractiveRebaseActionConverters
2020
});
2121

2222
public static readonly FuncValueConverter<Models.InteractiveRebaseAction, string> ToName =
23-
new FuncValueConverter<Models.InteractiveRebaseAction, string>(v => v.ToString());
23+
new(v => v.ToString());
24+
25+
public static readonly FuncValueConverter<Models.InteractiveRebaseAction, bool> IsDrop =
26+
new(v => v == Models.InteractiveRebaseAction.Drop);
27+
28+
public static readonly FuncValueConverter<Models.InteractiveRebaseAction, double> ToOpacity =
29+
new(v => v > Models.InteractiveRebaseAction.Reword ? 0.65 : 1.0);
2430
}
2531
}

src/Resources/Styles.axaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@
524524
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
525525
<Setter Property="Opacity" Value=".56"/>
526526
</Style>
527+
<Style Selector="TextBlock.dropped">
528+
<Setter Property="TextDecorations" Value="Strikethrough"/>
529+
</Style>
527530

528531
<Style Selector="Run.issue_link">
529532
<Setter Property="Foreground" Value="{DynamicResource Brush.Link}"/>

src/ViewModels/InteractiveRebase.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ public bool ShowEditMessageButton
7676
set => SetProperty(ref _showEditMessageButton, value);
7777
}
7878

79-
public bool IsFullMessageUsed
80-
{
81-
get => _isFullMessageUsed;
82-
set => SetProperty(ref _isFullMessageUsed, value);
83-
}
84-
8579
public Thickness DropDirectionIndicator
8680
{
8781
get => _dropDirectionIndicator;
@@ -108,7 +102,6 @@ public InteractiveRebaseItem(int order, Models.Commit c, string message)
108102
private string _fullMessage;
109103
private bool _canSquashOrFixup = true;
110104
private bool _showEditMessageButton = false;
111-
private bool _isFullMessageUsed = true;
112105
private Thickness _dropDirectionIndicator = new Thickness(0);
113106
}
114107

@@ -354,7 +347,6 @@ private void UpdateItems()
354347

355348
if (item.Action == Models.InteractiveRebaseAction.Drop)
356349
{
357-
item.IsFullMessageUsed = false;
358350
item.ShowEditMessageButton = false;
359351
item.PendingType = hasPending ? Models.InteractiveRebasePendingType.Ignore : Models.InteractiveRebasePendingType.None;
360352
item.FullMessage = item.OriginalFullMessage;
@@ -365,7 +357,6 @@ private void UpdateItems()
365357
if (item.Action == Models.InteractiveRebaseAction.Fixup ||
366358
item.Action == Models.InteractiveRebaseAction.Squash)
367359
{
368-
item.IsFullMessageUsed = false;
369360
item.ShowEditMessageButton = false;
370361
item.PendingType = hasPending ? Models.InteractiveRebasePendingType.Pending : Models.InteractiveRebasePendingType.Last;
371362
item.FullMessage = item.OriginalFullMessage;
@@ -382,7 +373,6 @@ private void UpdateItems()
382373
item.Action == Models.InteractiveRebaseAction.Edit)
383374
{
384375
var oldPendingType = item.PendingType;
385-
item.IsFullMessageUsed = true;
386376
item.ShowEditMessageButton = true;
387377
item.PendingType = hasPending ? Models.InteractiveRebasePendingType.Target : Models.InteractiveRebasePendingType.None;
388378

@@ -412,7 +402,6 @@ private void UpdateItems()
412402

413403
if (item.Action == Models.InteractiveRebaseAction.Pick)
414404
{
415-
item.IsFullMessageUsed = true;
416405
item.IsMessageUserEdited = false;
417406

418407
if (hasPending)

src/Views/InteractiveRebase.axaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,36 +165,38 @@
165165
Subject="{Binding Subject}"
166166
IssueTrackers="{Binding $parent[v:InteractiveRebase].((vm:InteractiveRebase)DataContext).IssueTrackers}"
167167
FontWeight="Normal"
168-
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"
169-
ShowStrikethrough="{Binding Action, Mode=OneWay, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:InteractiveRebaseAction.Drop}}"/>
168+
Opacity="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.ToOpacity}}"
169+
ShowStrikethrough="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.IsDrop}}"/>
170170
</Grid>
171171

172172
<!-- Author Avatar -->
173173
<v:Avatar Grid.Column="4"
174174
Width="16" Height="16"
175175
Margin="8,0,0,0"
176176
VerticalAlignment="Center"
177-
User="{Binding Commit.Author}"
178-
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"/>
177+
User="{Binding Commit.Author}"/>
179178

180179
<!-- Author Name -->
181180
<Border Grid.Column="5" ClipToBounds="True">
182181
<TextBlock Margin="6,0,12,0"
183-
Text="{Binding Commit.Author.Name}"
184-
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"/>
182+
Text="{Binding Commit.Author.Name}"
183+
Opacity="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.ToOpacity}}"
184+
Classes.dropped="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.IsDrop}}"/>
185185
</Border>
186186

187187
<!-- Commit SHA -->
188188
<Border Grid.Column="6" ClipToBounds="True">
189189
<TextBlock Text="{Binding Commit.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
190-
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"/>
190+
Opacity="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.ToOpacity}}"
191+
Classes.dropped="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.IsDrop}}"/>
191192
</Border>
192193

193194
<!-- Commit Time -->
194195
<Border Grid.Column="7">
195196
<v:DateTimePresenter Margin="16,0,8,0"
196197
Timestamp="{Binding Commit.CommitterTime}"
197-
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"/>
198+
Opacity="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.ToOpacity}}"
199+
Classes.dropped="{Binding Action, Mode=OneWay, Converter={x:Static c:InteractiveRebaseActionConverters.IsDrop}}"/>
198200
</Border>
199201
</Grid>
200202
</DataTemplate>

0 commit comments

Comments
 (0)