From 32c6c81860db5571399975cd8d756aa8fca6bf7a Mon Sep 17 00:00:00 2001 From: Mccree Lee Date: Sat, 10 Aug 2024 10:15:42 +0800 Subject: [PATCH 1/6] perf: using Avalonia `NotificationType` --- .../Features/ControlsLibrary/MiscViewModel.cs | 3 ++- .../ControlsLibrary/Toasts/ToastsViewModel.cs | 7 ++++--- SukiUI/Controls/InfoBadge.axaml | 4 ++-- SukiUI/Controls/InfoBadge.axaml.cs | 5 +++-- SukiUI/Controls/InfoBar.axaml.cs | 12 +++++------- SukiUI/Controls/SukiHost.axaml.cs | 19 +++++++------------ SukiUI/Controls/SukiToast.axaml.cs | 5 +++-- SukiUI/Enums/NotificationType.cs | 9 --------- SukiUI/Models/MessageBoxModel.cs | 3 ++- SukiUI/Models/ToastModel.cs | 3 ++- 10 files changed, 30 insertions(+), 40 deletions(-) delete mode 100644 SukiUI/Enums/NotificationType.cs diff --git a/SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs b/SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs index a65793afe..94c5661c0 100644 --- a/SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs +++ b/SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs @@ -3,6 +3,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Controls.Notifications; using Avalonia.Media; using Avalonia.Platform.Storage; using CommunityToolkit.Mvvm.ComponentModel; @@ -32,7 +33,7 @@ private async Task ToggleBusy() [RelayCommand] private void OpenBox() { - SukiHost.ShowMessageBox(new MessageBoxModel("Update Available", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", NotificationType.Info, "Update Now", () =>{SukiHost.CloseDialog();} )); + SukiHost.ShowMessageBox(new MessageBoxModel("Update Available", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", NotificationType.Information, "Update Now", () =>{SukiHost.CloseDialog();} )); } [RelayCommand] diff --git a/SukiUI.Demo/Features/ControlsLibrary/Toasts/ToastsViewModel.cs b/SukiUI.Demo/Features/ControlsLibrary/Toasts/ToastsViewModel.cs index 47133a8bb..46cbec9c8 100644 --- a/SukiUI.Demo/Features/ControlsLibrary/Toasts/ToastsViewModel.cs +++ b/SukiUI.Demo/Features/ControlsLibrary/Toasts/ToastsViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Avalonia.Controls; +using Avalonia.Controls.Notifications; using CommunityToolkit.Mvvm.Input; using Material.Icons; using SukiUI.Controls; @@ -18,11 +19,11 @@ private static Task ShowSingleStandardToast() => [RelayCommand] private static Task ShowInfoToast() => - SukiHost.ShowToast("A Simple Toast", "This is the content of an info toast.", NotificationType.Info); + SukiHost.ShowToast("A Simple Toast", "This is the content of an info toast.", NotificationType.Information); [RelayCommand] private static Task ShowActionToast() => - SukiHost.ShowToast(new ToastModel("Update Available", "A new version is available for you.", NotificationType.Info, TimeSpan.FromSeconds(5), null, "Update Now", + SukiHost.ShowToast(new ToastModel("Update Available", "A new version is available for you.", NotificationType.Information, TimeSpan.FromSeconds(5), null, "Update Now", () => { SukiHost.ShowToast("Update", new ProgressBar(){Value = 43, ShowProgressText = true});})); [RelayCommand] @@ -47,7 +48,7 @@ private static async Task ShowThreeInfoToasts() [RelayCommand] private static Task ShowToastWithCallback() { - return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", NotificationType.Info, TimeSpan.FromSeconds(15), + return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", NotificationType.Information, TimeSpan.FromSeconds(15), () => SukiHost.ShowDialog( new TextBlock { Text = "You clicked the toast! - Click anywhere outside of this dialog to close." }, allowBackgroundClose: true)); diff --git a/SukiUI/Controls/InfoBadge.axaml b/SukiUI/Controls/InfoBadge.axaml index ecddd1feb..96c1b5d3c 100644 --- a/SukiUI/Controls/InfoBadge.axaml +++ b/SukiUI/Controls/InfoBadge.axaml @@ -8,7 +8,7 @@ Height="400" Margin="0,20,0,0" Spacing="20"> - @@ -34,7 +34,7 @@ IsDot="True">