Skip to content

Feature: Add flyout to confirm tag deletion #11358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 20, 2023
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
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,9 @@
<data name="ShowHiddenItems" xml:space="preserve">
<value>Show hidden items</value>
</data>
<data name="ConfirmDeleteTag" xml:space="preserve">
<value>Are you sure you want to delete this tag?</value>
</data>
<data name="PlayAll" xml:space="preserve">
<value>Play all</value>
</data>
Expand Down
27 changes: 25 additions & 2 deletions src/Files.App/Views/SettingsPages/Tags.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,31 @@
Padding="8,4"
Background="Transparent"
BorderBrush="Transparent"
Click="RemoveTag_Click"
Content="{helpers:ResourceString Name=Delete}" />
Click="PreRemoveTag_Click"
Content="{helpers:ResourceString Name=Delete}">
<Button.Flyout>
<Flyout>
<StackPanel MaxWidth="150" Spacing="12">
<TextBlock
Text="{helpers:ResourceString Name=ConfirmDeleteTag}"
TextAlignment="Center"
TextWrapping="Wrap" />
<StackPanel
HorizontalAlignment="Center"
Orientation="Horizontal"
Spacing="8">
<Button Click="CancelRemoveTag_Click" Content="{helpers:ResourceString Name=Cancel}" />

<Button
Background="{ThemeResource SystemFillColorCriticalBackgroundBrush}"
BorderBrush="Transparent"
Click="RemoveTag_Click"
Content="{helpers:ResourceString Name=Delete}" />
</StackPanel>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>

<StackPanel
Expand Down
13 changes: 13 additions & 0 deletions src/Files.App/Views/SettingsPages/Tags.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Files.Backend.ViewModels.FileTags;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using System.Linq;
using Windows.System;
Expand All @@ -15,6 +16,8 @@ public sealed partial class Tags : Page
// Will be null unless the user has edited any tag
private ListedTagViewModel? editingTag;

private FlyoutBase? deleteItemFlyout;

public Tags()
{
InitializeComponent();
Expand Down Expand Up @@ -66,6 +69,16 @@ private void CancelRenameTag_Click(object sender, RoutedEventArgs e)
CloseEdit();
}

private void PreRemoveTag_Click(object sender, RoutedEventArgs e)
{
deleteItemFlyout = ((Button)sender).Flyout;
}

private void CancelRemoveTag_Click(object sender, RoutedEventArgs e)
{
deleteItemFlyout?.Hide();
}

private void RemoveTag_Click(object sender, RoutedEventArgs e)
{
ViewModel.DeleteExistingTag((ListedTagViewModel)((Button)sender).DataContext);
Expand Down