|
5 | 5 | using Avalonia;
|
6 | 6 | using Avalonia.Collections;
|
7 | 7 | using Avalonia.Controls;
|
| 8 | +using Avalonia.Controls.Notifications; |
8 | 9 | using Avalonia.Controls.Primitives;
|
9 | 10 | using Avalonia.Controls.Templates;
|
10 | 11 | using Avalonia.LogicalTree;
|
11 | 12 | using Avalonia.Rendering.Composition;
|
12 | 13 | using Avalonia.Threading;
|
13 | 14 | using Hollow.Helpers;
|
14 | 15 | using Hollow.Views.Controls.Toast;
|
15 |
| -using NotificationType = Hollow.Enums.NotificationType; |
16 | 16 |
|
17 | 17 | namespace Hollow.Views.Controls;
|
18 | 18 |
|
@@ -156,20 +156,20 @@ public static async Task ShowToast(Window window, ToastModel model)
|
156 | 156 | public static Task ShowToast(ToastModel model) =>
|
157 | 157 | ShowToast(_mainWindow!, model);
|
158 | 158 |
|
159 |
| - public static Task ShowToast(string title, string content = "", NotificationType? type = NotificationType.Info, TimeSpan? duration = null, Action? onClicked = null) => |
| 159 | + public static Task ShowToast(string title, string? content, NotificationType? type, TimeSpan? duration = null, Action? onClicked = null) => |
160 | 160 | ShowToast(new ToastModel(
|
161 | 161 | title,
|
162 |
| - content, |
163 |
| - type ?? NotificationType.Info, |
| 162 | + content ?? "", |
| 163 | + type ?? NotificationType.Information, |
164 | 164 | duration ?? TimeSpan.FromSeconds(4),
|
165 | 165 | onClicked));
|
166 | 166 |
|
167 |
| - public static Task ShowToast(Window window, string title, string content = "", NotificationType? type = NotificationType.Info, TimeSpan? duration = null, |
| 167 | + public static Task ShowToast(Window window, string title, string? content, NotificationType? type, TimeSpan? duration = null, |
168 | 168 | Action? onClicked = null) =>
|
169 | 169 | ShowToast(window, new ToastModel(
|
170 | 170 | title,
|
171 |
| - content, |
172 |
| - type ?? NotificationType.Info, |
| 171 | + content ?? "", |
| 172 | + type ?? NotificationType.Information, |
173 | 173 | duration ?? TimeSpan.FromSeconds(4),
|
174 | 174 | onClicked));
|
175 | 175 |
|
@@ -201,6 +201,16 @@ public static void ClearAllToasts(Window window)
|
201 | 201 |
|
202 | 202 | public static void ClearAllToasts() => ClearAllToasts(_mainWindow!);
|
203 | 203 |
|
| 204 | + #region New Toasts |
| 205 | + |
| 206 | + public static WindowNotificationManager NotificationManager { get; set; } = null!; |
| 207 | + public static void ShowAvaloniaToast(string title, string message, NotificationType notificationType, TimeSpan? timeSpan = null, Action? onClick = null, Action? onClose = null) |
| 208 | + { |
| 209 | + NotificationManager.Show(new Notification(title, message, notificationType, timeSpan, onClick, onClose)); |
| 210 | + } |
| 211 | + |
| 212 | + #endregion |
| 213 | + |
204 | 214 | protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
205 | 215 | {
|
206 | 216 | base.OnDetachedFromLogicalTree(e);
|
|
0 commit comments