From 9dd4166009da4446ad988482ea623281f5960079 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 11 Dec 2024 16:08:23 +0800 Subject: [PATCH] refactor: use MultiBinding instead of code to control visibility of `Commit & Push` button --- src/ViewModels/WorkingCopy.cs | 12 +----------- src/Views/WorkingCopy.axaml | 11 +++++++++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index bf788bb0..59de9245 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -29,11 +29,7 @@ namespace SourceGit.ViewModels public bool CanCommitWithPush { get => _canCommitWithPush; - set - { - if (SetProperty(ref _canCommitWithPush, value)) - OnPropertyChanged(nameof(IsCommitWithPushVisible)); - } + set => SetProperty(ref _canCommitWithPush, value); } public bool HasUnsolvedConflicts @@ -89,16 +85,10 @@ namespace SourceGit.ViewModels Staged = GetStagedChanges(); SelectedStaged = []; - OnPropertyChanged(nameof(IsCommitWithPushVisible)); } } } - public bool IsCommitWithPushVisible - { - get => !UseAmend && CanCommitWithPush; - } - public List Unstaged { get => _unstaged; diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index bd794f02..8600b367 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -355,8 +355,15 @@ HotKey="Alt+Enter" ToolTip.Tip="{OnPlatform Alt+Enter, macOS=⌥+Enter}" ToolTip.Placement="Top" - ToolTip.VerticalOffset="0" - IsVisible="{Binding IsCommitWithPushVisible}"/> + ToolTip.VerticalOffset="0"> + + + + + + + +