diff --git a/docs/plugins/essentials/notifications/actionsheets.md b/docs/plugins/essentials/notifications/actionsheets.md new file mode 100644 index 0000000..a793c6f --- /dev/null +++ b/docs/plugins/essentials/notifications/actionsheets.md @@ -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. diff --git a/docs/plugins/essentials/notifications/alerts.md b/docs/plugins/essentials/notifications/alerts.md new file mode 100644 index 0000000..78c1dd3 --- /dev/null +++ b/docs/plugins/essentials/notifications/alerts.md @@ -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) diff --git a/docs/plugins/essentials/notifications/images/simple-actionsheet.png b/docs/plugins/essentials/notifications/images/simple-actionsheet.png new file mode 100644 index 0000000..f8f4cec Binary files /dev/null and b/docs/plugins/essentials/notifications/images/simple-actionsheet.png differ diff --git a/docs/plugins/essentials/notifications/images/simple-alert.png b/docs/plugins/essentials/notifications/images/simple-alert.png new file mode 100644 index 0000000..1404312 Binary files /dev/null and b/docs/plugins/essentials/notifications/images/simple-alert.png differ diff --git a/docs/plugins/essentials/notifications/images/simple-prompt.png b/docs/plugins/essentials/notifications/images/simple-prompt.png new file mode 100644 index 0000000..642b7a1 Binary files /dev/null and b/docs/plugins/essentials/notifications/images/simple-prompt.png differ diff --git a/docs/plugins/essentials/notifications/images/two-button-alert.png b/docs/plugins/essentials/notifications/images/two-button-alert.png new file mode 100644 index 0000000..1c952b1 Binary files /dev/null and b/docs/plugins/essentials/notifications/images/two-button-alert.png differ diff --git a/docs/plugins/essentials/notifications/index.md b/docs/plugins/essentials/notifications/index.md new file mode 100644 index 0000000..8075dbc --- /dev/null +++ b/docs/plugins/essentials/notifications/index.md @@ -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. diff --git a/docs/plugins/essentials/notifications/prompts.md b/docs/plugins/essentials/notifications/prompts.md new file mode 100644 index 0000000..4a4668a --- /dev/null +++ b/docs/plugins/essentials/notifications/prompts.md @@ -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. diff --git a/docs/plugins/essentials/notifications/toc.yml b/docs/plugins/essentials/notifications/toc.yml new file mode 100644 index 0000000..170d83c --- /dev/null +++ b/docs/plugins/essentials/notifications/toc.yml @@ -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 \ No newline at end of file diff --git a/docs/plugins/essentials/toc.yml b/docs/plugins/essentials/toc.yml index 1cd3074..2962737 100644 --- a/docs/plugins/essentials/toc.yml +++ b/docs/plugins/essentials/toc.yml @@ -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