Skip to content

Commit 09f8c98

Browse files
authored
Feature: Updated Git status icons (#12910)
1 parent 7f99548 commit 09f8c98

File tree

7 files changed

+30
-43
lines changed

7 files changed

+30
-43
lines changed

src/Files.App/Data/Items/ListedItem.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Files.Shared.Services.DateTimeFormatter;
1010
using FluentFTP;
1111
using Microsoft.UI;
12+
using Microsoft.UI.Xaml;
1213
using Microsoft.UI.Xaml.Media;
1314
using Microsoft.UI.Xaml.Media.Imaging;
1415
using System.IO;
@@ -631,11 +632,11 @@ public override string Name
631632

632633
public class GitItem : ListedItem
633634
{
634-
private string? _UnmergedGitStatusLabel;
635-
public string? UnmergedGitStatusLabel
635+
private Style? _UnmergedGitStatusIcon;
636+
public Style? UnmergedGitStatusIcon
636637
{
637-
get => _UnmergedGitStatusLabel;
638-
set => SetProperty(ref _UnmergedGitStatusLabel, value);
638+
get => _UnmergedGitStatusIcon;
639+
set => SetProperty(ref _UnmergedGitStatusIcon, value);
639640
}
640641

641642
private string? _UnmergedGitStatusName;
@@ -645,8 +646,6 @@ public string? UnmergedGitStatusName
645646
set => SetProperty(ref _UnmergedGitStatusName, value);
646647
}
647648

648-
public SolidColorBrush UnmergedGitStatusLabelForeground { get; init; }
649-
650649
private DateTimeOffset? _GitLastCommitDate;
651650
public DateTimeOffset? GitLastCommitDate
652651
{

src/Files.App/Data/Models/GitItemModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using LibGit2Sharp;
2+
using Microsoft.UI.Xaml;
23

34
namespace Files.App.Data.Models
45
{
@@ -14,14 +15,13 @@ internal class GitItemModel
1415
/// This is often showed as A(Added), D(Deleted), M(Modified), U(Untracked) in VS Code.
1516
/// </remarks>
1617
public ChangeKind Status { get; init; }
17-
18+
1819
/// <summary>
19-
/// Gets or initializes file change kind symbol
20+
/// Gets or initializes file change kind icon
2021
/// </summary>
2122
/// <remarks>
22-
/// This is often showed as A(Added), D(Deleted), M(Modified), U(Untracked) in VS Code.
2323
/// </remarks>
24-
public string? StatusSymbol { get; init; }
24+
public Style? StatusIcon { get; init; }
2525

2626
/// <summary>
2727
/// Gets or initializes file change kind humanized string

src/Files.App/Data/Models/ItemViewModel.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.Cloud;
5-
using Files.App.Utils.Search;
6-
using Files.App.Utils.StorageEnumerators;
7-
using Files.App.Utils.StorageItems;
84
using Files.App.Helpers.StorageCache;
9-
using Files.App.Utils.Shell;
105
using Files.App.ViewModels.Previews;
116
using Files.Core.Services.SizeProvider;
127
using Files.Shared.Cloud;
138
using Files.Shared.EventArguments;
149
using Files.Shared.Services;
10+
using LibGit2Sharp;
1511
using Microsoft.Extensions.Logging;
1612
using Microsoft.UI.Xaml.Data;
1713
using Microsoft.UI.Xaml.Media;
@@ -1223,7 +1219,14 @@ await SafetyExtensions.IgnoreExceptions(() =>
12231219
return dispatcherQueue.EnqueueOrInvokeAsync(() =>
12241220
{
12251221
var gitItem = item.AsGitItem;
1226-
gitItem.UnmergedGitStatusLabel = gitItemModel.StatusSymbol;
1222+
gitItem.UnmergedGitStatusIcon = gitItemModel.Status switch
1223+
{
1224+
ChangeKind.Added => (Microsoft.UI.Xaml.Style)Microsoft.UI.Xaml.Application.Current.Resources["ColorIconGitAdded"],
1225+
ChangeKind.Deleted => (Microsoft.UI.Xaml.Style)Microsoft.UI.Xaml.Application.Current.Resources["ColorIconGitDeleted"],
1226+
ChangeKind.Modified => (Microsoft.UI.Xaml.Style)Microsoft.UI.Xaml.Application.Current.Resources["ColorIconGitModified"],
1227+
ChangeKind.Untracked => (Microsoft.UI.Xaml.Style)Microsoft.UI.Xaml.Application.Current.Resources["ColorIconGitUntracked"],
1228+
_ => null,
1229+
};
12271230
gitItem.UnmergedGitStatusName = gitItemModel.StatusHumanized;
12281231
gitItem.GitLastCommitDate = gitItemModel.LastCommit?.Author.When;
12291232
gitItem.GitLastCommitMessage = gitItemModel.LastCommit?.MessageShort;

src/Files.App/ResourceDictionaries/PathIcons.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@
24572457
<Path
24582458
x:Name="Path1"
24592459
Data="M4 1C2.34315 1 1 2.34315 1 4V12C1 13.6569 2.34315 15 4 15H12C13.6569 15 15 13.6569 15 12V4C15 2.34315 13.6569 1 12 1H4ZM2 4C2 2.89543 2.89543 2 4 2H12C13.1046 2 14 2.89543 14 4V12C14 13.1046 13.1046 14 12 14H4C2.89543 14 2 13.1046 2 12V4ZM4.5 7.50021C4.22386 7.50021 4 7.72407 4 8.00021C4 8.27636 4.22386 8.50021 4.5 8.50021C10.3343 8.50021 5.66567 8.50021 11.5 8.50021C11.7761 8.50021 12 8.27636 12 8.00021C12 7.72407 11.7761 7.50021 11.5 7.50021C5.66567 7.50021 10.3343 7.50021 4.5 7.50021Z"
2460-
Fill="{ThemeResource SystemFillColorSuccessBrush}" />
2460+
Fill="{ThemeResource SystemFillColorCriticalBrush}" />
24612461
</Grid>
24622462

24632463
<VisualStateManager.VisualStateGroups>

src/Files.App/Utils/Git/GitHelpers.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using Files.App.Dialogs;
5-
using Files.App.Utils.StorageItems;
65
using Files.App.ViewModels.Dialogs;
76
using LibGit2Sharp;
87
using Microsoft.AppCenter.Analytics;
@@ -510,19 +509,6 @@ public static GitItemModel GetGitInformationForItem(Repository repository, strin
510509
}
511510
}
512511

513-
string? changeKindSymbol = null;
514-
if (changeKind is not ChangeKind.Ignored)
515-
{
516-
changeKindSymbol = changeKind switch
517-
{
518-
ChangeKind.Added => "A",
519-
ChangeKind.Deleted => "D",
520-
ChangeKind.Modified => "M",
521-
ChangeKind.Untracked => "U",
522-
_ => null,
523-
};
524-
}
525-
526512
string? changeKindHumanized = null;
527513
if (changeKind is not ChangeKind.Ignored)
528514
{
@@ -539,7 +525,6 @@ public static GitItemModel GetGitInformationForItem(Repository repository, strin
539525
var gitItemModel = new GitItemModel()
540526
{
541527
Status = changeKind,
542-
StatusSymbol = changeKindSymbol,
543528
StatusHumanized = changeKindHumanized,
544529
LastCommit = commit,
545530
Path = relativePath,
@@ -593,7 +578,7 @@ public static void InitializeRepository(string? path)
593578
private static void CheckoutRemoteBranch(Repository repository, Branch branch)
594579
{
595580
var uniqueName = branch.FriendlyName.Substring(END_OF_ORIGIN_PREFIX);
596-
581+
597582
// TODO: This is a temp fix to avoid an issue where Files would create many branches in a loop
598583
if (repository.Branches.Any(b => !b.IsRemote && b.FriendlyName == uniqueName))
599584
return;

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,20 +1015,21 @@
10151015
</Grid>
10161016

10171017
<!-- Item Git Status -->
1018-
<TextBlock
1018+
<Border
10191019
x:Name="ItemGitStatusTextBlock"
10201020
Width="{Binding ColumnsViewModel.GitStatusColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
10211021
Padding="12,0,0,0"
10221022
HorizontalAlignment="Stretch"
10231023
VerticalAlignment="Center"
1024-
x:Load="{x:Bind IsGitItem}"
1025-
FontWeight="SemiBold"
1026-
Foreground="{ThemeResource SystemFillColorSuccessBrush}"
1027-
Style="{StaticResource ColumnContentTextBlock}"
1028-
Text="{x:Bind AsGitItem.UnmergedGitStatusLabel, Mode=OneWay}"
1029-
TextTrimming="CharacterEllipsis"
1030-
ToolTipService.ToolTip="{x:Bind AsGitItem.UnmergedGitStatusName, Mode=OneWay}"
1031-
Visibility="{Binding ColumnsViewModel.GitStatusColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
1024+
x:Load="{x:Bind IsGitItem}">
1025+
<uc:OpacityIcon
1026+
Width="16"
1027+
Height="16"
1028+
HorizontalAlignment="Left"
1029+
Style="{x:Bind AsGitItem.UnmergedGitStatusIcon, Mode=OneWay}"
1030+
ToolTipService.ToolTip="{x:Bind AsGitItem.UnmergedGitStatusName, Mode=OneWay}"
1031+
Visibility="{Binding ColumnsViewModel.GitStatusColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
1032+
</Border>
10321033

10331034
<!-- Item Git Last Commit Date -->
10341035
<TextBlock

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ private void ResizeColumnToFit(int columnToResize)
592592
{
593593
1 => 40, // Check all items columns
594594
2 => FileList.Items.Cast<ListedItem>().Select(x => x.Name?.Length ?? 0).Max(), // file name column
595-
3 => FileList.Items.Cast<ListedItem>().Select(x => (x as GitItem)?.UnmergedGitStatusLabel?.Length ?? 0).Max(), // git
596595
4 => FileList.Items.Cast<ListedItem>().Select(x => (x as GitItem)?.GitLastCommitDateHumanized?.Length ?? 0).Max(), // git
597596
5 => FileList.Items.Cast<ListedItem>().Select(x => (x as GitItem)?.GitLastCommitMessage?.Length ?? 0).Max(), // git
598597
6 => FileList.Items.Cast<ListedItem>().Select(x => (x as GitItem)?.GitLastCommitAuthor?.Length ?? 0).Max(), // git

0 commit comments

Comments
 (0)