Skip to content

Commit 5234537

Browse files
committed
docs: adding documentation on the Notifications API
1 parent 6e61ddd commit 5234537

10 files changed

+95
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
uid: Plugins.Essentials.Notifications.ActionSheets
3+
---
4+
5+
# ActionSheets
6+
7+
An ActionSheet presents the user with a set of alternatives for how to proceed with a task. To display an ActionSheet you can use the `IActionSheet` directly or you can use the aggregate `INotifications` interface as follows:
8+
9+
```cs
10+
await notifications.ActionSheet.DisplayAsync("Send to:",
11+
ActionSheetButton.CreateButton("Email", SendEmail),
12+
ActionSheetButton.CreateButton("Twitter", SendTweet),
13+
ActionSheetButton.CreateButton("Facebook Messenger", SendFacebookMessage));
14+
```
15+
16+
![Simple ActionSheet](images/simple-actionsheet.png)
17+
18+
ActionSheets also provide the capability to provide an explicit Cancel or Destroy button.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
uid: Plugins.Essentials.Notifications.Alerts
3+
---
4+
5+
# Alerts
6+
7+
To display an Alert you can use the `IAlerts` interface directly or through the aggregate service `INotifications` as follows:
8+
9+
```cs
10+
await notifications.Alert.DisplayAsync("Alert", "You have been alerted");
11+
```
12+
13+
![Simple Alert](images/simple-alert.png)
14+
15+
The Alert can also be used to prompt a user for a boolean (yes/no) response.
16+
17+
```cs
18+
await notifications.Alert.DisplayAsync("Question?", "Would you like to play a game", "Yes", "No");
19+
```
20+
21+
![Two Button Alert](images/two-button-alert.png)
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
uid: Plugins.Essentials.Notifications
3+
---
4+
5+
# Notifications
6+
7+
Displaying an alert, asking a user to make a choice, or displaying a prompt is a common UI task. The Notifications API from Prism Essentials is designed as a cross platform replacement API for the PageDialogService in Prism.Forms and Prism.Maui. For those migrating from Prism.Forms it is recommended to migrate to this API as this will better help you to migrate your code to a more future proof API which will work well into the future without the need to change your code should you choose to switch between Uno Platform and .NET MAUI. Additionally this API will be providing support with WPF making your WPF apps easier to migrate to mobile in the future.
8+
9+
## Getting Started
10+
11+
To use the Notifications API you must either call `UsePrismEssentials` or `RegisterNotifications`.
12+
13+
```cs
14+
public class MyViewModel(INotifications notifications)
15+
```
16+
17+
## Next Steps
18+
19+
- [ActionSheets](xref:Prism.Essentials.Notifications.ActionSheets)
20+
- [Alerts](xref:Prism.Essentials.Notifications.Alerts)
21+
- [Prompts](xref:Prism.Essentials.Notifications.Prompts)
22+
23+
> [!NOTE]
24+
> This is currently only supported on Android, iOS, MacCatalyst, & WinUI for .NET MAUI and Uno Platform. This feature is planned for future expansion to all Uno Platform platforms and WPF.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
uid: Plugins.Essentials.Notifications.ActionSheets
3+
---
4+
5+
# Prompts
6+
7+
To display a prompt you can use the `IPrompts` interface directly or the aggregate `INotifications` as follows:
8+
9+
```cs
10+
var value = await notifications.Prompts.DisplayAsync("Question", "What's your name?");
11+
```
12+
13+
![Simple Prompt](images/simple-prompt.png)
14+
15+
The Display method also provides additional optional parameters:
16+
17+
- `accept` - the text for the accept button.
18+
- `cancel` - the text for the cancel button.
19+
- `placeholder` - the placeholder text to display in the user prompt.
20+
- `maxlength` - the max length of the user's response.
21+
- `keyboard` - the keyboard type to use. This is provided via an enum value.
22+
- `initialValue` - a predefined default value for the user to provide.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- name: Getting Started
2+
href: index.md
3+
- name: ActionSheets
4+
href: actionsheets.md
5+
- name: Alerts
6+
href: alerts.md
7+
- name: Prompts
8+
href: prompts.md

docs/plugins/essentials/toc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
href: latestversion.md
1111
- name: Main Thread
1212
href: mainthread.md
13+
- name: Notifications
14+
href: notifications/toc.yml
1315
- name: Permissions
1416
href: permissions.md
1517
- name: Phone Dialer

0 commit comments

Comments
 (0)