From e9036b5fb9c3e3520149edad36dca2db1b93f06f Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 16 Apr 2025 10:22:54 +0800 Subject: [PATCH] ux: re-design commit message input box Signed-off-by: leo --- src/Views/CommitMessageTextBox.axaml | 54 ++++++++++++++++++++----- src/Views/CommitMessageTextBox.axaml.cs | 32 +++++++++++++++ src/Views/WorkingCopy.axaml | 40 +++++------------- src/Views/WorkingCopy.axaml.cs | 22 ---------- 4 files changed, 85 insertions(+), 63 deletions(-) diff --git a/src/Views/CommitMessageTextBox.axaml b/src/Views/CommitMessageTextBox.axaml index 1bd2ce31..7489d1dd 100644 --- a/src/Views/CommitMessageTextBox.axaml +++ b/src/Views/CommitMessageTextBox.axaml @@ -64,25 +64,57 @@ Background="{DynamicResource Brush.Window}" BorderThickness="1,0,0,0" CornerRadius="0,0,4,4"> - - + + + + + + + + + - + - - - - diff --git a/src/Views/CommitMessageTextBox.axaml.cs b/src/Views/CommitMessageTextBox.axaml.cs index b3abe330..807461d1 100644 --- a/src/Views/CommitMessageTextBox.axaml.cs +++ b/src/Views/CommitMessageTextBox.axaml.cs @@ -56,6 +56,9 @@ namespace SourceGit.Views FromEditor, } + public static readonly StyledProperty ShowAdvancedOptionsProperty = + AvaloniaProperty.Register(nameof(ShowAdvancedOptions), false); + public static readonly StyledProperty TextProperty = AvaloniaProperty.Register(nameof(Text), string.Empty); @@ -65,6 +68,12 @@ namespace SourceGit.Views public static readonly StyledProperty DescriptionProperty = AvaloniaProperty.Register(nameof(Description), string.Empty); + public bool ShowAdvancedOptions + { + get => GetValue(ShowAdvancedOptionsProperty); + set => SetValue(ShowAdvancedOptionsProperty, value); + } + public string Text { get => GetValue(TextProperty); @@ -167,6 +176,29 @@ namespace SourceGit.Views } } + private void OnOpenCommitMessagePicker(object sender, RoutedEventArgs e) + { + if (sender is Button button && DataContext is ViewModels.WorkingCopy vm) + { + var menu = vm.CreateContextMenuForCommitMessages(); + menu.Placement = PlacementMode.TopEdgeAlignedLeft; + menu?.Open(button); + } + + e.Handled = true; + } + + private void OnOpenOpenAIHelper(object sender, RoutedEventArgs e) + { + if (DataContext is ViewModels.WorkingCopy vm && sender is Control control) + { + var menu = vm.CreateContextForOpenAI(); + menu?.Open(control); + } + + e.Handled = true; + } + private void OnOpenConventionalCommitHelper(object _, RoutedEventArgs e) { var dialog = new ConventionalCommitMessageBuilder() diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index 578741aa..f8640ec7 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -230,33 +230,13 @@ Background="Transparent"/> - + - - - - - - + - - - - -