diff --git a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml index 3daf0a2618a0..6abeddb874fb 100644 --- a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml +++ b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml @@ -689,31 +689,47 @@ - - - - + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs index 77e7d6a10cd9..2f5ad39e0dbe 100644 --- a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs +++ b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs @@ -1,3 +1,4 @@ +using CommunityToolkit.Mvvm.DependencyInjection; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.WinUI.UI; using Files.App.EventArguments; @@ -7,6 +8,7 @@ using Files.App.UserControls; using Files.App.UserControls.Selection; using Files.App.ViewModels; +using Files.Backend.Services.Settings; using Files.Shared.Enums; using Microsoft.UI.Input; using Microsoft.UI.Xaml; @@ -15,7 +17,6 @@ using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; using System; -using System.Globalization; using System.Linq; using UWPToWinAppSDKUpgradeHelpers; using Windows.Foundation; @@ -39,6 +40,8 @@ public sealed partial class DetailsLayoutBrowser : StandardViewBase private ListedItem? _nextItemToSelect; + private IFileTagsSettingsService tagsSettingsService { get; } = Ioc.Default.GetRequiredService(); + protected override uint IconSize => currentIconSize; protected override ListViewBase ListViewBase => FileList; @@ -733,7 +736,34 @@ private void TagItem_Tapped(object sender, TappedRoutedEventArgs e) if (tagName is null) return; - ParentShellPageInstance.SubmitSearch($"tag:{tagName}", false); + ParentShellPageInstance?.SubmitSearch($"tag:{tagName}", false); + } + + private void FileTag_PointerEntered(object sender, PointerRoutedEventArgs e) + { + VisualStateManager.GoToState((UserControl)sender, "PointerOver", true); + } + + private void FileTag_PointerExited(object sender, PointerRoutedEventArgs e) + { + VisualStateManager.GoToState((UserControl)sender, "Normal", true); + } + + private void TagIcon_Tapped(object sender, TappedRoutedEventArgs e) + { + var parent = (sender as FontIcon)?.Parent as StackPanel; + var tagName = (parent?.Children[TAG_TEXT_BLOCK] as TextBlock)?.Text; + + if (tagName is null || parent?.DataContext is not ListedItem item) + return; + + var tagId = tagsSettingsService.GetTagsByName(tagName).FirstOrDefault()?.Uid; + + item.FileTags = item.FileTags + .Except(new string[] { tagId }) + .ToArray(); + + e.Handled = true; } } }