diff --git a/SukiUI.Demo/App.axaml b/SukiUI.Demo/App.axaml index f3c8ef6e0..11485037b 100644 --- a/SukiUI.Demo/App.axaml +++ b/SukiUI.Demo/App.axaml @@ -2,6 +2,7 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" + xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit" xmlns:common="clr-namespace:SukiUI.Demo.Common" xmlns:suki="https://github.com/kikipoulet/SukiUI" RequestedThemeVariant="Default"> @@ -42,6 +43,9 @@ + @@ -50,6 +54,7 @@ + diff --git a/SukiUI.Demo/Styles/MaterialIconStyles.axaml b/SukiUI.Demo/Styles/MaterialIconStyles.axaml new file mode 100644 index 000000000..455426ac7 --- /dev/null +++ b/SukiUI.Demo/Styles/MaterialIconStyles.axaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/SukiUI.Demo/SukiUIDemoView.axaml b/SukiUI.Demo/SukiUIDemoView.axaml index 410da0273..708903725 100644 --- a/SukiUI.Demo/SukiUIDemoView.axaml +++ b/SukiUI.Demo/SukiUIDemoView.axaml @@ -61,7 +61,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -94,7 +94,7 @@ - + + + + + + diff --git a/SukiUI.Demo/SukiUIDemoViewModel.cs b/SukiUI.Demo/SukiUIDemoViewModel.cs index bd57beb6b..8ed502522 100644 --- a/SukiUI.Demo/SukiUIDemoViewModel.cs +++ b/SukiUI.Demo/SukiUIDemoViewModel.cs @@ -139,7 +139,10 @@ private void ToggleTitleBar() .WithContent($"Window title bar has been {(TitleBarVisible ? "shown" : "hidden")}.") .Queue(); } - + + [RelayCommand] + private void ToggleRightToLeft() => _theme.IsRightToLeft = !_theme.IsRightToLeft; + [RelayCommand] private static void OpenUrl(string url) => UrlUtilities.OpenUrl(url); diff --git a/SukiUI/Controls/CodeView.axaml.cs b/SukiUI/Controls/CodeView.axaml.cs index d93869163..b8f29f3e4 100644 --- a/SukiUI/Controls/CodeView.axaml.cs +++ b/SukiUI/Controls/CodeView.axaml.cs @@ -55,6 +55,7 @@ public CodeView() new PathIcon() { Data = Icons.ChevronRight, + Classes = { "Flippable" }, Foreground = new Avalonia.Media.SolidColorBrush( (Avalonia.Media.Color)Application.Current.FindRequiredResource("SukiText")), diff --git a/SukiUI/Controls/Stepper.axaml.cs b/SukiUI/Controls/Stepper.axaml.cs index 8b6471156..e6bd6941c 100644 --- a/SukiUI/Controls/Stepper.axaml.cs +++ b/SukiUI/Controls/Stepper.axaml.cs @@ -134,7 +134,7 @@ private void AddStep(object step, int index, Grid grid, int stepCount) }; var icon = new PathIcon - { Height = 10, Width = 10, Data = Icons.ChevronRight, Margin = new Thickness(0, 0, 20, 0) }; + { Height = 10, Width = 10, Data = Icons.ChevronRight, Margin = new Thickness(0, 0, 20, 0), Classes = { "Flippable" } }; if (index == stepCount - 1) { icon.IsVisible = false; diff --git a/SukiUI/Controls/SukiSideMenu.axaml b/SukiUI/Controls/SukiSideMenu.axaml index 7eb9bbd09..b8d033cd7 100644 --- a/SukiUI/Controls/SukiSideMenu.axaml +++ b/SukiUI/Controls/SukiSideMenu.axaml @@ -31,6 +31,7 @@ IsVisible="{TemplateBinding SidebarToggleEnabled}"> + @@ -71,14 +71,13 @@ - - + + + + + + + - - - - - - - + + > 16)); - var buttonLeftTop = maximize.PointToScreen(new Point(0, 0)); + var desiredSize = maximize.DesiredSize; + var buttonLeftTop = maximize.PointToScreen(FlowDirection == FlowDirection.LeftToRight + ? new Point(desiredSize.Width, 0) + : new Point(0, 0)); var x = (buttonLeftTop.X - point.X) / RenderScaling; var y = (point.Y - buttonLeftTop.Y) / RenderScaling; if (new Rect(0, 0, - maximize.DesiredSize.Width, - maximize.DesiredSize.Height) + desiredSize.Width, + desiredSize.Height) .Contains(new Point(x, y))) { setter?.SetValue(maximize, true); diff --git a/SukiUI/Theme/Calendar/CalendarItem.axaml b/SukiUI/Theme/Calendar/CalendarItem.axaml index dda6bbe2a..071461029 100644 --- a/SukiUI/Theme/Calendar/CalendarItem.axaml +++ b/SukiUI/Theme/Calendar/CalendarItem.axaml @@ -36,13 +36,13 @@ diff --git a/SukiUI/Theme/CheckBoxStyles.axaml b/SukiUI/Theme/CheckBoxStyles.axaml index e378a1166..a234003de 100644 --- a/SukiUI/Theme/CheckBoxStyles.axaml +++ b/SukiUI/Theme/CheckBoxStyles.axaml @@ -41,6 +41,7 @@ Margin="1,1,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" + FlowDirection="LeftToRight" Data="M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z" Fill="White" Stretch="Uniform" > diff --git a/SukiUI/Theme/Index.axaml b/SukiUI/Theme/Index.axaml index 64b0f4d25..94942b736 100644 --- a/SukiUI/Theme/Index.axaml +++ b/SukiUI/Theme/Index.axaml @@ -31,6 +31,8 @@ + + diff --git a/SukiUI/Theme/Index.axaml.cs b/SukiUI/Theme/Index.axaml.cs index f727cc0c4..f64eb0470 100644 --- a/SukiUI/Theme/Index.axaml.cs +++ b/SukiUI/Theme/Index.axaml.cs @@ -19,6 +19,10 @@ public partial class SukiTheme : Styles AvaloniaProperty.Register(nameof(Color), defaultBindingMode: BindingMode.OneTime, defaultValue: SukiColor.Blue); + public static readonly StyledProperty IsRightToLeftProperty = + AvaloniaProperty.Register(nameof(IsRightToLeft), defaultBindingMode: BindingMode.OneTime, + defaultValue: false); + /// /// Used to assign the ColorTheme at launch, /// @@ -32,6 +36,12 @@ public SukiColor ThemeColor } } + public bool IsRightToLeft + { + get => GetValue(IsRightToLeftProperty); + set => SetValue(IsRightToLeftProperty, value); + } + /// /// Called whenever the application's is changed. /// Useful where controls cannot use "DynamicResource" @@ -74,6 +84,18 @@ public SukiTheme() _app.ActualThemeVariantChanged += (_, e) => OnBaseThemeChanged?.Invoke(_app.ActualThemeVariant); foreach (var theme in DefaultColorThemes) AddColorTheme(theme.Value); + + UpdateFlowDirectionResources(IsRightToLeft); + } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + if (change.Property == IsRightToLeftProperty) + { + UpdateFlowDirectionResources(change.GetNewValue()); + } + + base.OnPropertyChanged(change); } /// @@ -152,6 +174,15 @@ public void SwitchBaseTheme() Application.Current.RequestedThemeVariant = newBase; } + private void UpdateFlowDirectionResources(bool rightToLeft) + { + var primary = rightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; + var opposite = rightToLeft ? FlowDirection.LeftToRight : FlowDirection.RightToLeft; + + Resources["FlowDirectionPrimary"] = primary; + Resources["FlowDirectionOpposite"] = opposite; + } + /// /// Initializes the color theme resources whenever the property is changed. /// In an ideal world people wouldn't use the property diff --git a/SukiUI/Theme/ManagedFileChooserConverters.cs b/SukiUI/Theme/ManagedFileChooserConverters.cs index 765405f77..e03e9abc0 100644 --- a/SukiUI/Theme/ManagedFileChooserConverters.cs +++ b/SukiUI/Theme/ManagedFileChooserConverters.cs @@ -49,7 +49,8 @@ public class TextToPathConverter : IValueConverter var p = new PathIcon { Height = 6, Margin = new Thickness(12, 4, 12, 2), Width = 5, Data = Icons.ChevronRight, - IsVisible = i != pathes.Length - 1, VerticalAlignment = VerticalAlignment.Center + IsVisible = i != pathes.Length - 1, VerticalAlignment = VerticalAlignment.Center, + Classes = { "Flippable" } }; p[!TemplatedControl.ForegroundProperty] = new DynamicResourceExtension("SukiLowText"); diff --git a/SukiUI/Theme/MenuItem.axaml b/SukiUI/Theme/MenuItem.axaml index f8fb5d399..7bdbff59c 100644 --- a/SukiUI/Theme/MenuItem.axaml +++ b/SukiUI/Theme/MenuItem.axaml @@ -34,6 +34,7 @@ DockPanel.Dock="Left" Fill="{DynamicResource SukiLightBorderBrush}" /> + + + + + + diff --git a/SukiUI/Theme/ProgressBarStyles.xaml b/SukiUI/Theme/ProgressBarStyles.xaml index 99ce9a5f3..257d8b5e1 100644 --- a/SukiUI/Theme/ProgressBarStyles.xaml +++ b/SukiUI/Theme/ProgressBarStyles.xaml @@ -24,7 +24,7 @@ + +