Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 41 additions & 25 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -689,31 +689,47 @@
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="filetags:TagViewModel">
<StackPanel
Height="24"
Padding="8,0"
HorizontalAlignment="Left"
x:Phase="2"
BorderBrush="{x:Bind Color, Mode=OneWay, Converter={StaticResource StringToBrushConverter}}"
BorderThickness="1"
CornerRadius="12"
Orientation="Horizontal"
Spacing="8"
Tapped="TagItem_Tapped"
ToolTipService.ToolTip="{x:Bind Name, Mode=OneWay}">
<FontIcon
FontSize="12"
Foreground="{x:Bind Color, Mode=OneWay, Converter={StaticResource StringToBrushConverter}}"
Glyph="&#xE1CB;" />
<TextBlock
x:Name="ItemTag"
VerticalAlignment="Center"
FontSize="12"
LineHeight="18"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind Name, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
<UserControl PointerEntered="FileTag_PointerEntered" PointerExited="FileTag_PointerExited">
<StackPanel
Height="24"
Padding="8,0"
HorizontalAlignment="Left"
x:Phase="2"
BorderBrush="{x:Bind Color, Mode=OneWay, Converter={StaticResource StringToBrushConverter}}"
BorderThickness="1"
CornerRadius="12"
Orientation="Horizontal"
Tapped="TagItem_Tapped"
ToolTipService.ToolTip="{x:Bind Name, Mode=OneWay}">
<FontIcon
x:Name="TagIcon"
FontSize="12"
Foreground="{x:Bind Color, Mode=OneWay, Converter={StaticResource StringToBrushConverter}}"
Glyph="&#xE1CB;"
Tapped="TagIcon_Tapped"
ToolTipService.ToolTip="{helpers:ResourceString Name=Remove}" />
<TextBlock
Padding="8,0,0,0"
VerticalAlignment="Center"
FontSize="12"
LineHeight="18"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind Name, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />

<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="TagIcon.Glyph" Value="&#xE711;" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</StackPanel>
</UserControl>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
Expand Down
34 changes: 32 additions & 2 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.UI;
using Files.App.EventArguments;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -39,6 +40,8 @@ public sealed partial class DetailsLayoutBrowser : StandardViewBase

private ListedItem? _nextItemToSelect;

private IFileTagsSettingsService tagsSettingsService { get; } = Ioc.Default.GetRequiredService<IFileTagsSettingsService>();

protected override uint IconSize => currentIconSize;

protected override ListViewBase ListViewBase => FileList;
Expand Down Expand Up @@ -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;
}
}
}