Browse Source

Add debug show notification

pull/438/head
Ionite 10 months ago
parent
commit
1ce19c8493
No known key found for this signature in database
  1. 5
      StabilityMatrix.Avalonia/Services/INotificationService.cs
  2. 31
      StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs

5
StabilityMatrix.Avalonia/Services/INotificationService.cs

@ -92,4 +92,9 @@ public interface INotificationService
NotificationType appearance = NotificationType.Error, NotificationType appearance = NotificationType.Error,
LogLevel logLevel = LogLevel.Warning LogLevel logLevel = LogLevel.Warning
); );
/// <summary>
/// Get the native notification manager.
/// </summary>
Task<DesktopNotifications.INotificationManager?> GetNativeNotificationManagerAsync();
} }

31
StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs

@ -770,7 +770,11 @@ public partial class MainSettingsViewModel : PageViewModelBase
#region Debug Commands #region Debug Commands
public CommandItem[] DebugCommands => public CommandItem[] DebugCommands =>
[new CommandItem(DebugFindLocalModelFromIndexCommand), new CommandItem(DebugExtractDmgCommand)]; [
new CommandItem(DebugFindLocalModelFromIndexCommand),
new CommandItem(DebugExtractDmgCommand),
new CommandItem(DebugShowNativeNotificationCommand)
];
[RelayCommand] [RelayCommand]
private async Task DebugFindLocalModelFromIndex() private async Task DebugFindLocalModelFromIndex()
@ -859,6 +863,31 @@ public partial class MainSettingsViewModel : PageViewModelBase
notificationService.Show("Extraction Complete", dmgFile); notificationService.Show("Extraction Complete", dmgFile);
} }
[RelayCommand]
private async Task DebugShowNativeNotification()
{
var nativeManager = await notificationService.GetNativeNotificationManagerAsync();
if (nativeManager is null)
{
notificationService.Show(
"Not supported",
"Native notifications are not supported on this platform.",
NotificationType.Warning
);
return;
}
await nativeManager.ShowNotification(
new DesktopNotifications.Notification
{
Title = "Test Notification",
Body = "Here is some message",
Buttons = { ("Action", "__Debug_Action"), ("Close", "__Debug_Close"), }
}
);
}
#endregion #endregion
#region Info Section #region Info Section

Loading…
Cancel
Save