From 9fb8af51ffd246c7117226ba97067462fbb66e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20W?= <44604769+goran-w@users.noreply.github.com> Date: Fri, 23 May 2025 03:18:05 +0200 Subject: [PATCH] code_style: move hardcoded brush/strings (for outlier Conflict-icon) into named constants (#1350) This makes code more consistent and gives better overview of all the icons. (Potentially, this special/outlier icon could be moved into the existing arrays as an extra ChangeState enum-value.) --- src/Views/ChangeStatusIcon.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Views/ChangeStatusIcon.cs b/src/Views/ChangeStatusIcon.cs index 7dbd0beb..5cafb851 100644 --- a/src/Views/ChangeStatusIcon.cs +++ b/src/Views/ChangeStatusIcon.cs @@ -64,6 +64,10 @@ namespace SourceGit.Views private static readonly string[] INDICATOR = ["?", "±", "T", "+", "−", "➜", "❏", "U", "★"]; private static readonly string[] TIPS = ["Unknown", "Modified", "Type Changed", "Added", "Deleted", "Renamed", "Copied", "Unmerged", "Untracked"]; + private static readonly IBrush BACKGROUND_CONFLICT = Brushes.OrangeRed; + private const string INDICATOR_CONFLICT = "!"; + private const string TIP_CONFLICT = "Conflict"; + public static readonly StyledProperty IsUnstagedChangeProperty = AvaloniaProperty.Register(nameof(IsUnstagedChange)); @@ -95,8 +99,8 @@ namespace SourceGit.Views { if (Change.IsConflict) { - background = Brushes.OrangeRed; - indicator = "!"; + background = BACKGROUND_CONFLICT; + indicator = INDICATOR_CONFLICT; } else { @@ -139,7 +143,7 @@ namespace SourceGit.Views } if (isUnstaged) - ToolTip.SetTip(this, c.IsConflict ? "Conflict" : TIPS[(int)c.WorkTree]); + ToolTip.SetTip(this, c.IsConflict ? TIP_CONFLICT : TIPS[(int)c.WorkTree]); else ToolTip.SetTip(this, TIPS[(int)c.Index]);