Skip to content

Commit a6a86cd

Browse files
committed
feature: show build date in About dialog
Signed-off-by: leo <[email protected]>
1 parent db11a60 commit a6a86cd

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
22
<x:String x:Key="Text.About" xml:space="preserve">About</x:String>
33
<x:String x:Key="Text.About.Menu" xml:space="preserve">About SourceGit</x:String>
4+
<x:String x:Key="Text.About.ReleaseDate" xml:space="preserve">Release Date: {0}</x:String>
45
<x:String x:Key="Text.About.ReleaseNotes" xml:space="preserve">Release Notes</x:String>
56
<x:String x:Key="Text.About.SubTitle" xml:space="preserve">Opensource &amp; Free Git GUI Client</x:String>
67
<x:String x:Key="Text.AddToIgnore" xml:space="preserve">Add File(s) To Ignore</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<x:String x:Key="Text.About" xml:space="preserve">关于软件</x:String>
77
<x:String x:Key="Text.About.Menu" xml:space="preserve">关于本软件</x:String>
8+
<x:String x:Key="Text.About.ReleaseDate" xml:space="preserve">发布日期 :{0}</x:String>
89
<x:String x:Key="Text.About.ReleaseNotes" xml:space="preserve">浏览版本更新说明</x:String>
910
<x:String x:Key="Text.About.SubTitle" xml:space="preserve">开源免费的Git客户端</x:String>
1011
<x:String x:Key="Text.AddToIgnore" xml:space="preserve">新增忽略文件</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<x:String x:Key="Text.About" xml:space="preserve">關於</x:String>
77
<x:String x:Key="Text.About.Menu" xml:space="preserve">關於 SourceGit</x:String>
8+
<x:String x:Key="Text.About.ReleaseDate" xml:space="preserve">發行日期: {0}</x:String>
89
<x:String x:Key="Text.About.ReleaseNotes" xml:space="preserve">版本說明</x:String>
910
<x:String x:Key="Text.About.SubTitle" xml:space="preserve">開源免費的 Git 客戶端</x:String>
1011
<x:String x:Key="Text.AddToIgnore" xml:space="preserve">新增忽略檔案</x:String>

src/SourceGit.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
3333
</PropertyGroup>
3434

35+
<ItemGroup>
36+
<AssemblyMetadata Include="BuildDate" Value="$([System.DateTime]::Now.ToString('o'))"/>
37+
</ItemGroup>
38+
3539
<ItemGroup>
3640
<AvaloniaResource Include="App.ico" />
3741
<AvaloniaResource Include="Resources/Fonts/*" />

src/Views/About.axaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
HorizontalAlignment="Center"
4343
VerticalAlignment="Center"/>
4444

45-
<Grid Grid.Column="1" Margin="0,0,8,0" RowDefinitions="Auto,Auto,Auto,Auto" VerticalAlignment="Center">
45+
<Grid Grid.Column="1" RowDefinitions="Auto,Auto,Auto,Auto,Auto" VerticalAlignment="Center">
4646
<StackPanel Grid.Row="0" Height="40" Orientation="Horizontal">
4747
<TextBlock Classes="bold" Text="SourceGit" FontSize="32" />
4848
<Border Margin="12,0,0,0" Height="20"
@@ -56,7 +56,7 @@
5656
</Border>
5757
</StackPanel>
5858

59-
<Border Grid.Row="1" Margin="2,4,0,0">
59+
<Border Grid.Row="1" Margin="0,4,0,0">
6060
<TextBlock Text="{DynamicResource Text.About.SubTitle}" FontSize="16" TextWrapping="Wrap"/>
6161
</Border>
6262

@@ -70,7 +70,8 @@
7070
</Button>
7171
</StackPanel>
7272

73-
<TextBlock Grid.Row="3" x:Name="TxtCopyright" Margin="0,40,0,0" Foreground="{DynamicResource Brush.FG2}"/>
73+
<TextBlock Grid.Row="3" x:Name="TxtReleaseDate" Margin="0,28,0,0" Foreground="{DynamicResource Brush.FG2}"/>
74+
<TextBlock Grid.Row="4" x:Name="TxtCopyright" Margin="0,2,0,0" Foreground="{DynamicResource Brush.FG2}"/>
7475
</Grid>
7576
</Grid>
7677
</Grid>

src/Views/About.axaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System;
12
using System.Reflection;
3+
24
using Avalonia.Interactivity;
35

46
namespace SourceGit.Views
@@ -15,6 +17,16 @@ public About()
1517
if (ver != null)
1618
TxtVersion.Text = $"{ver.Major}.{ver.Minor:D2}";
1719

20+
var meta = assembly.GetCustomAttributes<AssemblyMetadataAttribute>();
21+
foreach (var attr in meta)
22+
{
23+
if (attr.Key.Equals("BuildDate", StringComparison.OrdinalIgnoreCase) && DateTime.TryParse(attr.Value, out var date))
24+
{
25+
TxtReleaseDate.Text = App.Text("About.ReleaseDate", date.ToLocalTime().ToString("MMM d yyyy"));
26+
break;
27+
}
28+
}
29+
1830
var copyright = assembly.GetCustomAttribute<AssemblyCopyrightAttribute>();
1931
if (copyright != null)
2032
TxtCopyright.Text = copyright.Copyright;

0 commit comments

Comments
 (0)