ux: show only subject in Apply Stash and Drop Stash popup
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-19 14:26:31 +08:00
parent dcd8effc32
commit 8d74586970
No known key found for this signature in database
5 changed files with 42 additions and 23 deletions

View file

@ -11,6 +11,24 @@ namespace SourceGit.Models
public ulong Time { get; set; } = 0; public ulong Time { get; set; } = 0;
public string Message { get; set; } = ""; public string Message { get; set; } = "";
public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString(DateTimeFormat.Active.DateTime); public string Subject
{
get
{
var idx = Message.IndexOf('\n', StringComparison.Ordinal);
return idx > 0 ? Message.Substring(0, idx).Trim() : Message;
}
}
public string TimeStr
{
get
{
return DateTime.UnixEpoch
.AddSeconds(Time)
.ToLocalTime()
.ToString(DateTimeFormat.Active.DateTime);
}
}
} }
} }

View file

@ -15,14 +15,16 @@
HorizontalAlignment="Right" VerticalAlignment="Center" HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0" Margin="0,0,8,0"
Text="{DynamicResource Text.ApplyStash.Stash}"/> Text="{DynamicResource Text.ApplyStash.Stash}"/>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal"> <Grid Grid.Row="0" Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
<Path Width="12" Height="12" Margin="2,0,8,0" <Path Grid.Column="0"
Width="12" Height="12"
Margin="2,0,8,0"
HorizontalAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" VerticalAlignment="Center"
Data="{StaticResource Icons.Stashes}"/> Data="{StaticResource Icons.Stashes}"/>
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/> <TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/> <TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
</StackPanel> </Grid>
<CheckBox Grid.Row="1" Grid.Column="1" <CheckBox Grid.Row="1" Grid.Column="1"
Content="{DynamicResource Text.ApplyStash.RestoreIndex}" Content="{DynamicResource Text.ApplyStash.RestoreIndex}"

View file

@ -15,14 +15,16 @@
HorizontalAlignment="Right" VerticalAlignment="Center" HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0" Margin="0,0,8,0"
Text="{DynamicResource Text.StashDropConfirm.Label}"/> Text="{DynamicResource Text.StashDropConfirm.Label}"/>
<StackPanel Grid.Column="1" Orientation="Horizontal"> <Grid Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
<Path Width="12" Height="12" Margin="0,0,8,0" <Path Grid.Column="0"
Width="12" Height="12"
Margin="0,0,8,0"
HorizontalAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" VerticalAlignment="Center"
Data="{StaticResource Icons.Stashes}"/> Data="{StaticResource Icons.Stashes}"/>
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/> <TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/> <TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
</StackPanel> </Grid>
</Grid> </Grid>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View file

@ -46,26 +46,23 @@ namespace SourceGit.Views
set => SetValue(PrefixBackgroundProperty, value); set => SetValue(PrefixBackgroundProperty, value);
} }
public static readonly StyledProperty<string> MessageProperty = public static readonly StyledProperty<string> SubjectProperty =
AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Message)); AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Subject));
public string Message public string Subject
{ {
get => GetValue(MessageProperty); get => GetValue(SubjectProperty);
set => SetValue(MessageProperty, value); set => SetValue(SubjectProperty, value);
} }
public override void Render(DrawingContext context) public override void Render(DrawingContext context)
{ {
base.Render(context); base.Render(context);
var message = Message ?? string.Empty; var subject = Subject;
if (string.IsNullOrEmpty(message)) if (string.IsNullOrEmpty(subject))
return; return;
var subjectIdx = message.IndexOf('\n', StringComparison.Ordinal);
var subject = subjectIdx > 0 ? message.Substring(0, subjectIdx).Trim() : message;
var typeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal); var typeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal);
var foreground = Foreground; var foreground = Foreground;
var x = 0.0; var x = 0.0;
@ -108,7 +105,7 @@ namespace SourceGit.Views
{ {
base.OnPropertyChanged(change); base.OnPropertyChanged(change);
if (change.Property == MessageProperty || if (change.Property == SubjectProperty ||
change.Property == FontFamilyProperty || change.Property == FontFamilyProperty ||
change.Property == FontSizeProperty || change.Property == FontSizeProperty ||
change.Property == ForegroundProperty || change.Property == ForegroundProperty ||

View file

@ -96,7 +96,7 @@
</Grid> </Grid>
<v:StashSubjectPresenter Grid.Row="1" <v:StashSubjectPresenter Grid.Row="1"
Message="{Binding Message}" Subject="{Binding Subject}"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize}" FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize}"
PrefixBackground="{DynamicResource Brush.InlineCode}" PrefixBackground="{DynamicResource Brush.InlineCode}"