From 4ba362cd670778a24106fdde7d330c817cb7a560 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 14 Jan 2023 00:31:33 +0800 Subject: [PATCH] feat: add toggle button, update all buttons to shrink upon click. --- src/Semi.Avalonia.Demo/MainWindow.axaml | 8 +- .../Pages/ToggleButtonDemo.axaml | 29 +++ .../Pages/ToggleButtonDemo.axaml.cs | 18 ++ src/Semi.Avalonia/Controls/Button.axaml | 14 +- src/Semi.Avalonia/Controls/Controls.axaml | 1 + src/Semi.Avalonia/Controls/RepeatButton.axaml | 17 +- src/Semi.Avalonia/Controls/ToggleButton.axaml | 185 ++++++++++++++++++ src/Semi.Avalonia/Themes/Light/Light.axaml | 1 + .../Themes/Light/ToggleButton.axaml | 72 +++++++ 9 files changed, 336 insertions(+), 9 deletions(-) create mode 100644 src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml create mode 100644 src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml.cs create mode 100644 src/Semi.Avalonia/Controls/ToggleButton.axaml create mode 100644 src/Semi.Avalonia/Themes/Light/ToggleButton.axaml diff --git a/src/Semi.Avalonia.Demo/MainWindow.axaml b/src/Semi.Avalonia.Demo/MainWindow.axaml index 034eba6..6527bb7 100644 --- a/src/Semi.Avalonia.Demo/MainWindow.axaml +++ b/src/Semi.Avalonia.Demo/MainWindow.axaml @@ -25,7 +25,6 @@ - @@ -62,11 +61,14 @@ - - + + + + + diff --git a/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml b/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml new file mode 100644 index 0000000..f56bcbd --- /dev/null +++ b/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml @@ -0,0 +1,29 @@ + + + + + Primary + Secondary + Tertiary + Warning + Error + + + + + Primary + Secondary + Tertiary + Warning + Error + + + diff --git a/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml.cs b/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml.cs new file mode 100644 index 0000000..3e1424e --- /dev/null +++ b/src/Semi.Avalonia.Demo/Pages/ToggleButtonDemo.axaml.cs @@ -0,0 +1,18 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Semi.Avalonia.Demo.Pages; + +public partial class ToggleButtonDemo : UserControl +{ + public ToggleButtonDemo() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/Button.axaml b/src/Semi.Avalonia/Controls/Button.axaml index a256ed6..a3cf5b5 100644 --- a/src/Semi.Avalonia/Controls/Button.axaml +++ b/src/Semi.Avalonia/Controls/Button.axaml @@ -37,6 +37,10 @@ + + @@ -77,7 +81,10 @@ - + @@ -155,7 +162,10 @@ - + + @@ -73,7 +76,10 @@ - + @@ -151,7 +157,10 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Semi.Avalonia/Themes/Light/Light.axaml b/src/Semi.Avalonia/Themes/Light/Light.axaml index 65064e5..be1249f 100644 --- a/src/Semi.Avalonia/Themes/Light/Light.axaml +++ b/src/Semi.Avalonia/Themes/Light/Light.axaml @@ -17,6 +17,7 @@ + diff --git a/src/Semi.Avalonia/Themes/Light/ToggleButton.axaml b/src/Semi.Avalonia/Themes/Light/ToggleButton.axaml new file mode 100644 index 0000000..e2bdd00 --- /dev/null +++ b/src/Semi.Avalonia/Themes/Light/ToggleButton.axaml @@ -0,0 +1,72 @@ + + + 14 + 600 + + 12 6 + 16 10 + 6 2 + 1 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +