Skip to content

Commit d7b8474

Browse files
committed
Merge branch 'xtorlukas/Fix-WrongArrowInRTL' into xtorlukas/Featue-RealTimeLayoutUpdate
2 parents 38e6465 + ca698e2 commit d7b8474

File tree

9 files changed

+211
-66
lines changed

9 files changed

+211
-66
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
namespace Files.App.Data.Enums
5+
{
6+
public enum ArrowSymbolType
7+
{
8+
Forward,
9+
Back,
10+
ChevronLeft,
11+
ChevronRight
12+
}
13+
}

src/Files.App/UserControls/AddressToolbar.xaml

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
xmlns:keyboard="using:Files.App.UserControls.KeyboardShortcut"
1515
xmlns:local="using:Files.App.UserControls"
1616
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
17+
xmlns:s="using:Files.App.UserControls.Symbols"
1718
xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers"
1819
xmlns:uc="using:Files.App.UserControls"
1920
xmlns:ucs="using:Files.App.UserControls.StatusCenter"
@@ -263,37 +264,36 @@
263264
</AnimatedIcon>
264265
</ToggleButton>
265266

266-
<StackPanel FlowDirection="LeftToRight" Orientation="Horizontal">
267-
<Button
268-
x:Name="Back"
269-
AccessKey="B"
270-
AccessKeyInvoked="Button_AccessKeyInvoked"
271-
AutomationProperties.FullDescription="{x:Bind ViewModel.Commands.NavigateBack.Description, Mode=OneWay}"
272-
AutomationProperties.Name="{x:Bind ViewModel.Commands.NavigateBack.Label, Mode=OneWay}"
273-
Command="{x:Bind ViewModel.Commands.NavigateBack, Mode=OneWay}"
274-
IsEnabled="{x:Bind ViewModel.Commands.NavigateBack.IsExecutable, Mode=OneWay}"
275-
Style="{StaticResource AddressToolbarButtonStyle}"
276-
ToolTipService.ToolTip="{x:Bind ViewModel.Commands.NavigateBack.LabelWithHotKey, Mode=OneWay}">
277-
<FontIcon FontSize="14" Glyph="{x:Bind ViewModel.Commands.NavigateBack.Glyph.BaseGlyph, Mode=OneWay}" />
278-
<Button.ContextFlyout>
279-
<MenuFlyout
280-
x:Name="BackHistoryFlyout"
281-
Opening="BackHistoryFlyout_Opening"
282-
Placement="BottomEdgeAlignedLeft"
283-
ScrollViewer.VerticalScrollBarVisibility="Auto"
284-
ScrollViewer.VerticalScrollMode="Auto">
285-
<MenuFlyout.MenuFlyoutPresenterStyle>
286-
<Style TargetType="MenuFlyoutPresenter">
287-
<Setter Property="MaxHeight" Value="400" />
288-
<!-- Workaround for https://github.com/files-community/Files/issues/13078 -->
289-
<Setter Target="HighContrastAdjustment" Value="None" />
290-
</Style>
291-
</MenuFlyout.MenuFlyoutPresenterStyle>
292-
</MenuFlyout>
293-
</Button.ContextFlyout>
294-
</Button>
295-
296-
<Button
267+
<Button
268+
x:Name="Back"
269+
AccessKey="B"
270+
AccessKeyInvoked="Button_AccessKeyInvoked"
271+
AutomationProperties.FullDescription="{x:Bind ViewModel.Commands.NavigateBack.Description, Mode=OneWay}"
272+
AutomationProperties.Name="{x:Bind ViewModel.Commands.NavigateBack.Label, Mode=OneWay}"
273+
Command="{x:Bind ViewModel.Commands.NavigateBack, Mode=OneWay}"
274+
IsEnabled="{x:Bind ViewModel.Commands.NavigateBack.IsExecutable, Mode=OneWay}"
275+
Style="{StaticResource AddressToolbarButtonStyle}"
276+
ToolTipService.ToolTip="{x:Bind ViewModel.Commands.NavigateBack.LabelWithHotKey, Mode=OneWay}">
277+
<s:ArrowGlyph Arrow="Back" FontSize="14" />
278+
<Button.ContextFlyout>
279+
<MenuFlyout
280+
x:Name="BackHistoryFlyout"
281+
Opening="BackHistoryFlyout_Opening"
282+
Placement="BottomEdgeAlignedLeft"
283+
ScrollViewer.VerticalScrollBarVisibility="Auto"
284+
ScrollViewer.VerticalScrollMode="Auto">
285+
<MenuFlyout.MenuFlyoutPresenterStyle>
286+
<Style TargetType="MenuFlyoutPresenter">
287+
<Setter Property="MaxHeight" Value="400" />
288+
<!-- Workaround for https://github.com/files-community/Files/issues/13078 -->
289+
<Setter Target="HighContrastAdjustment" Value="None" />
290+
</Style>
291+
</MenuFlyout.MenuFlyoutPresenterStyle>
292+
</MenuFlyout>
293+
</Button.ContextFlyout>
294+
</Button>
295+
296+
<Button
297297
x:Name="Forward"
298298
AccessKey="F"
299299
AccessKeyInvoked="Button_AccessKeyInvoked"
@@ -303,25 +303,24 @@
303303
IsEnabled="{x:Bind ViewModel.Commands.NavigateForward.IsExecutable, Mode=OneWay}"
304304
Style="{StaticResource AddressToolbarButtonStyle}"
305305
ToolTipService.ToolTip="{x:Bind ViewModel.Commands.NavigateForward.LabelWithHotKey, Mode=OneWay}">
306-
<FontIcon FontSize="14" Glyph="{x:Bind ViewModel.Commands.NavigateForward.Glyph.BaseGlyph, Mode=OneWay}" />
307-
<Button.ContextFlyout>
308-
<MenuFlyout
306+
<s:ArrowGlyph Arrow="Forward" FontSize="14" />
307+
<Button.ContextFlyout>
308+
<MenuFlyout
309309
x:Name="ForwardHistoryFlyout"
310310
Opening="ForwardHistoryFlyout_Opening"
311311
Placement="BottomEdgeAlignedLeft"
312312
ScrollViewer.VerticalScrollBarVisibility="Auto"
313313
ScrollViewer.VerticalScrollMode="Auto">
314-
<MenuFlyout.MenuFlyoutPresenterStyle>
315-
<Style TargetType="MenuFlyoutPresenter">
316-
<Setter Property="MaxHeight" Value="400" />
317-
<!-- Workaround for https://github.com/files-community/Files/issues/13078 -->
318-
<Setter Target="HighContrastAdjustment" Value="None" />
319-
</Style>
320-
</MenuFlyout.MenuFlyoutPresenterStyle>
321-
</MenuFlyout>
322-
</Button.ContextFlyout>
323-
</Button>
324-
</StackPanel>
314+
<MenuFlyout.MenuFlyoutPresenterStyle>
315+
<Style TargetType="MenuFlyoutPresenter">
316+
<Setter Property="MaxHeight" Value="400" />
317+
<!-- Workaround for https://github.com/files-community/Files/issues/13078 -->
318+
<Setter Target="HighContrastAdjustment" Value="None" />
319+
</Style>
320+
</MenuFlyout.MenuFlyoutPresenterStyle>
321+
</MenuFlyout>
322+
</Button.ContextFlyout>
323+
</Button>
325324

326325
<Button
327326
x:Name="Up"

src/Files.App/UserControls/PathBreadcrumb.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
xmlns:dataitem="using:Files.App.Data.Items"
99
xmlns:i="using:Microsoft.Xaml.Interactivity"
1010
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
xmlns:s="using:Files.App.UserControls.Symbols"
1112
xmlns:templateselectors="using:Files.App.Data.TemplateSelectors"
1213
mc:Ignorable="d">
1314

@@ -110,11 +111,11 @@
110111
</Button.Flyout>
111112

112113
<!-- Chevron -->
113-
<FontIcon
114+
<s:ArrowGlyph
114115
x:Name="ExpandMenuFontIcon"
116+
Arrow="ChevronRight"
115117
AutomationProperties.AccessibilityView="Raw"
116-
FontSize="12"
117-
Glyph="&#xE76C;" />
118+
FontSize="12" />
118119
</Button>
119120

120121
</StackPanel>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<UserControl
2+
x:Class="Files.App.UserControls.Symbols.ArrowGlyph"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:local="using:Files.App.UserControls.Symbols"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
x:Name="Root"
10+
mc:Ignorable="d">
11+
12+
<Grid x:Name="SymbolGrid" Loaded="SymbolGrid_Loaded">
13+
<FontIcon
14+
x:Name="SymbolIcon"
15+
FontSize="{Binding FontSize, ElementName=Root}"
16+
Glyph="{x:Bind Glyph, Mode=OneWay}"
17+
Visibility="{x:Bind IsStaticIconVisible, Mode=OneWay}" />
18+
19+
<AnimatedIcon x:Name="DynamicAnimatedIcon" Visibility="{x:Bind IsAnimatedIconVisible, Mode=OneWay}">
20+
<AnimatedIcon.Source>
21+
<animatedvisuals:AnimatedBackVisualSource />
22+
</AnimatedIcon.Source>
23+
<AnimatedIcon.FallbackIconSource>
24+
<SymbolIconSource Symbol="Back" />
25+
</AnimatedIcon.FallbackIconSource>
26+
</AnimatedIcon>
27+
</Grid>
28+
</UserControl>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using Microsoft.UI.Xaml;
2+
using Microsoft.UI.Xaml.Controls;
3+
using Microsoft.UI.Xaml.Controls.AnimatedVisuals;
4+
using Microsoft.UI.Xaml.Media;
5+
using System.Numerics;
6+
using System.Runtime.CompilerServices;
7+
8+
namespace Files.App.UserControls.Symbols
9+
{
10+
[DependencyProperty<double>("FontSize", DefaultValue = "(double)12.0")]
11+
[DependencyProperty<Brush>("Foreground", nameof(OnColorChange), DefaultValue = "null")]
12+
[DependencyProperty<ArrowSymbolType>("Arrow", nameof(OnArrowChange), DefaultValue = "Files.App.Data.Enums.ArrowSymbolType.ChevronRight")]
13+
[DependencyProperty<bool>("UseAnimatedIcon", nameof(OnUseAnimatedIconChanged), DefaultValue = "false")]
14+
[DependencyProperty<string>("Glyph", DefaultValue = "null")]
15+
public partial class ArrowGlyph : UserControl, INotifyPropertyChanged, IRealTimeControl
16+
{
17+
private static ICommandManager Commands { get; } = Ioc.Default.GetRequiredService<ICommandManager>();
18+
19+
private string ForwardGlyph { get; } = Commands.NavigateForward.Glyph.BaseGlyph;
20+
private string BackGlyph { get; } = Commands.NavigateBack.Glyph.BaseGlyph;
21+
private string ChevronLeft { get; } = "\uE76B";
22+
private string ChevronRight { get; } = "\uE76C";
23+
24+
private long _token;
25+
26+
public event PropertyChangedEventHandler? PropertyChanged;
27+
28+
public bool IsStaticIconVisible => !UseAnimatedIcon;
29+
30+
public bool IsAnimatedIconVisible => UseAnimatedIcon;
31+
32+
public ArrowGlyph()
33+
{
34+
InitializeComponent();
35+
InitializeContentLayout();
36+
UpdateGlyph();
37+
RealTimeLayoutService.AddCallback(this, UpdateGlyph);
38+
}
39+
40+
41+
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
42+
{
43+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
44+
}
45+
46+
private void UpdateGlyph()
47+
{
48+
if (UseAnimatedIcon)
49+
{
50+
SymbolGrid.Rotation = Arrow switch
51+
{
52+
ArrowSymbolType.Forward => FlowDirection == FlowDirection.LeftToRight ? 180 : 0,
53+
ArrowSymbolType.Back => FlowDirection == FlowDirection.LeftToRight ? 0 : 180,
54+
_ => 0
55+
};
56+
return;
57+
}
58+
59+
Glyph = Arrow switch
60+
{
61+
ArrowSymbolType.Forward => FlowDirection == FlowDirection.LeftToRight ? ForwardGlyph : BackGlyph,
62+
ArrowSymbolType.Back => FlowDirection == FlowDirection.LeftToRight ? BackGlyph : ForwardGlyph,
63+
ArrowSymbolType.ChevronLeft => FlowDirection == FlowDirection.LeftToRight ? ChevronLeft : ChevronRight,
64+
ArrowSymbolType.ChevronRight => FlowDirection == FlowDirection.LeftToRight ? ChevronRight : ChevronLeft,
65+
_ => ChevronLeft
66+
};
67+
}
68+
69+
private void OnColorChange(Brush oldValue, Brush newValue)
70+
{
71+
if (oldValue != newValue)
72+
{
73+
SymbolIcon.Foreground = newValue;
74+
UpdateGlyph();
75+
}
76+
}
77+
78+
private void OnArrowChange(ArrowSymbolType oldValue, ArrowSymbolType newValue)
79+
{
80+
if (oldValue != newValue)
81+
UpdateGlyph();
82+
}
83+
84+
private void OnUseAnimatedIconChanged(bool oldValue, bool newValue)
85+
{
86+
if (oldValue != newValue)
87+
{
88+
UpdateGlyph();
89+
OnPropertyChanged(nameof(IsStaticIconVisible));
90+
OnPropertyChanged(nameof(IsAnimatedIconVisible));
91+
}
92+
}
93+
94+
private void SymbolGrid_Loaded(object sender, RoutedEventArgs e)
95+
{
96+
if (UseAnimatedIcon)
97+
{
98+
var centerX = SymbolGrid.ActualWidth / 2;
99+
var centerY = SymbolGrid.ActualHeight / 2;
100+
SymbolGrid.CenterPoint = new Vector3((float)centerX, (float)centerY, 0);
101+
}
102+
}
103+
}
104+
105+
}

src/Files.App/Views/Layouts/ColumnLayoutPage.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
xmlns:helpers="using:Files.App.Helpers"
1212
xmlns:local="using:Files.App.Views.Layouts"
1313
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
14+
xmlns:s="using:Files.App.UserControls.Symbols"
1415
xmlns:storage="using:Files.App.Utils.Storage"
1516
xmlns:uc="using:Files.App.UserControls"
1617
xmlns:wct="using:CommunityToolkit.WinUI.UI"
@@ -337,14 +338,14 @@
337338
Visibility="{x:Bind FileTagsUI, Converter={StaticResource EmptyObjectToObjectConverter}, Mode=OneWay}" />
338339

339340
<!-- Open Folder Chevron -->
340-
<FontIcon
341+
<s:ArrowGlyph
341342
x:Name="OpenFolderChevron"
342343
HorizontalAlignment="Right"
343344
VerticalAlignment="Center"
344345
x:Load="{x:Bind IsFolder}"
346+
Arrow="ChevronRight"
345347
FontSize="12"
346-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
347-
Glyph="&#xE76C;" />
348+
Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
348349

349350
</StackPanel>
350351
</Grid>

src/Files.App/Views/Properties/MainPropertiesPage.xaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xmlns:dataitems="using:Files.App.Data.Items"
1010
xmlns:helpers="using:Files.App.Helpers"
1111
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
12+
xmlns:s="using:Files.App.UserControls.Symbols"
1213
xmlns:uc="using:Files.App.UserControls"
1314
xmlns:vm="using:Files.App.ViewModels.Properties"
1415
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
@@ -69,14 +70,7 @@
6970
<StaticResource x:Key="ButtonBorderBrushDisabled" ResourceKey="SystemControlTransparentBrush" />
7071
</ResourceDictionary>
7172
</Button.Resources>
72-
<AnimatedIcon x:Name="BackAnimatedIcon">
73-
<AnimatedIcon.Source>
74-
<animatedvisuals:AnimatedBackVisualSource />
75-
</AnimatedIcon.Source>
76-
<AnimatedIcon.FallbackIconSource>
77-
<SymbolIconSource Symbol="Back" />
78-
</AnimatedIcon.FallbackIconSource>
79-
</AnimatedIcon>
73+
<s:ArrowGlyph Arrow="Back" UseAnimatedIcon="True" />
8074
</Button>
8175

8276
<!-- Title Text Area -->

src/Files.App/Views/Properties/SecurityPage.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:dataitems="using:Files.App.Data.Items"
88
xmlns:helpers="using:Files.App.Helpers"
99
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
xmlns:s="using:Files.App.UserControls.Symbols"
1011
xmlns:vm="using:Files.App.ViewModels.Properties"
1112
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
1213
DataContext="{x:Bind SecurityViewModel, Mode=OneWay}"
@@ -219,7 +220,7 @@
219220
ToolTipService.ToolTip="{helpers:ResourceString Name=AdvancedPermissions}">
220221
<StackPanel Orientation="Horizontal" Spacing="4">
221222
<TextBlock Text="{helpers:ResourceString Name=AdvancedPermissions}" />
222-
<FontIcon FontSize="14" Glyph="&#xE76C;" />
223+
<s:ArrowGlyph Arrow="ChevronRight" FontSize="14" />
223224
</StackPanel>
224225
</Button>
225226

src/Files.App/Views/Shells/ModernShellPage.xaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:local="using:Files.App.Views.Shells"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:s="using:Files.App.UserControls.Symbols"
910
xmlns:wct="using:CommunityToolkit.WinUI.UI"
1011
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
1112
x:Name="RootPage"
@@ -71,11 +72,12 @@
7172
BorderThickness="1"
7273
Canvas.ZIndex="64"
7374
CornerRadius="24">
74-
<FontIcon
75+
<s:ArrowGlyph
7576
HorizontalAlignment="Center"
7677
VerticalAlignment="Center"
77-
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}"
78-
Glyph="&#xE72B;" />
78+
Arrow="Back"
79+
FontSize="14"
80+
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}" />
7981
</Border>
8082

8183
<!-- Swipe Forward Icon -->
@@ -92,11 +94,12 @@
9294
BorderThickness="1"
9395
Canvas.ZIndex="64"
9496
CornerRadius="24">
95-
<SymbolIcon
97+
<s:ArrowGlyph
9698
HorizontalAlignment="Center"
9799
VerticalAlignment="Center"
98-
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}"
99-
Symbol="Forward" />
100+
Arrow="Forward"
101+
FontSize="14"
102+
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}" />
100103
</Border>
101104

102105
<!-- Shell Frame -->

0 commit comments

Comments
 (0)