forked from kas/percentage
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New notification button to disable a particular level of notification…
… and manual refresh button in details view.
- Loading branch information
1 parent
17daacd
commit 758d376
Showing
8 changed files
with
123 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,54 @@ | ||
using Microsoft.Toolkit.Uwp.Notifications; | ||
using System; | ||
using Microsoft.Toolkit.Uwp.Notifications; | ||
|
||
namespace Percentage.App.Extensions; | ||
|
||
internal static class ToastNotificationExtensions | ||
{ | ||
private const string ActionArgumentKey = "action"; | ||
private const string NotificationTypeArgumentKey = "notificationType"; | ||
|
||
internal static Action GetActionArgument(this ToastArguments arguments) | ||
{ | ||
return arguments.GetEnum<Action>(ActionArgumentKey); | ||
} | ||
|
||
internal static void ShowToastNotification(string header, string body) | ||
internal static NotificationType GetNotificationTypeArgument(this ToastArguments arguments) | ||
{ | ||
return arguments.GetEnum<NotificationType>(NotificationTypeArgumentKey); | ||
} | ||
|
||
internal static void ShowToastNotification(string header, string body, NotificationType notificationType) | ||
{ | ||
if (notificationType == NotificationType.None) | ||
{ | ||
throw new NotSupportedException($"Notification type {notificationType} is not supported."); | ||
} | ||
|
||
new ToastContentBuilder() | ||
.AddText(header) | ||
.AddText(body) | ||
.AddButton(new ToastButton().SetContent("See more details") | ||
.AddButton(new ToastButton().SetContent("Details") | ||
.AddArgument(ActionArgumentKey, Action.ViewDetails)) | ||
.AddButton(new ToastButton().SetContent("Disable") | ||
.AddArgument(ActionArgumentKey, Action.DisableBatteryNotification) | ||
.AddArgument(NotificationTypeArgumentKey, notificationType)) | ||
.AddButton(new ToastButtonDismiss()) | ||
.Show(); | ||
} | ||
|
||
internal enum Action | ||
{ | ||
ViewDetails = 0 | ||
ViewDetails = 0, | ||
DisableBatteryNotification | ||
} | ||
|
||
internal enum NotificationType | ||
{ | ||
None = 0, | ||
Critical, | ||
Low, | ||
High, | ||
Full | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters