Skip to content

Commit 8d74586

Browse files
committed
ux: show only subject in Apply Stash and Drop Stash popup
Signed-off-by: leo <[email protected]>
1 parent dcd8eff commit 8d74586

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

src/Models/Stash.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ public class Stash
1111
public ulong Time { get; set; } = 0;
1212
public string Message { get; set; } = "";
1313

14-
public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString(DateTimeFormat.Active.DateTime);
14+
public string Subject
15+
{
16+
get
17+
{
18+
var idx = Message.IndexOf('\n', StringComparison.Ordinal);
19+
return idx > 0 ? Message.Substring(0, idx).Trim() : Message;
20+
}
21+
}
22+
23+
public string TimeStr
24+
{
25+
get
26+
{
27+
return DateTime.UnixEpoch
28+
.AddSeconds(Time)
29+
.ToLocalTime()
30+
.ToString(DateTimeFormat.Active.DateTime);
31+
}
32+
}
1533
}
1634
}

src/Views/ApplyStash.axaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
HorizontalAlignment="Right" VerticalAlignment="Center"
1616
Margin="0,0,8,0"
1717
Text="{DynamicResource Text.ApplyStash.Stash}"/>
18-
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
19-
<Path Width="12" Height="12" Margin="2,0,8,0"
18+
<Grid Grid.Row="0" Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
19+
<Path Grid.Column="0"
20+
Width="12" Height="12"
21+
Margin="2,0,8,0"
2022
HorizontalAlignment="Left" VerticalAlignment="Center"
2123
Data="{StaticResource Icons.Stashes}"/>
2224

23-
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
24-
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/>
25-
</StackPanel>
25+
<TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
26+
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
27+
</Grid>
2628

2729
<CheckBox Grid.Row="1" Grid.Column="1"
2830
Content="{DynamicResource Text.ApplyStash.RestoreIndex}"

src/Views/DropStash.axaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
HorizontalAlignment="Right" VerticalAlignment="Center"
1616
Margin="0,0,8,0"
1717
Text="{DynamicResource Text.StashDropConfirm.Label}"/>
18-
<StackPanel Grid.Column="1" Orientation="Horizontal">
19-
<Path Width="12" Height="12" Margin="0,0,8,0"
18+
<Grid Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
19+
<Path Grid.Column="0"
20+
Width="12" Height="12"
21+
Margin="0,0,8,0"
2022
HorizontalAlignment="Left" VerticalAlignment="Center"
2123
Data="{StaticResource Icons.Stashes}"/>
2224

23-
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
24-
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/>
25-
</StackPanel>
25+
<TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
26+
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
27+
</Grid>
2628
</Grid>
2729
</StackPanel>
2830
</UserControl>

src/Views/StashSubjectPresenter.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,23 @@ public IBrush PrefixBackground
4646
set => SetValue(PrefixBackgroundProperty, value);
4747
}
4848

49-
public static readonly StyledProperty<string> MessageProperty =
50-
AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Message));
49+
public static readonly StyledProperty<string> SubjectProperty =
50+
AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Subject));
5151

52-
public string Message
52+
public string Subject
5353
{
54-
get => GetValue(MessageProperty);
55-
set => SetValue(MessageProperty, value);
54+
get => GetValue(SubjectProperty);
55+
set => SetValue(SubjectProperty, value);
5656
}
5757

5858
public override void Render(DrawingContext context)
5959
{
6060
base.Render(context);
6161

62-
var message = Message ?? string.Empty;
63-
if (string.IsNullOrEmpty(message))
62+
var subject = Subject;
63+
if (string.IsNullOrEmpty(subject))
6464
return;
6565

66-
var subjectIdx = message.IndexOf('\n', StringComparison.Ordinal);
67-
var subject = subjectIdx > 0 ? message.Substring(0, subjectIdx).Trim() : message;
68-
6966
var typeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal);
7067
var foreground = Foreground;
7168
var x = 0.0;
@@ -108,7 +105,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
108105
{
109106
base.OnPropertyChanged(change);
110107

111-
if (change.Property == MessageProperty ||
108+
if (change.Property == SubjectProperty ||
112109
change.Property == FontFamilyProperty ||
113110
change.Property == FontSizeProperty ||
114111
change.Property == ForegroundProperty ||

src/Views/StashesPage.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
</Grid>
9797

9898
<v:StashSubjectPresenter Grid.Row="1"
99-
Message="{Binding Message}"
99+
Subject="{Binding Subject}"
100100
Foreground="{DynamicResource Brush.FG1}"
101101
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize}"
102102
PrefixBackground="{DynamicResource Brush.InlineCode}"

0 commit comments

Comments
 (0)