From c170f261dbd42db1faa1c26f4c67e99af4a9942f Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 2 Jul 2024 20:59:28 +0800 Subject: [PATCH] ux: re-design commit detail information page to avoid commit message hidden in scoll view --- src/Converters/ListConverters.cs | 7 +++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/Views/CommitBaseInfo.axaml | 4 +- src/Views/CommitDetail.axaml | 95 +++++++++++++++---------------- src/Views/CommitDetail.axaml.cs | 28 +++------ 7 files changed, 64 insertions(+), 73 deletions(-) diff --git a/src/Converters/ListConverters.cs b/src/Converters/ListConverters.cs index dac55076..fef0f584 100644 --- a/src/Converters/ListConverters.cs +++ b/src/Converters/ListConverters.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Collections.Generic; using Avalonia.Data.Converters; @@ -11,5 +12,11 @@ namespace SourceGit.Converters public static readonly FuncValueConverter IsNotNullOrEmpty = new FuncValueConverter(v => v != null && v.Count > 0); + + public static readonly FuncValueConverter, List> Top100Changes = + new FuncValueConverter, List>(v => (v == null || v.Count < 100) ? v : v.GetRange(0, 100)); + + public static readonly FuncValueConverter IsOnlyTop100Shows = + new FuncValueConverter(v => v != null && v.Count > 100); } } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index d3d41a8e..546a300b 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -111,6 +111,7 @@ AUTHOR CHANGED COMMITTER + Shows only the first 100 changes. See all changes on the CHANGES tab. MESSAGE PARENTS REFS diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 80d4c3b9..fcc2f40f 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -114,6 +114,7 @@ 修改者 变更列表 提交者 + 仅显示前100项变更。请前往【变更对比】页面查看全部。 提交信息 父提交 相关引用 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index b37b681f..159009b9 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -114,6 +114,7 @@ 修改者 變更列表 提交者 + 僅顯示前100項變更。 請前往『變更對比』頁面查看全部。 提交資訊 父提交 相關引用 diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index 3d3dd826..19b75a50 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -104,9 +104,7 @@ - - - + diff --git a/src/Views/CommitDetail.axaml b/src/Views/CommitDetail.axaml index a46d5e54..05a521e1 100644 --- a/src/Views/CommitDetail.axaml +++ b/src/Views/CommitDetail.axaml @@ -17,58 +17,55 @@ - - - + + + + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + diff --git a/src/Views/CommitDetail.axaml.cs b/src/Views/CommitDetail.axaml.cs index 1209e41a..999d1c07 100644 --- a/src/Views/CommitDetail.axaml.cs +++ b/src/Views/CommitDetail.axaml.cs @@ -10,37 +10,23 @@ namespace SourceGit.Views InitializeComponent(); } - private void OnChangeListDoubleTapped(object sender, TappedEventArgs e) + private void OnChangeDoubleTapped(object sender, TappedEventArgs e) { - if (DataContext is ViewModels.CommitDetail detail) + if (DataContext is ViewModels.CommitDetail detail && sender is Grid grid && grid.DataContext is Models.Change change) { - var datagrid = sender as DataGrid; - if (datagrid.SelectedItem == null) - { - e.Handled = true; - return; - } - detail.ActivePageIndex = 1; - detail.SelectedChanges = new() { datagrid.SelectedItem as Models.Change }; + detail.SelectedChanges = new() { change }; } e.Handled = true; } - private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e) + private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e) { - if (DataContext is ViewModels.CommitDetail detail) + if (DataContext is ViewModels.CommitDetail detail && sender is Grid grid && grid.DataContext is Models.Change change) { - var datagrid = sender as DataGrid; - if (datagrid.SelectedItem == null) - { - e.Handled = true; - return; - } - - var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change); - datagrid.OpenContextMenu(menu); + var menu = detail.CreateChangeContextMenu(change); + grid.OpenContextMenu(menu); } e.Handled = true;