1- using Microsoft . UI ;
2- using Microsoft . UI . Xaml ;
1+ using Microsoft . UI . Xaml ;
32using Microsoft . UI . Xaml . Controls ;
3+ using Microsoft . UI . Xaml . Controls . AnimatedVisuals ;
44using Microsoft . UI . Xaml . Media ;
5+ using System . Numerics ;
6+ using System . Runtime . CompilerServices ;
57
68namespace Files . App . UserControls . Symbols
79{
810 [ DependencyProperty < double > ( "FontSize" , DefaultValue = "(double)12.0" ) ]
9- [ DependencyProperty < Brush > ( "Color " , nameof ( OnColorChange ) , DefaultValue = "null" ) ]
11+ [ DependencyProperty < Brush > ( "Foreground " , nameof ( OnColorChange ) , DefaultValue = "null" ) ]
1012 [ DependencyProperty < ArrowSymbolType > ( "Arrow" , nameof ( OnArrowChange ) , DefaultValue = "Files.App.Data.Enums.ArrowSymbolType.ChevronRight" ) ]
13+ [ DependencyProperty < bool > ( "UseAnimatedIcon" , nameof ( OnUseAnimatedIconChanged ) , DefaultValue = "false" ) ]
1114 [ DependencyProperty < string > ( "Glyph" , DefaultValue = "null" ) ]
12- public sealed partial class ArrowGlyph : UserControl , IRealTimeControl
15+ public partial class ArrowGlyph : UserControl , INotifyPropertyChanged , IRealTimeControl
1316 {
1417 private static ICommandManager Commands { get ; } = Ioc . Default . GetRequiredService < ICommandManager > ( ) ;
1518
1619 private string ForwardGlyph { get ; } = Commands . NavigateForward . Glyph . BaseGlyph ;
17-
1820 private string BackGlyph { get ; } = Commands . NavigateBack . Glyph . BaseGlyph ;
19-
2021 private string ChevronLeft { get ; } = "\uE76B " ;
2122 private string ChevronRight { get ; } = "\uE76C " ;
2223
2324 private long _token ;
2425
26+ public event PropertyChangedEventHandler ? PropertyChanged ;
27+
28+ public bool IsStaticIconVisible => ! UseAnimatedIcon ;
29+
30+ public bool IsAnimatedIconVisible => UseAnimatedIcon ;
31+
2532 public ArrowGlyph ( )
2633 {
2734 InitializeComponent ( ) ;
@@ -30,8 +37,25 @@ public ArrowGlyph()
3037 RealTimeLayoutService . AddCallback ( this , UpdateGlyph ) ;
3138 }
3239
40+
41+ protected void OnPropertyChanged ( [ CallerMemberName ] string ? propertyName = null )
42+ {
43+ PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
44+ }
45+
3346 private void UpdateGlyph ( )
3447 {
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+
3559 Glyph = Arrow switch
3660 {
3761 ArrowSymbolType . Forward => FlowDirection == FlowDirection . LeftToRight ? ForwardGlyph : BackGlyph ,
@@ -56,6 +80,26 @@ private void OnArrowChange(ArrowSymbolType oldValue, ArrowSymbolType newValue)
5680 if ( oldValue != newValue )
5781 UpdateGlyph ( ) ;
5882 }
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+ }
59103 }
60104
61105}
0 commit comments