From a00b0d21103e9003e5121e58102c2cb1a7a3aa48 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:54:30 +0800 Subject: [PATCH] feat: redesign Banner. --- demo/Ursa.Demo/Pages/BannerDemo.axaml | 39 ++++++----- demo/Ursa.Demo/Pages/BannerDemo.axaml.cs | 38 ++--------- src/Ursa.Themes.Semi/Controls/Banner.axaml | 66 +++++++++---------- .../Themes/Shared/Banner.axaml | 3 + 4 files changed, 64 insertions(+), 82 deletions(-) diff --git a/demo/Ursa.Demo/Pages/BannerDemo.axaml b/demo/Ursa.Demo/Pages/BannerDemo.axaml index 91c8f89..d8e6b85 100644 --- a/demo/Ursa.Demo/Pages/BannerDemo.axaml +++ b/demo/Ursa.Demo/Pages/BannerDemo.axaml @@ -13,28 +13,27 @@ - - - - - + - + - + \ No newline at end of file diff --git a/demo/Ursa.Demo/Pages/BannerDemo.axaml.cs b/demo/Ursa.Demo/Pages/BannerDemo.axaml.cs index cd7b94d..e0d16d1 100644 --- a/demo/Ursa.Demo/Pages/BannerDemo.axaml.cs +++ b/demo/Ursa.Demo/Pages/BannerDemo.axaml.cs @@ -1,7 +1,7 @@ -using System.Collections.ObjectModel; using Avalonia.Controls; using Avalonia.Controls.Notifications; using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.ComponentModel; using Ursa.Demo.ViewModels; namespace Ursa.Demo.Pages; @@ -20,37 +20,9 @@ public partial class BannerDemo : UserControl } } -public class BannerDemoViewModel : ViewModelBase +public partial class BannerDemoViewModel : ViewModelBase { - private ObservableCollection? _types; - - public ObservableCollection? Types - { - get => _types; - set => SetProperty(ref _types, value); - } - - private NotificationType _selectedType; - - public NotificationType SelectedType - { - get => _selectedType; - set => SetProperty(ref _selectedType, value); - } - - private bool _bordered; - - public bool Bordered - { - get => _bordered; - set => SetProperty(ref _bordered, value); - } - - public BannerDemoViewModel() - { - Types = new ObservableCollection() - { - NotificationType.Information, NotificationType.Success, NotificationType.Warning, NotificationType.Error - }; - } + [ObservableProperty] private NotificationType _selectedType; + [ObservableProperty] private bool _bordered; + [ObservableProperty] private bool _canClose; } \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Banner.axaml b/src/Ursa.Themes.Semi/Controls/Banner.axaml index e69fc97..4050b03 100644 --- a/src/Ursa.Themes.Semi/Controls/Banner.axaml +++ b/src/Ursa.Themes.Semi/Controls/Banner.axaml @@ -2,8 +2,18 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:u="https://irihi.tech/ursa"> - + + + + + + @@ -11,19 +21,16 @@ + ColumnDefinitions="Auto, *"> + Theme="{DynamicResource InnerPathIcon}" + Classes="Large" + IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" /> - - + + + + + Margin="{DynamicResource BannerCloseButtonMargin}" + HorizontalAlignment="Right" + VerticalAlignment="Top" + Theme="{DynamicResource NotificationCloseButton}" + IsVisible="{TemplateBinding CanClose}" /> @@ -120,4 +118,4 @@ - + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml index df1300f..93e5a38 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/Banner.axaml @@ -6,6 +6,9 @@ 3 + 12 1 0 0 12 0 + 12 0 0 0 + 18 \ No newline at end of file