Skip to content

Commit 9dd4166

Browse files
committed
refactor: use MultiBinding instead of code to control visibility of Commit & Push button
1 parent a10f9e0 commit 9dd4166

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/ViewModels/WorkingCopy.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ public bool IncludeUntracked
2929
public bool CanCommitWithPush
3030
{
3131
get => _canCommitWithPush;
32-
set
33-
{
34-
if (SetProperty(ref _canCommitWithPush, value))
35-
OnPropertyChanged(nameof(IsCommitWithPushVisible));
36-
}
32+
set => SetProperty(ref _canCommitWithPush, value);
3733
}
3834

3935
public bool HasUnsolvedConflicts
@@ -89,16 +85,10 @@ public bool UseAmend
8985

9086
Staged = GetStagedChanges();
9187
SelectedStaged = [];
92-
OnPropertyChanged(nameof(IsCommitWithPushVisible));
9388
}
9489
}
9590
}
9691

97-
public bool IsCommitWithPushVisible
98-
{
99-
get => !UseAmend && CanCommitWithPush;
100-
}
101-
10292
public List<Models.Change> Unstaged
10393
{
10494
get => _unstaged;

src/Views/WorkingCopy.axaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,15 @@
355355
HotKey="Alt+Enter"
356356
ToolTip.Tip="{OnPlatform Alt+Enter, macOS=⌥+Enter}"
357357
ToolTip.Placement="Top"
358-
ToolTip.VerticalOffset="0"
359-
IsVisible="{Binding IsCommitWithPushVisible}"/>
358+
ToolTip.VerticalOffset="0">
359+
<Button.IsVisible>
360+
<MultiBinding Converter="{x:Static BoolConverters.And}">
361+
<Binding Path="UseAmend" Converter="{x:Static BoolConverters.Not}"/>
362+
<Binding Path="CanCommitWithPush"/>
363+
<Binding Path="InProgressContext" Converter="{x:Static ObjectConverters.IsNull}"/>
364+
</MultiBinding>
365+
</Button.IsVisible>
366+
</Button>
360367
</Grid>
361368
</Grid>
362369
</Grid>

0 commit comments

Comments
 (0)