mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-21 02:15:00 +00:00
ux: show only subject in Apply Stash
and Drop Stash
popup
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
dcd8effc32
commit
8d74586970
5 changed files with 42 additions and 23 deletions
|
@ -11,6 +11,24 @@ namespace SourceGit.Models
|
|||
public ulong Time { get; set; } = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,16 @@
|
|||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.ApplyStash.Stash}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Margin="2,0,8,0"
|
||||
<Grid Grid.Row="0" Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12"
|
||||
Margin="2,0,8,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Data="{StaticResource Icons.Stashes}"/>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
|
||||
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||
Content="{DynamicResource Text.ApplyStash.RestoreIndex}"
|
||||
|
|
|
@ -15,14 +15,16 @@
|
|||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.StashDropConfirm.Label}"/>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Margin="0,0,8,0"
|
||||
<Grid Grid.Column="1" ColumnDefinitions="Auto,Auto,*">
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Data="{StaticResource Icons.Stashes}"/>
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding Stash.Message}" Margin="4,0,0,0"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="primary" Text="{Binding Stash.Name}" Foreground="DarkOrange"/>
|
||||
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding Stash.Subject}" TextTrimming="CharacterEllipsis" Margin="4,0,0,0"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -46,26 +46,23 @@ namespace SourceGit.Views
|
|||
set => SetValue(PrefixBackgroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<string> MessageProperty =
|
||||
AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Message));
|
||||
public static readonly StyledProperty<string> SubjectProperty =
|
||||
AvaloniaProperty.Register<StashSubjectPresenter, string>(nameof(Subject));
|
||||
|
||||
public string Message
|
||||
public string Subject
|
||||
{
|
||||
get => GetValue(MessageProperty);
|
||||
set => SetValue(MessageProperty, value);
|
||||
get => GetValue(SubjectProperty);
|
||||
set => SetValue(SubjectProperty, value);
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
{
|
||||
base.Render(context);
|
||||
|
||||
var message = Message ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(message))
|
||||
var subject = Subject;
|
||||
if (string.IsNullOrEmpty(subject))
|
||||
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 foreground = Foreground;
|
||||
var x = 0.0;
|
||||
|
@ -108,7 +105,7 @@ namespace SourceGit.Views
|
|||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
||||
if (change.Property == MessageProperty ||
|
||||
if (change.Property == SubjectProperty ||
|
||||
change.Property == FontFamilyProperty ||
|
||||
change.Property == FontSizeProperty ||
|
||||
change.Property == ForegroundProperty ||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
</Grid>
|
||||
|
||||
<v:StashSubjectPresenter Grid.Row="1"
|
||||
Message="{Binding Message}"
|
||||
Subject="{Binding Subject}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize}"
|
||||
PrefixBackground="{DynamicResource Brush.InlineCode}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue