Skip to content

Commit

Permalink
docs: adding documentation on the Notifications API
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Oct 24, 2024
1 parent 6e61ddd commit 5234537
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/plugins/essentials/notifications/actionsheets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
uid: Plugins.Essentials.Notifications.ActionSheets
---

# ActionSheets

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:

```cs
await notifications.ActionSheet.DisplayAsync("Send to:",
ActionSheetButton.CreateButton("Email", SendEmail),
ActionSheetButton.CreateButton("Twitter", SendTweet),
ActionSheetButton.CreateButton("Facebook Messenger", SendFacebookMessage));
```

![Simple ActionSheet](images/simple-actionsheet.png)

ActionSheets also provide the capability to provide an explicit Cancel or Destroy button.
21 changes: 21 additions & 0 deletions docs/plugins/essentials/notifications/alerts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
uid: Plugins.Essentials.Notifications.Alerts
---

# Alerts

To display an Alert you can use the `IAlerts` interface directly or through the aggregate service `INotifications` as follows:

```cs
await notifications.Alert.DisplayAsync("Alert", "You have been alerted");
```

![Simple Alert](images/simple-alert.png)

The Alert can also be used to prompt a user for a boolean (yes/no) response.

```cs
await notifications.Alert.DisplayAsync("Question?", "Would you like to play a game", "Yes", "No");
```

![Two Button Alert](images/two-button-alert.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/plugins/essentials/notifications/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
uid: Plugins.Essentials.Notifications
---

# Notifications

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.

## Getting Started

To use the Notifications API you must either call `UsePrismEssentials` or `RegisterNotifications`.

```cs
public class MyViewModel(INotifications notifications)
```

## Next Steps

- [ActionSheets](xref:Prism.Essentials.Notifications.ActionSheets)
- [Alerts](xref:Prism.Essentials.Notifications.Alerts)
- [Prompts](xref:Prism.Essentials.Notifications.Prompts)

> [!NOTE]
> 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.
22 changes: 22 additions & 0 deletions docs/plugins/essentials/notifications/prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
uid: Plugins.Essentials.Notifications.ActionSheets
---

# Prompts

To display a prompt you can use the `IPrompts` interface directly or the aggregate `INotifications` as follows:

```cs
var value = await notifications.Prompts.DisplayAsync("Question", "What's your name?");
```

![Simple Prompt](images/simple-prompt.png)

The Display method also provides additional optional parameters:

- `accept` - the text for the accept button.
- `cancel` - the text for the cancel button.
- `placeholder` - the placeholder text to display in the user prompt.
- `maxlength` - the max length of the user's response.
- `keyboard` - the keyboard type to use. This is provided via an enum value.
- `initialValue` - a predefined default value for the user to provide.
8 changes: 8 additions & 0 deletions docs/plugins/essentials/notifications/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: Getting Started
href: index.md
- name: ActionSheets
href: actionsheets.md
- name: Alerts
href: alerts.md
- name: Prompts
href: prompts.md
2 changes: 2 additions & 0 deletions docs/plugins/essentials/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
href: latestversion.md
- name: Main Thread
href: mainthread.md
- name: Notifications
href: notifications/toc.yml
- name: Permissions
href: permissions.md
- name: Phone Dialer
Expand Down

0 comments on commit 5234537

Please sign in to comment.