Skip to content

Commit 9fb8af5

Browse files
authored
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.)
1 parent 1ee7d11 commit 9fb8af5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Views/ChangeStatusIcon.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public class ChangeStatusIcon : Control
6464
private static readonly string[] INDICATOR = ["?", "±", "T", "+", "−", "➜", "❏", "U", "★"];
6565
private static readonly string[] TIPS = ["Unknown", "Modified", "Type Changed", "Added", "Deleted", "Renamed", "Copied", "Unmerged", "Untracked"];
6666

67+
private static readonly IBrush BACKGROUND_CONFLICT = Brushes.OrangeRed;
68+
private const string INDICATOR_CONFLICT = "!";
69+
private const string TIP_CONFLICT = "Conflict";
70+
6771
public static readonly StyledProperty<bool> IsUnstagedChangeProperty =
6872
AvaloniaProperty.Register<ChangeStatusIcon, bool>(nameof(IsUnstagedChange));
6973

@@ -95,8 +99,8 @@ public override void Render(DrawingContext context)
9599
{
96100
if (Change.IsConflict)
97101
{
98-
background = Brushes.OrangeRed;
99-
indicator = "!";
102+
background = BACKGROUND_CONFLICT;
103+
indicator = INDICATOR_CONFLICT;
100104
}
101105
else
102106
{
@@ -139,7 +143,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
139143
}
140144

141145
if (isUnstaged)
142-
ToolTip.SetTip(this, c.IsConflict ? "Conflict" : TIPS[(int)c.WorkTree]);
146+
ToolTip.SetTip(this, c.IsConflict ? TIP_CONFLICT : TIPS[(int)c.WorkTree]);
143147
else
144148
ToolTip.SetTip(this, TIPS[(int)c.Index]);
145149

0 commit comments

Comments
 (0)