diff --git a/src/Models/Bisect.cs b/src/Models/Bisect.cs index d1021113..2ed8beb2 100644 --- a/src/Models/Bisect.cs +++ b/src/Models/Bisect.cs @@ -14,8 +14,8 @@ namespace SourceGit.Models public enum BisectCommitFlag { None = 0, - Good = 1, - Bad = 2, + Good = 1 << 0, + Bad = 1 << 1, } public class Bisect diff --git a/src/Models/DirtyState.cs b/src/Models/DirtyState.cs new file mode 100644 index 00000000..2b9d898d --- /dev/null +++ b/src/Models/DirtyState.cs @@ -0,0 +1,12 @@ +using System; + +namespace SourceGit.Models +{ + [Flags] + public enum DirtyState + { + None = 0, + HasLocalChanges = 1 << 0, + HasPendingPullOrPush = 1 << 1, + } +} diff --git a/src/ViewModels/LauncherPage.cs b/src/ViewModels/LauncherPage.cs index 288770bc..b97ef6f7 100644 --- a/src/ViewModels/LauncherPage.cs +++ b/src/ViewModels/LauncherPage.cs @@ -1,5 +1,8 @@ using System; + using Avalonia.Collections; +using Avalonia.Media; + using CommunityToolkit.Mvvm.ComponentModel; namespace SourceGit.ViewModels @@ -18,6 +21,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _data, value); } + public IBrush DirtyBrush + { + get => _dirtyBrush; + private set => SetProperty(ref _dirtyBrush, value); + } + public Popup Popup { get => _popup; @@ -56,6 +65,26 @@ namespace SourceGit.ViewModels App.CopyText(_node.Id); } + public void ChangeDirtyState(Models.DirtyState flag, bool remove) + { + if (remove) + { + if (_dirtyState.HasFlag(flag)) + _dirtyState -= flag; + } + else + { + _dirtyState |= flag; + } + + if (_dirtyState.HasFlag(Models.DirtyState.HasLocalChanges)) + DirtyBrush = Brushes.Gray; + else if (_dirtyState.HasFlag(Models.DirtyState.HasPendingPullOrPush)) + DirtyBrush = Brushes.RoyalBlue; + else + DirtyBrush = null; + } + public bool CanCreatePopup() { return _popup == null || !_popup.InProgress; @@ -104,6 +133,8 @@ namespace SourceGit.ViewModels private RepositoryNode _node = null; private object _data = null; + private IBrush _dirtyBrush = null; + private Models.DirtyState _dirtyState = Models.DirtyState.None; private Popup _popup = null; } } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 1db1d6f3..289d890f 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -994,6 +994,8 @@ namespace SourceGit.ViewModels if (_workingCopy != null) _workingCopy.HasRemotes = remotes.Count > 0; + + GetOwnerPage()?.ChangeDirtyState(Models.DirtyState.HasPendingPullOrPush, !CurrentBranch.TrackStatus.IsVisible); }); } @@ -1101,6 +1103,7 @@ namespace SourceGit.ViewModels { LocalChangesCount = changes.Count; OnPropertyChanged(nameof(InProgressContext)); + GetOwnerPage()?.ChangeDirtyState(Models.DirtyState.HasLocalChanges, changes.Count == 0); }); } diff --git a/src/Views/LauncherTabBar.axaml b/src/Views/LauncherTabBar.axaml index 73b48f58..0376e259 100644 --- a/src/Views/LauncherTabBar.axaml +++ b/src/Views/LauncherTabBar.axaml @@ -68,14 +68,29 @@ Data="{StaticResource Icons.Repositories}" IsVisible="{Binding !Node.IsRepository}" IsHitTestVisible="False"/> - + + + + + + +