From 43db0c0293acf2c1849a725c9868881197db7e1d Mon Sep 17 00:00:00 2001 From: rabbitism Date: Fri, 10 Feb 2023 00:34:48 +0800 Subject: [PATCH] feat: add header for demo. --- demo/Semi.Avalonia.Demo/Pages/Overview.axaml | 12 - .../{Views => Themes}/TabMenu.axaml | 33 +-- .../Themes/ToggleButton.axaml | 33 +++ demo/Semi.Avalonia.Demo/Views/MainView.axaml | 272 ++++++++++-------- .../Views/MainView.axaml.cs | 13 + 5 files changed, 211 insertions(+), 152 deletions(-) rename demo/Semi.Avalonia.Demo/{Views => Themes}/TabMenu.axaml (57%) create mode 100644 demo/Semi.Avalonia.Demo/Themes/ToggleButton.axaml diff --git a/demo/Semi.Avalonia.Demo/Pages/Overview.axaml b/demo/Semi.Avalonia.Demo/Pages/Overview.axaml index 2e100a2..a2a8569 100644 --- a/demo/Semi.Avalonia.Demo/Pages/Overview.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/Overview.axaml @@ -9,18 +9,6 @@ mc:Ignorable="d"> - - - - diff --git a/demo/Semi.Avalonia.Demo/Views/TabMenu.axaml b/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml similarity index 57% rename from demo/Semi.Avalonia.Demo/Views/TabMenu.axaml rename to demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml index 5c7a38f..0c9ec39 100644 --- a/demo/Semi.Avalonia.Demo/Views/TabMenu.axaml +++ b/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml @@ -12,27 +12,18 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml b/demo/Semi.Avalonia.Demo/Views/MainView.axaml index 608e5e0..0074644 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml @@ -11,126 +11,160 @@ - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs index 5464c27..b48ee71 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs @@ -1,4 +1,7 @@ +using Avalonia; using Avalonia.Controls; +using Avalonia.Interactivity; +using Avalonia.Styling; namespace Semi.Avalonia.Demo.Views; @@ -8,4 +11,14 @@ public partial class MainView : UserControl { InitializeComponent(); } + + private void ToggleButton_OnIsCheckedChanged(object sender, RoutedEventArgs e) + { + var app = Application.Current; + if (app is not null) + { + var theme = app.ActualThemeVariant; + app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Default : ThemeVariant.Dark; + } + } } \ No newline at end of file