diff --git a/.github/workflows/pack-tree.yml b/.github/workflows/pack-tree.yml new file mode 100644 index 0000000..1d2a6cd --- /dev/null +++ b/.github/workflows/pack-tree.yml @@ -0,0 +1,26 @@ +name: Pack TreeDataGrid Nuget + +on: + push: + branches: [ "action/pack-tree" ] + pull_request: + branches: [ "action/pack-tree" ] + +jobs: + nuget: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + + - name: Nuget Semi.Avalonia.TreeDataGrid + run: dotnet pack ./src/Semi.Avalonia.TreeDataGrid -o ./nugets + + - name: Publish NuGet package + run: dotnet nuget push "./nugets/*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v4.3.1 + with: + name: nugets + path: ./nugets diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index 7882e33..e27e35a 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -22,8 +22,8 @@ jobs: - name: Nuget Semi.Avalonia.DataGrid run: dotnet pack ./src/Semi.Avalonia.DataGrid -o ./nugets - - name: Nuget Semi.Avalonia.TreeDataGrid - run: dotnet pack ./src/Semi.Avalonia.TreeDataGrid -o ./nugets + - name: Publish NuGet package + run: dotnet nuget push "./nugets/*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - name: Upload a Build Artifact uses: actions/upload-artifact@v4.3.1 diff --git a/Semi.Avalonia.sln b/Semi.Avalonia.sln index 827c045..b7564d0 100644 --- a/Semi.Avalonia.sln +++ b/Semi.Avalonia.sln @@ -12,6 +12,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution src\Package.props = src\Package.props EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Action", "GitHub Action", "{318534A1-1CC3-40FB-B4AE-736F94465232}" + ProjectSection(SolutionItems) = preProject + .github\workflows\deploy.yml = .github\workflows\deploy.yml + .github\workflows\pack.yml = .github\workflows\pack.yml + .github\workflows\pack-tree.yml = .github\workflows\pack-tree.yml + .github\workflows\publish.yml = .github\workflows\publish.yml + EndProjectSection +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo", "Demo", "{43091528-9509-43CB-A003-9C5C11E96DD6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semi.Avalonia.Demo.Desktop", "demo\Semi.Avalonia.Demo.Desktop\Semi.Avalonia.Demo.Desktop.csproj", "{2ADCA724-2B6D-46EC-87F7-604D7918B89A}" diff --git a/demo/Directory.Build.props b/demo/Directory.Build.props index e25d59c..2d2f46e 100644 --- a/demo/Directory.Build.props +++ b/demo/Directory.Build.props @@ -2,5 +2,6 @@ enable 11.1.3 + 8.3.2 diff --git a/demo/Semi.Avalonia.Demo.Desktop/Program.cs b/demo/Semi.Avalonia.Demo.Desktop/Program.cs index e011c45..f6fb44d 100644 --- a/demo/Semi.Avalonia.Demo.Desktop/Program.cs +++ b/demo/Semi.Avalonia.Demo.Desktop/Program.cs @@ -16,13 +16,13 @@ class Program public static void Main(string[] args) => BuildAvaloniaApp() .With(new FontManagerOptions { - FontFallbacks = new[] - { + FontFallbacks = + [ new FontFallback { FontFamily = new FontFamily("Microsoft YaHei") } - } + ] }) .StartWithClassicDesktopLifetime(args); diff --git a/demo/Semi.Avalonia.Demo.Web/Assets/Fonts/SourceHanSansCN-Bold.otf b/demo/Semi.Avalonia.Demo.Web/Assets/Fonts/SourceHanSansCN-Bold.otf new file mode 100644 index 0000000..8e1e869 Binary files /dev/null and b/demo/Semi.Avalonia.Demo.Web/Assets/Fonts/SourceHanSansCN-Bold.otf differ diff --git a/demo/Semi.Avalonia.Demo.Web/Assets/SourceHanSansCN-Regular.otf b/demo/Semi.Avalonia.Demo.Web/Assets/Fonts/SourceHanSansCN-Regular.otf similarity index 100% rename from demo/Semi.Avalonia.Demo.Web/Assets/SourceHanSansCN-Regular.otf rename to demo/Semi.Avalonia.Demo.Web/Assets/Fonts/SourceHanSansCN-Regular.otf diff --git a/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs b/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs index 2d5a50f..29386d5 100644 --- a/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs +++ b/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs @@ -11,6 +11,6 @@ public static class AvaloniaAppBuilderExtensions builder.With(new FontManagerOptions { DefaultFamilyName = DefaultFontFamily, - FontFallbacks = new[] { new FontFallback { FontFamily = new FontFamily(DefaultFontFamily) } } + FontFallbacks = [new FontFallback { FontFamily = new FontFamily(DefaultFontFamily) }] }); } \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Controls/ColorDetailControl.axaml b/demo/Semi.Avalonia.Demo/Controls/ColorDetailControl.axaml index 4dc7d42..abcbd39 100644 --- a/demo/Semi.Avalonia.Demo/Controls/ColorDetailControl.axaml +++ b/demo/Semi.Avalonia.Demo/Controls/ColorDetailControl.axaml @@ -7,6 +7,7 @@ x:DataType="viewModels:ColorItemViewModel"> M5 7C3.89543 7 3 7.89543 3 9V19C3 20.1046 3.89543 21 5 21H15C16.1046 21 17 20.1046 17 19V9C17 7.89543 16.1046 7 15 7H5Z,M7 4C7 2.89543 7.89543 2 9 2H20C21.1046 2 22 2.89543 22 4V15C22 16.1046 21.1046 17 20 17H19V8C19 6 18 5 16 5H7V4Z + diff --git a/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.axaml b/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.axaml index b3d46be..2c74653 100644 --- a/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.axaml +++ b/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.axaml @@ -6,15 +6,15 @@ x:CompileBindings="True" x:DataType="viewModels:FunctionalColorGroupViewModel"> - - + + - + Theme="{DynamicResource TitleSelectableTextBlock}" /> @@ -129,4 +129,4 @@ - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.cs b/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.cs index 7a17dee..57b3587 100644 --- a/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.cs +++ b/demo/Semi.Avalonia.Demo/Controls/FunctionalColorGroupControl.cs @@ -4,33 +4,38 @@ using Avalonia.Controls.Primitives; namespace Semi.Avalonia.Demo.Controls; -public class FunctionalColorGroupControl: TemplatedControl +public class FunctionalColorGroupControl : TemplatedControl { - public static readonly StyledProperty TitleProperty = AvaloniaProperty.Register( - nameof(Title)); + public static readonly StyledProperty TitleProperty = + AvaloniaProperty.Register(nameof(Title)); + public string? Title { get => GetValue(TitleProperty); set => SetValue(TitleProperty, value); } - - public static readonly DirectProperty LightColorsProperty = AvaloniaProperty.RegisterDirect( - nameof(LightColors), o => o.LightColors, (o, v) => o.LightColors = v); + + public static readonly DirectProperty LightColorsProperty = + AvaloniaProperty.RegisterDirect(nameof(LightColors), + o => o.LightColors, (o, v) => o.LightColors = v); + private IEnumerable? _lightColors; + public IEnumerable? LightColors { get => _lightColors; set => SetAndRaise(LightColorsProperty, ref _lightColors, value); } - - public static readonly DirectProperty DarkColorsProperty = AvaloniaProperty.RegisterDirect( - nameof(DarkColors), o => o.DarkColors, (o, v) => o.DarkColors = v); + + public static readonly DirectProperty DarkColorsProperty = + AvaloniaProperty.RegisterDirect(nameof(DarkColors), + o => o.DarkColors, (o, v) => o.DarkColors = v); + private IEnumerable? _darkColors; + public IEnumerable? DarkColors { get => _darkColors; set => SetAndRaise(DarkColorsProperty, ref _darkColors, value); } - - } \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.axaml b/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.axaml new file mode 100644 index 0000000..d06aea4 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.axaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.cs b/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.cs new file mode 100644 index 0000000..bb59ab1 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Controls/ShadowGroupControl.cs @@ -0,0 +1,41 @@ +using System.Collections; +using Avalonia; +using Avalonia.Controls.Primitives; + +namespace Semi.Avalonia.Demo.Controls; + +public class ShadowGroupControl : TemplatedControl +{ + public static readonly StyledProperty TitleProperty = + AvaloniaProperty.Register(nameof(Title)); + + public string? Title + { + get => GetValue(TitleProperty); + set => SetValue(TitleProperty, value); + } + + private IEnumerable? _lightShadows; + + public static readonly DirectProperty LightShadowsProperty = + AvaloniaProperty.RegisterDirect(nameof(LightShadows), + o => o.LightShadows, (o, v) => o.LightShadows = v); + + public IEnumerable? LightShadows + { + get => _lightShadows; + set => SetAndRaise(LightShadowsProperty, ref _lightShadows, value); + } + + private IEnumerable? _darkShadows; + + public static readonly DirectProperty DarkShadowsProperty = + AvaloniaProperty.RegisterDirect(nameof(DarkShadows), + o => o.DarkShadows, (o, v) => o.DarkShadows = v); + + public IEnumerable? DarkShadows + { + get => _darkShadows; + set => SetAndRaise(DarkShadowsProperty, ref _darkShadows, value); + } +} \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/CarouselDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/CarouselDemo.axaml index 6b419c0..d295307 100644 --- a/demo/Semi.Avalonia.Demo/Pages/CarouselDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/CarouselDemo.axaml @@ -8,20 +8,26 @@ d:DesignWidth="800" mc:Ignorable="d"> - - - - - - + @@ -35,39 +41,39 @@ - - - - - - + + + + + + + + - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/ColorPickerDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/ColorPickerDemo.axaml index cb5dfaf..3eb407d 100644 --- a/demo/Semi.Avalonia.Demo/Pages/ColorPickerDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/ColorPickerDemo.axaml @@ -19,42 +19,74 @@ - + + Theme="{StaticResource SimpleColorView}" /> - + - + - + + + + + + + + + + + + + + - - + + diff --git a/demo/Semi.Avalonia.Demo/Pages/DataGridDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/DataGridDemo.axaml index d2c8add..475c6af 100644 --- a/demo/Semi.Avalonia.Demo/Pages/DataGridDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/DataGridDemo.axaml @@ -101,7 +101,7 @@ - + diff --git a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml similarity index 80% rename from demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml rename to demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml index 0928a67..ef965c6 100644 --- a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml @@ -1,5 +1,5 @@ diff --git a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs similarity index 71% rename from demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs rename to demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs index c317cf5..b3f1927 100644 --- a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs @@ -1,12 +1,11 @@ -using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; namespace Semi.Avalonia.Demo.Pages; -public partial class GridSplitter : UserControl +public partial class GridSplitterDemo : UserControl { - public GridSplitter() + public GridSplitterDemo() { InitializeComponent(); } diff --git a/demo/Semi.Avalonia.Demo/Pages/HeaderedContentControlDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/HeaderedContentControlDemo.axaml index af62a80..b778b13 100644 --- a/demo/Semi.Avalonia.Demo/Pages/HeaderedContentControlDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/HeaderedContentControlDemo.axaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="1450" x:Class="Semi.Avalonia.Demo.Pages.HeaderedContentControlDemo"> @@ -27,12 +27,18 @@ GroupBox Theme - Semi Design 是由互娱社区前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。 + HorizontalAlignment="Left" + MaxWidth="360"> + + + + + + + + + diff --git a/demo/Semi.Avalonia.Demo/Pages/HyperlinkButtonDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/HyperlinkButtonDemo.axaml index 897a75b..10b774b 100644 --- a/demo/Semi.Avalonia.Demo/Pages/HyperlinkButtonDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/HyperlinkButtonDemo.axaml @@ -8,36 +8,22 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + + - - - - - - - - - - - - - + + - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/LabelDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/LabelDemo.axaml index 5b17250..250c794 100644 --- a/demo/Semi.Avalonia.Demo/Pages/LabelDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/LabelDemo.axaml @@ -4,7 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - d:DesignHeight="450" + d:DesignHeight="800" d:DesignWidth="800" mc:Ignorable="d"> @@ -13,15 +13,13 @@ + - - - - Classes - - - Secondary - Tertiary - Quaternary - Success - Warning - Danger - Mark - Code - + RowDefinitions="*,*,*,*,*,*,*,*,*,*,*"> + Classes + - + Secondary + Tertiary + Quaternary + Success + Warning + Danger + Mark + Code + - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/PaletteDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/PaletteDemo.axaml.cs index 4ef2ecf..70fb84b 100644 --- a/demo/Semi.Avalonia.Demo/Pages/PaletteDemo.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/PaletteDemo.axaml.cs @@ -13,17 +13,16 @@ public partial class PaletteDemo : UserControl public PaletteDemo() { InitializeComponent(); - + this.DataContext = new PaletteDemoViewModel(); } protected override async void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - PaletteDemoViewModel? vm = new PaletteDemoViewModel(); + PaletteDemoViewModel? vm = this.DataContext as PaletteDemoViewModel; await Dispatcher.UIThread.InvokeAsync(() => { - vm.InitializeResources(); + vm?.InitializeResources(); }); - DataContext = vm; } } \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/PathIconDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/PathIconDemo.axaml index 6e0214f..e5fa352 100644 --- a/demo/Semi.Avalonia.Demo/Pages/PathIconDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/PathIconDemo.axaml @@ -7,16 +7,30 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> - - - - + + + + + + + + + + + + + + + + Foreground="{DynamicResource SemiBlue6}" + BorderBrush="{DynamicResource SemiRed6}" + Data="M12 3L2 12H5V20H19V12H22L12 3M13 18H11V16H13V18M13 14H11V8H13V14Z" /> - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/SelectableTextBlock.axaml b/demo/Semi.Avalonia.Demo/Pages/SelectableTextBlock.axaml index abeb7f3..c353ef3 100644 --- a/demo/Semi.Avalonia.Demo/Pages/SelectableTextBlock.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/SelectableTextBlock.axaml @@ -4,13 +4,13 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - d:DesignHeight="450" + d:DesignHeight="600" d:DesignWidth="800" mc:Ignorable="d"> - @@ -25,70 +25,76 @@ - Classes - - - Secondary - Tertiary - Quaternary - Success - Warning - Danger - Mark - Underline - Delete + RowDefinitions="*,*,*,*,*,*,*,*,*,*,*"> + + + + Classes + - + Secondary + Tertiary + Quaternary + Success + Warning + Danger + Mark + Underline + Delete - Text + Text Secondary Tertiary Quaternary Success Warning Danger Default Mark Underline Delete @@ -104,53 +110,52 @@ Theme="{DynamicResource GroupBox}"> - Classes - H1 - H2 - H3 - H4 - H5 - H6 + RowDefinitions="*,*,*,*,*,*,*"> + Classes + H1 + H2 + H3 + H4 + H5 + H6 Header 1 Header 2 Header 3 Header 4 Header 5 diff --git a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml index 7de95ef..7598b32 100644 --- a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml @@ -114,20 +114,9 @@ ItemsSource="{Binding Songs}" /> - - - - - - diff --git a/demo/Semi.Avalonia.Demo/Pages/TextBlockDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/TextBlockDemo.axaml index 5702698..04f0fe3 100644 --- a/demo/Semi.Avalonia.Demo/Pages/TextBlockDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/TextBlockDemo.axaml @@ -10,7 +10,7 @@ - @@ -25,70 +25,70 @@ - Classes - - - Secondary - Tertiary - Quaternary - Success - Warning - Danger - Mark - Underline - Delete + RowDefinitions="*,*,*,*,*,*,*,*,*,*,*"> + Classes + - + Secondary + Tertiary + Quaternary + Success + Warning + Danger + Mark + Underline + Delete - Text + Text Secondary Tertiary Quaternary Success Warning Danger Default Mark Underline Delete @@ -105,58 +105,57 @@ - Classes - H1 - H2 - H3 - H4 - H5 - H6 + RowDefinitions="*,*,*,*,*,*,*"> + Classes + H1 + H2 + H3 + H4 + H5 + H6 Header 1 Header 2 Header 3 Header 4 Header 5 Header 6 - diff --git a/demo/Semi.Avalonia.Demo/Pages/ToggleSwitchDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/ToggleSwitchDemo.axaml index 1a23866..ed66fc1 100644 --- a/demo/Semi.Avalonia.Demo/Pages/ToggleSwitchDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/ToggleSwitchDemo.axaml @@ -8,22 +8,23 @@ d:DesignWidth="800" mc:Ignorable="d"> - - - + + + + + + + + + + + + + + + + + @@ -44,8 +45,8 @@ - - + + @@ -60,21 +61,35 @@ - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj index cb9a679..9e5c54a 100644 --- a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj +++ b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj @@ -14,7 +14,7 @@ - + diff --git a/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml b/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml index 12fc2df..43e3b8e 100644 --- a/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml +++ b/demo/Semi.Avalonia.Demo/Themes/TabMenu.axaml @@ -1,6 +1,6 @@ - + - + @@ -19,7 +22,8 @@ - + + - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Themes/ToggleButton.axaml b/demo/Semi.Avalonia.Demo/Themes/ToggleButton.axaml deleted file mode 100644 index da8124c..0000000 --- a/demo/Semi.Avalonia.Demo/Themes/ToggleButton.axaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - diff --git a/demo/Semi.Avalonia.Demo/Themes/ToggleSwitch.axaml b/demo/Semi.Avalonia.Demo/Themes/ToggleSwitch.axaml new file mode 100644 index 0000000..f3b0485 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Themes/ToggleSwitch.axaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs b/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs index 1646be8..cf23454 100644 --- a/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs +++ b/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs @@ -2,25 +2,25 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Avalonia.Controls; -using Avalonia.Markup.Xaml; using Avalonia.Media; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Messaging; namespace Semi.Avalonia.Demo.ViewModels; -public class PaletteDemoViewModel: ObservableObject +public class PaletteDemoViewModel : ObservableObject { private readonly string[] _predefinedColorNames = - { + [ "Red", "Pink", "Purple", "Violet", "Indigo", "Blue", "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", "Yellow", "Amber", "Orange", "Grey" - }; + ]; + private readonly IResourceDictionary? _lightResourceDictionary; private readonly IResourceDictionary? _darkResourceDictionary; - + private ColorItemViewModel _selectedColor = null!; public ColorItemViewModel SelectedColor @@ -28,26 +28,30 @@ public class PaletteDemoViewModel: ObservableObject get => _selectedColor; set => SetProperty(ref _selectedColor, value); } - - + + private ObservableCollection? _lightLists; + public ObservableCollection? LightLists { get => _lightLists; set => SetProperty(ref _lightLists, value); } + private ObservableCollection? _darkLists; + public ObservableCollection? DarkLists { get => _darkLists; set => SetProperty(ref _darkLists, value); } - public ObservableCollection FunctionalColors { get; set; } = new(); + public ObservableCollection FunctionalColors { get; set; } = []; + public ObservableCollection Shadows { get; set; } = []; public PaletteDemoViewModel() { - _lightResourceDictionary = new Light.Palette(); + _lightResourceDictionary = new Light.Palette(); _darkResourceDictionary = new Dark.Palette(); WeakReferenceMessenger.Default.Register(this, OnClickColorItem); } @@ -56,18 +60,20 @@ public class PaletteDemoViewModel: ObservableObject { InitializePalette(); InitializeFunctionalColors(); + InitializeShadows(); } private void InitializePalette() { - LightLists = new ObservableCollection(); + LightLists = []; foreach (var color in _predefinedColorNames) { ColorListViewModel s = new ColorListViewModel(); s.Initialize(_lightResourceDictionary, color, true); LightLists.Add(s); } - DarkLists = new ObservableCollection(); + + DarkLists = []; foreach (var color in _predefinedColorNames) { ColorListViewModel s = new ColorListViewModel(); @@ -92,13 +98,19 @@ public class PaletteDemoViewModel: ObservableObject FunctionalColors.Add(new FunctionalColorGroupViewModel("Border", _lightResourceDictionary, _darkResourceDictionary, ColorTokens.BorderTokens)); FunctionalColors.Add(new FunctionalColorGroupViewModel("Disabled", _lightResourceDictionary, _darkResourceDictionary, ColorTokens.DisabledTokens)); } + + private void InitializeShadows() + { + Shadows.Add(new ShadowGroupViewModel("Shadow", _lightResourceDictionary, _darkResourceDictionary, ColorTokens.ShadowTokens)); + } + private void OnClickColorItem(PaletteDemoViewModel vm, ColorItemViewModel item) { SelectedColor = item; } } -public class ColorListViewModel: ObservableObject +public class ColorListViewModel : ObservableObject { private ObservableCollection? _colors; @@ -115,17 +127,18 @@ public class ColorListViewModel: ObservableObject get => _seriesName; set => SetProperty(ref _seriesName, value); } - + internal void Initialize(IResourceDictionary? resourceDictionary, string color, bool light) { if (resourceDictionary is null) { return; } + SeriesName = color; - Color = new ObservableCollection(); - - for (int i = 0; i < 10; i++) + Color = []; + + for (var i = 0; i < 10; i++) { var key = "Semi" + color + i; if (resourceDictionary.TryGetValue(key, out var value)) @@ -136,7 +149,7 @@ public class ColorListViewModel: ObservableObject var item = new ColorItemViewModel(name, brush, key, light, i); item.ColorResourceKey = item.ResourceKey + "Color"; Color.Add(item); - } + } } } } @@ -144,15 +157,16 @@ public class ColorListViewModel: ObservableObject public class ColorItemViewModel : ObservableObject { - private IBrush _brush = null!; + public IBrush Brush { get => _brush; set => SetProperty(ref _brush, value); } - + private IBrush _textBrush = null!; + public IBrush TextBrush { get => _textBrush; @@ -160,6 +174,7 @@ public class ColorItemViewModel : ObservableObject } private string _colorDisplayName = null!; + public string ColorDisplayName { get => _colorDisplayName; @@ -189,8 +204,9 @@ public class ColorItemViewModel : ObservableObject get => _hex; set => SetProperty(ref _hex, value); } - - public ColorItemViewModel(string colorDisplayName, ISolidColorBrush brush, string resourceKey, bool light, int index) + + public ColorItemViewModel(string colorDisplayName, ISolidColorBrush brush, string resourceKey, bool light, + int index) { ColorDisplayName = colorDisplayName; Brush = brush; @@ -210,22 +226,22 @@ public class ColorItemViewModel : ObservableObject public class FunctionalColorGroupViewModel : ObservableObject { private string _title = null!; + public string Title { get => _title; set => SetProperty(ref _title, value); } - public ObservableCollection LightColors { get; set; } = new(); - public ObservableCollection DarkColors { get; set; } = new(); + public ObservableCollection LightColors { get; set; } = []; + public ObservableCollection DarkColors { get; set; } = []; - public FunctionalColorGroupViewModel(string title, IResourceDictionary? lightDictionary, IResourceDictionary? darkDictionary, IReadOnlyList> tokens) + public FunctionalColorGroupViewModel(string title, IResourceDictionary? lightDictionary, + IResourceDictionary? darkDictionary, IReadOnlyList> tokens) { Title = title; - foreach (var token in tokens) + foreach (var (key, name) in tokens) { - string key = token.Item1; - string name = token.Item2; if (lightDictionary?.TryGetValue(key, out var lightValue) ?? false) { if (lightValue is ISolidColorBrush lightBrush) @@ -245,125 +261,203 @@ public class FunctionalColorGroupViewModel : ObservableObject } } +public class ShadowItemViewModel : ObservableObject +{ + private string _shadowDisplayName = null!; + + public string ShadowDisplayName + { + get => _shadowDisplayName; + set => SetProperty(ref _shadowDisplayName, value); + } + + private string _resourceKey = null!; + + public string ResourceKey + { + get => _resourceKey; + set => SetProperty(ref _resourceKey, value); + } + + private string _boxShadowValue = null!; + + public string BoxShadowValue + { + get => _boxShadowValue; + set => SetProperty(ref _boxShadowValue, value); + } + + public ShadowItemViewModel(string shadowDisplayName, BoxShadows boxShadows, string resourceKey) + { + ShadowDisplayName = shadowDisplayName; + ResourceKey = resourceKey; + BoxShadowValue = boxShadows.ToString(); + } +} + +public class ShadowGroupViewModel : ObservableObject +{ + private string _title = null!; + + public string Title + { + get => _title; + set => SetProperty(ref _title, value); + } + + public ObservableCollection LightShadows { get; set; } = []; + public ObservableCollection DarkShadows { get; set; } = []; + + + public ShadowGroupViewModel(string title, IResourceDictionary? lightDictionary, + IResourceDictionary? darkDictionary, IReadOnlyList> tokens) + { + Title = title; + foreach (var (key, name) in tokens) + { + if (lightDictionary?.TryGetValue(key, out var lightValue) ?? false) + { + if (lightValue is BoxShadows lightShadow) + { + LightShadows.Add(new ShadowItemViewModel(name, lightShadow, key)); + } + } + + if (darkDictionary?.TryGetValue(key, out var darkValue) ?? false) + { + if (darkValue is BoxShadows darkShadow) + { + DarkShadows.Add(new ShadowItemViewModel(name, darkShadow, key)); + } + } + } + } +} + public static class ColorTokens { public static IReadOnlyList> PrimaryTokens { get; } = new List> { - new ("SemiColorPrimary", "Primary"), - new ("SemiColorPrimaryPointerover", "Primary Pointerover"), - new ("SemiColorPrimaryActive", "Primary Active"), - new ("SemiColorPrimaryDisabled", "Primary Disabled"), - new ("SemiColorPrimaryLight", "Primary Light"), - new ("SemiColorPrimaryLightPointerover", "Primary Light Pointerover"), - new ("SemiColorPrimaryLightActive", "Primary Light Active"), + new("SemiColorPrimary", "Primary"), + new("SemiColorPrimaryPointerover", "Primary Pointerover"), + new("SemiColorPrimaryActive", "Primary Active"), + new("SemiColorPrimaryDisabled", "Primary Disabled"), + new("SemiColorPrimaryLight", "Primary Light"), + new("SemiColorPrimaryLightPointerover", "Primary Light Pointerover"), + new("SemiColorPrimaryLightActive", "Primary Light Active"), }; public static IReadOnlyList> SecondaryTokens { get; } = new List> { - new ("SemiColorSecondary", "Secondary"), - new ("SemiColorSecondaryPointerover", "Secondary Pointerover"), - new ("SemiColorSecondaryActive", "Secondary Active"), - new ("SemiColorSecondaryDisabled", "Secondary Disabled"), - new ("SemiColorSecondaryLight", "Secondary Light"), - new ("SemiColorSecondaryLightPointerover", "Secondary Light Pointerover"), - new ("SemiColorSecondaryLightActive", "Secondary Light Active"), + new("SemiColorSecondary", "Secondary"), + new("SemiColorSecondaryPointerover", "Secondary Pointerover"), + new("SemiColorSecondaryActive", "Secondary Active"), + new("SemiColorSecondaryDisabled", "Secondary Disabled"), + new("SemiColorSecondaryLight", "Secondary Light"), + new("SemiColorSecondaryLightPointerover", "Secondary Light Pointerover"), + new("SemiColorSecondaryLightActive", "Secondary Light Active"), }; - + public static IReadOnlyList> TertiaryTokens { get; } = new List> { - new ("SemiColorTertiary", "Tertiary"), - new ("SemiColorTertiaryPointerover", "Tertiary Pointerover"), - new ("SemiColorTertiaryActive", "Tertiary Active"), - new ("SemiColorTertiaryLight", "Tertiary Light"), - new ("SemiColorTertiaryLightPointerover", "Tertiary Light Pointerover"), - new ("SemiColorTertiaryLightActive", "Tertiary Light Active"), + new("SemiColorTertiary", "Tertiary"), + new("SemiColorTertiaryPointerover", "Tertiary Pointerover"), + new("SemiColorTertiaryActive", "Tertiary Active"), + new("SemiColorTertiaryLight", "Tertiary Light"), + new("SemiColorTertiaryLightPointerover", "Tertiary Light Pointerover"), + new("SemiColorTertiaryLightActive", "Tertiary Light Active"), }; - + public static IReadOnlyList> InformationTokens { get; } = new List> { - new ("SemiColorInformation", "Information"), - new ("SemiColorInformationPointerover", "Information Pointerover"), - new ("SemiColorInformationActive", "Information Active"), - new ("SemiColorInformationDisabled", "Information Disabled"), - new ("SemiColorInformationLight", "Information Light"), - new ("SemiColorInformationLightPointerover", "Information Light Pointerover"), - new ("SemiColorInformationLightActive", "Information Light Active"), + new("SemiColorInformation", "Information"), + new("SemiColorInformationPointerover", "Information Pointerover"), + new("SemiColorInformationActive", "Information Active"), + new("SemiColorInformationDisabled", "Information Disabled"), + new("SemiColorInformationLight", "Information Light"), + new("SemiColorInformationLightPointerover", "Information Light Pointerover"), + new("SemiColorInformationLightActive", "Information Light Active"), }; - + public static IReadOnlyList> SuccessTokens { get; } = new List> { - new ("SemiColorSuccess", "Success"), - new ("SemiColorSuccessPointerover", "Success Pointerover"), - new ("SemiColorSuccessActive", "Success Active"), - new ("SemiColorSuccessDisabled", "Success Disabled"), - new ("SemiColorSuccessLight", "Success Light"), - new ("SemiColorSuccessLightPointerover", "Success Light Pointerover"), - new ("SemiColorSuccessLightActive", "Success Light Active"), + new("SemiColorSuccess", "Success"), + new("SemiColorSuccessPointerover", "Success Pointerover"), + new("SemiColorSuccessActive", "Success Active"), + new("SemiColorSuccessDisabled", "Success Disabled"), + new("SemiColorSuccessLight", "Success Light"), + new("SemiColorSuccessLightPointerover", "Success Light Pointerover"), + new("SemiColorSuccessLightActive", "Success Light Active"), }; - + public static IReadOnlyList> WarningTokens { get; } = new List> { - new ("SemiColorWarning", "Warning"), - new ("SemiColorWarningPointerover", "Warning Pointerover"), - new ("SemiColorWarningActive", "Warning Active"), - new ("SemiColorWarningLight", "Warning Light"), - new ("SemiColorWarningLightPointerover", "Warning Light Pointerover"), - new ("SemiColorWarningLightActive", "Warning Light Active"), + new("SemiColorWarning", "Warning"), + new("SemiColorWarningPointerover", "Warning Pointerover"), + new("SemiColorWarningActive", "Warning Active"), + new("SemiColorWarningLight", "Warning Light"), + new("SemiColorWarningLightPointerover", "Warning Light Pointerover"), + new("SemiColorWarningLightActive", "Warning Light Active"), }; - + public static IReadOnlyList> DangerTokens { get; } = new List> { - new ("SemiColorDanger", "Danger"), - new ("SemiColorDangerPointerover", "Danger Pointerover"), - new ("SemiColorDangerActive", "Danger Active"), - new ("SemiColorDangerLight", "Danger Light"), - new ("SemiColorDangerLightPointerover", "Danger Light Pointerover"), - new ("SemiColorDangerLightActive", "Danger Light Active"), + new("SemiColorDanger", "Danger"), + new("SemiColorDangerPointerover", "Danger Pointerover"), + new("SemiColorDangerActive", "Danger Active"), + new("SemiColorDangerLight", "Danger Light"), + new("SemiColorDangerLightPointerover", "Danger Light Pointerover"), + new("SemiColorDangerLightActive", "Danger Light Active"), }; public static IReadOnlyList> TextTokens { get; } = new List> { - new ("SemiColorText0", "Text 0"), - new ("SemiColorText1", "Text 1"), - new ("SemiColorText2", "Text 2"), - new ("SemiColorText3", "Text 3"), + new("SemiColorText0", "Text 0"), + new("SemiColorText1", "Text 1"), + new("SemiColorText2", "Text 2"), + new("SemiColorText3", "Text 3"), }; - + public static IReadOnlyList> LinkTokens { get; } = new List> { - new ("SemiColorLink", "Link"), - new ("SemiColorLinkPointerover", "Link Pointerover"), - new ("SemiColorLinkActive", "Link Active"), - new ("SemiColorLinkVisited", "Link Visited"), + new("SemiColorLink", "Link"), + new("SemiColorLinkPointerover", "Link Pointerover"), + new("SemiColorLinkActive", "Link Active"), + new("SemiColorLinkVisited", "Link Visited"), }; - + public static IReadOnlyList> BackgroundTokens { get; } = new List> { - new ("SemiColorBackground0", "Background 0"), - new ("SemiColorBackground1", "Background 1"), - new ("SemiColorBackground2", "Background 2"), - new ("SemiColorBackground3", "Background 3"), - new ("SemiColorBackground4", "Background 4"), + new("SemiColorBackground0", "Background 0"), + new("SemiColorBackground1", "Background 1"), + new("SemiColorBackground2", "Background 2"), + new("SemiColorBackground3", "Background 3"), + new("SemiColorBackground4", "Background 4"), }; - + public static IReadOnlyList> FillTokens { get; } = new List> { - new ("SemiColorFill0", "Fill 0"), - new ("SemiColorFill1", "Fill 1"), - new ("SemiColorFill2", "Fill 2"), + new("SemiColorFill0", "Fill 0"), + new("SemiColorFill1", "Fill 1"), + new("SemiColorFill2", "Fill 2"), }; - + public static IReadOnlyList> BorderTokens { get; } = new List> { - new ("SemiColorBorder", "Border"), + new("SemiColorBorder", "Border"), }; - + public static IReadOnlyList> DisabledTokens { get; } = new List> { - new ("SemiColorDisabledText", "Disabled Text"), - new ("SemiColorDisabledBorder", "Disabled Border"), - new ("SemiColorDisabledBackground", "Disabled Background"), - new ("SemiColorDisabledFill", "Disabled Fill"), + new("SemiColorDisabledText", "Disabled Text"), + new("SemiColorDisabledBorder", "Disabled Border"), + new("SemiColorDisabledBackground", "Disabled Background"), + new("SemiColorDisabledFill", "Disabled Fill"), + }; + + public static IReadOnlyList> ShadowTokens { get; } = new List> + { + new("SemiColorShadow", "Shadow"), + new("SemiShadowElevated", "Shadow Elevated"), }; - } \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml b/demo/Semi.Avalonia.Demo/Views/MainView.axaml index 0c12b22..961a24d 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml @@ -15,56 +15,84 @@ - + + M12 21.5C10.65 20.65 8.2 20 6.5 20C4.85 20 3.15 20.3 1.75 21.05C1.65 21.1 1.6 21.1 1.5 21.1C1.25 21.1 1 20.85 1 20.6V6C1.6 5.55 2.25 5.25 3 5C4.11 4.65 5.33 4.5 6.5 4.5C8.45 4.5 10.55 4.9 12 6C13.45 4.9 15.55 4.5 17.5 4.5C18.67 4.5 19.89 4.65 21 5C21.75 5.25 22.4 5.55 23 6V20.6C23 20.85 22.75 21.1 22.5 21.1C22.4 21.1 22.35 21.1 22.25 21.05C20.85 20.3 19.15 20 17.5 20C15.8 20 13.35 20.65 12 21.5M12 8V19.5C13.35 18.65 15.8 18 17.5 18C18.7 18 19.9 18.15 21 18.5V7C19.9 6.65 18.7 6.5 17.5 6.5C15.8 6.5 13.35 7.15 12 8M13 11.5C14.11 10.82 15.6 10.5 17.5 10.5C18.41 10.5 19.26 10.59 20 10.78V9.23C19.13 9.08 18.29 9 17.5 9C15.73 9 14.23 9.28 13 9.84V11.5M17.5 11.67C15.79 11.67 14.29 11.93 13 12.46V14.15C14.11 13.5 15.6 13.16 17.5 13.16C18.54 13.16 19.38 13.24 20 13.4V11.9C19.13 11.74 18.29 11.67 17.5 11.67M20 14.57C19.13 14.41 18.29 14.33 17.5 14.33C15.67 14.33 14.17 14.6 13 15.13V16.82C14.11 16.16 15.6 15.83 17.5 15.83C18.54 15.83 19.38 15.91 20 16.07V14.57Z + M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z + M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23ZM17 15C17.476 15 17.9408 14.9525 18.3901 14.862C17.296 17.3011 14.8464 19 12 19C8.13401 19 5 15.866 5 12C5 8.60996 7.40983 5.78277 10.6099 5.13803C10.218 6.01173 10 6.98041 10 8C10 11.866 13.134 15 17 15Z + M3.55 19.09L4.96 20.5L6.76 18.71L5.34 17.29M12 6C8.69 6 6 8.69 6 12S8.69 18 12 18 18 15.31 18 12C18 8.68 15.31 6 12 6M20 13H23V11H20M17.24 18.71L19.04 20.5L20.45 19.09L18.66 17.29M20.45 5L19.04 3.6L17.24 5.39L18.66 6.81M13 1H11V4H13M6.76 5.39L4.96 3.6L3.55 5L5.34 6.81L6.76 5.39M1 13H4V11H1M13 20H11V23H13 + M2 19.5C2 18.6716 2.67157 18 3.5 18H20.5C21.3284 18 22 18.6716 22 19.5C22 20.3284 21.3284 21 20.5 21H3.5C2.67157 21 2 20.3284 2 19.5ZM2 12C2 11.1716 2.67157 10.5 3.5 10.5H20.5C21.3284 10.5 22 11.1716 22 12C22 12.8284 21.3284 13.5 20.5 13.5H3.5C2.67157 13.5 2 12.8284 2 12ZM2 4.5C2 3.67157 2.67157 3 3.5 3H20.5C21.3284 3 22 3.67157 22 4.5C22 5.32843 21.3284 6 20.5 6H3.5C2.67157 6 2 5.32843 2 4.5Z - - - + + + - + - - - - - - - + + + + + + + + + + + + + + + @@ -126,7 +155,7 @@ - + @@ -209,4 +238,4 @@ - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs index b7e74a8..9285eb1 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs @@ -1,10 +1,13 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Windows.Input; using Avalonia; using Avalonia.Controls; -using Avalonia.Interactivity; +using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Styling; using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; namespace Semi.Avalonia.Demo.Views; @@ -15,62 +18,63 @@ public partial class MainView : UserControl InitializeComponent(); this.DataContext = new MainViewModel(); } +} - private void ToggleButton_OnIsCheckedChanged(object sender, RoutedEventArgs e) +public partial class MainViewModel : ObservableObject +{ + public string DocumentationUrl => "https://docs.irihi.tech/semi"; + public string RepoUrl => "https://github.com/irihitech/Semi.Avalonia"; + public IReadOnlyList MenuItems { get; } + + public MainViewModel() + { + MenuItems = []; + } + + [RelayCommand] + private void ToggleTheme() + { + var app = Application.Current; + if (app is null) return; + var theme = app.ActualThemeVariant; + app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark; + } + + [RelayCommand] + private void SelectTheme(object? obj) { var app = Application.Current; if (app is not null) { - var theme = app.ActualThemeVariant; - app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark; + app.RequestedThemeVariant = obj as ThemeVariant; } } - private async void OpenRepository(object sender, RoutedEventArgs e) + [RelayCommand] + private static async Task OpenUrl(string url) { - var top = TopLevel.GetTopLevel(this); - if (top is null) return; - var launcher = top.Launcher; - await launcher.LaunchUriAsync(new Uri("https://github.com/irihitech/Semi.Avalonia")); - } - - private async void OpenDocumentation(object sender, RoutedEventArgs e) - { - var top = TopLevel.GetTopLevel(this); - if (top is null) return; - var launcher = top.Launcher; - await launcher.LaunchUriAsync(new Uri("https://docs.irihi.tech/semi")); - } -} - -public partial class MainViewModel: ObservableObject -{ - public ObservableCollection Themes { get; } = new() - { - new ThemeItem("Light", ThemeVariant.Light), - new ThemeItem("Dark", ThemeVariant.Dark), - new ThemeItem("Aquatic", SemiTheme.Aquatic), - new ThemeItem("Desert", SemiTheme.Desert), - new ThemeItem("Dust", SemiTheme.Dust), - new ThemeItem("NightSky", SemiTheme.NightSky), - }; - - [ObservableProperty] private ThemeItem? _selectedTheme; - - partial void OnSelectedThemeChanged(ThemeItem? oldValue, ThemeItem? newValue) - { - if (newValue is null) return; - var app = Application.Current; - if (app is not null) + var launcher = ResolveDefaultTopLevel()?.Launcher; + if (launcher is not null) { - app.RequestedThemeVariant = newValue.Theme; + await launcher.LaunchUriAsync(new Uri(url)); } } - + + private static TopLevel? ResolveDefaultTopLevel() + { + return Application.Current?.ApplicationLifetime switch + { + IClassicDesktopStyleApplicationLifetime desktopLifetime => desktopLifetime.MainWindow, + ISingleViewApplicationLifetime singleView => TopLevel.GetTopLevel(singleView.MainView), + _ => null + }; + } } -public class ThemeItem(string name, ThemeVariant theme) +public class MenuItemViewModel { - public string Name { get; set; } = name; - public ThemeVariant Theme { get; set; } = theme; + public string? Header { get; set; } + public ICommand? Command { get; set; } + public object? CommandParameter { get; set; } + public IList? Items { get; set; } } \ No newline at end of file diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/Program.cs b/demo/Semi.Avalonia.TreeDataGrid.Demo/Program.cs index b71cf5e..b0b60d9 100644 --- a/demo/Semi.Avalonia.TreeDataGrid.Demo/Program.cs +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/Program.cs @@ -1,5 +1,6 @@ using Avalonia; using System; +using Avalonia.Media; namespace Semi.Avalonia.TreeDataGrid.Demo; @@ -10,12 +11,21 @@ class Program // yet and stuff might break. [STAThread] public static void Main(string[] args) => BuildAvaloniaApp() + .With(new FontManagerOptions + { + FontFallbacks = + [ + new FontFallback + { + FontFamily = new FontFamily("Microsoft YaHei") + } + ] + }) .StartWithClassicDesktopLifetime(args); // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() - .WithInterFont() .LogToTrace(); } \ No newline at end of file diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/Semi.Avalonia.TreeDataGrid.Demo.csproj b/demo/Semi.Avalonia.TreeDataGrid.Demo/Semi.Avalonia.TreeDataGrid.Demo.csproj index 59312af..9327fae 100644 --- a/demo/Semi.Avalonia.TreeDataGrid.Demo/Semi.Avalonia.TreeDataGrid.Demo.csproj +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/Semi.Avalonia.TreeDataGrid.Demo.csproj @@ -1,28 +1,29 @@  WinExe - net6.0 + net8.0 enable true + latest app.manifest true + + + - + - - - + - - - + + diff --git a/src/Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml b/src/Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml index ea7d2a7..31cc570 100644 --- a/src/Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml +++ b/src/Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml @@ -5,6 +5,7 @@ xmlns:converters="using:Avalonia.Controls.Converters" xmlns:primitives="using:Avalonia.Controls.Primitives" x:CompileBindings="True"> + @@ -51,7 +52,6 @@ + + + @@ -30,7 +31,7 @@ VerticalAlignment="Stretch" Background="{DynamicResource ColorControlCheckeredBackgroundBrush}" /> + + diff --git a/src/Semi.Avalonia.ColorPicker/Controls/ColorSpectrum.axaml b/src/Semi.Avalonia.ColorPicker/Controls/ColorSpectrum.axaml index 4bc308e..2dcaaa8 100644 --- a/src/Semi.Avalonia.ColorPicker/Controls/ColorSpectrum.axaml +++ b/src/Semi.Avalonia.ColorPicker/Controls/ColorSpectrum.axaml @@ -4,6 +4,7 @@ xmlns:controls="using:Avalonia.Controls" xmlns:converters="using:Avalonia.Controls.Converters" x:CompileBindings="True"> + @@ -15,16 +16,16 @@ - 0 0 14 0 #1AFFFFFF + inset 0 0 0 1 #1AFFFFFF, 0 4 14 #40000000 \ No newline at end of file diff --git a/src/Semi.Avalonia.ColorPicker/Light.axaml b/src/Semi.Avalonia.ColorPicker/Light.axaml index 6148e2f..514b984 100644 --- a/src/Semi.Avalonia.ColorPicker/Light.axaml +++ b/src/Semi.Avalonia.ColorPicker/Light.axaml @@ -17,5 +17,5 @@ - 0 0 14 0 #1A000000 + 0 0 1 #4A000000, 0 4 14 #1A000000 \ No newline at end of file diff --git a/src/Semi.Avalonia.DataGrid/DataGrid.axaml b/src/Semi.Avalonia.DataGrid/DataGrid.axaml index 6a25ff3..0b3f116 100644 --- a/src/Semi.Avalonia.DataGrid/DataGrid.axaml +++ b/src/Semi.Avalonia.DataGrid/DataGrid.axaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:collections="using:Avalonia.Collections" x:CompileBindings="True"> + @@ -34,14 +35,14 @@ - + @@ -74,7 +75,7 @@ Foreground="{TemplateBinding Foreground}" /> @@ -203,7 +204,7 @@ TargetType="DataGridColumnHeader"> - + @@ -406,10 +407,11 @@ Margin="4,0,0,0" Foreground="{TemplateBinding Foreground}" IsVisible="{TemplateBinding IsPropertyNameVisible}" /> - + Content="{Binding Key}" /> + diff --git a/src/Semi.Avalonia.TreeDataGrid/Index.axaml b/src/Semi.Avalonia.TreeDataGrid/Index.axaml index f67ed3c..9fd70b0 100644 --- a/src/Semi.Avalonia.TreeDataGrid/Index.axaml +++ b/src/Semi.Avalonia.TreeDataGrid/Index.axaml @@ -1,9 +1,10 @@ + - - + + diff --git a/src/Semi.Avalonia.TreeDataGrid/Light.axaml b/src/Semi.Avalonia.TreeDataGrid/Light.axaml index 73c6c8b..f15e970 100644 --- a/src/Semi.Avalonia.TreeDataGrid/Light.axaml +++ b/src/Semi.Avalonia.TreeDataGrid/Light.axaml @@ -1,4 +1,5 @@ + diff --git a/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj b/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj index efb7e6d..fb6eff5 100644 --- a/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj +++ b/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj @@ -4,14 +4,14 @@ net6.0 enable latest - Update to Avalonia 11.1-rc1 + 11.0.10.1 + Update to 11.0.10.1 IRIHI Technology Co., Ltd. Avalonia Theme inspired by Semi Design. https://github.com/irihitech/Semi.Avalonia MIT irihi.png https://github.com/irihitech/Semi.Avalonia - 11.0.0 @@ -19,7 +19,7 @@ - + diff --git a/src/Semi.Avalonia.TreeDataGrid/Shared.axaml b/src/Semi.Avalonia.TreeDataGrid/Shared.axaml index dd2a475..b48fab4 100644 --- a/src/Semi.Avalonia.TreeDataGrid/Shared.axaml +++ b/src/Semi.Avalonia.TreeDataGrid/Shared.axaml @@ -1,4 +1,5 @@ + M17.549 15.659L12.753 21.139C12.6591 21.2464 12.5434 21.3325 12.4135 21.3915C12.2836 21.4505 12.1427 21.481 12 21.481C11.8574 21.481 11.7164 21.4505 11.5865 21.3915C11.4566 21.3325 11.3409 21.2464 11.247 21.139L6.45101 15.659C5.88501 15.011 6.34501 14 7.20401 14H16.796C17.656 14 18.115 15.012 17.549 15.659Z diff --git a/src/Semi.Avalonia.TreeDataGrid/TreeDataGrid.axaml b/src/Semi.Avalonia.TreeDataGrid/TreeDataGrid.axaml index c9e2cbe..e3e98c2 100644 --- a/src/Semi.Avalonia.TreeDataGrid/TreeDataGrid.axaml +++ b/src/Semi.Avalonia.TreeDataGrid/TreeDataGrid.axaml @@ -2,6 +2,7 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls.TreeDataGrid"> + @@ -11,7 +12,7 @@ - + - + + + + + + + + \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/AutoCompleteBox.axaml b/src/Semi.Avalonia/Controls/AutoCompleteBox.axaml index 8aa84a6..748d436 100644 --- a/src/Semi.Avalonia/Controls/AutoCompleteBox.axaml +++ b/src/Semi.Avalonia/Controls/AutoCompleteBox.axaml @@ -9,9 +9,9 @@ - - - + + + @@ -27,12 +27,13 @@ Watermark="{TemplateBinding Watermark}" /> - + diff --git a/src/Semi.Avalonia/Controls/Border.axaml b/src/Semi.Avalonia/Controls/Border.axaml index 53806cf..9967017 100644 --- a/src/Semi.Avalonia/Controls/Border.axaml +++ b/src/Semi.Avalonia/Controls/Border.axaml @@ -17,12 +17,12 @@ - - - - - - + + + + + + diff --git a/src/Semi.Avalonia/Controls/Button.axaml b/src/Semi.Avalonia/Controls/Button.axaml index 27ce9d5..4c6be64 100644 --- a/src/Semi.Avalonia/Controls/Button.axaml +++ b/src/Semi.Avalonia/Controls/Button.axaml @@ -27,7 +27,7 @@ + + + + + @@ -129,7 +134,6 @@ @@ -211,9 +215,9 @@ @@ -254,30 +258,32 @@ BasedOn="{StaticResource {x:Type Button}}" TargetType="Button"> + + + - - - + - diff --git a/src/Semi.Avalonia/Controls/Calendar.axaml b/src/Semi.Avalonia/Controls/Calendar.axaml index 15a6bbb..c5a7709 100644 --- a/src/Semi.Avalonia/Controls/Calendar.axaml +++ b/src/Semi.Avalonia/Controls/Calendar.axaml @@ -65,8 +65,8 @@ Foreground="{TemplateBinding Foreground}" Theme="{DynamicResource BorderlessButton}"> @@ -85,8 +85,8 @@ Foreground="{TemplateBinding Foreground}" Theme="{DynamicResource BorderlessButton}"> @@ -95,7 +95,8 @@ Name="PART_MonthView" Grid.Row="1" HorizontalAlignment="Stretch" - IsVisible="False"> + IsVisible="False" + ColumnDefinitions="*,*,*,*,*,*,*"> @@ -105,33 +106,14 @@ - - - - - - - - - - - - - - - - - - - - - + IsVisible="False" + ColumnDefinitions="*,*,*,*" + RowDefinitions="*,*,*" /> @@ -151,6 +133,7 @@ + + + + + + + @@ -20,11 +25,11 @@ + IsVisible="False" /> - - diff --git a/src/Semi.Avalonia/Controls/Carousel.axaml b/src/Semi.Avalonia/Controls/Carousel.axaml index 4b48df4..cf805c3 100644 --- a/src/Semi.Avalonia/Controls/Carousel.axaml +++ b/src/Semi.Avalonia/Controls/Carousel.axaml @@ -1,9 +1,66 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -12,6 +69,7 @@ Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" + BringIntoViewOnFocusChange="True" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> - - - - + + + + - - - - - + - - - - - - - - + + + - - - - - - + - - - - - - - + + + + + - - - - - - - - - - - - - + + + + + + + - - - - - + + + + + - - - + - + + + @@ -165,16 +192,15 @@ + ItemsSource="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemToObjectConverter}}" + IsVisible="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemVisibleConverter}}" + SelectedIndex="{TemplateBinding SelectedIndex, Mode=TwoWay}"> @@ -185,30 +211,31 @@ Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" + Theme="{DynamicResource CarouselButton}" Margin="{DynamicResource CarouselButtonMargin}" - VerticalAlignment="Center" - Background="{DynamicResource CarouselButtonPointeroverForeground}" - BorderBrush="{DynamicResource CarouselButtonPressedForeground}" - Command="{Binding $parent[Carousel].Previous}" Foreground="{DynamicResource CarouselButtonForeground}" - Theme="{DynamicResource CarouselButton}" /> + IsVisible="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemVisibleConverter}}" + Command="{Binding $parent[Carousel].Previous}" /> - - + + + + + + - + @@ -177,6 +182,7 @@ @@ -232,11 +237,11 @@