Controls.UserDialogs.Maui
1.5.0
See the version list below for details.
dotnet add package Controls.UserDialogs.Maui --version 1.5.0
NuGet\Install-Package Controls.UserDialogs.Maui -Version 1.5.0
<PackageReference Include="Controls.UserDialogs.Maui" Version="1.5.0" />
paket add Controls.UserDialogs.Maui --version 1.5.0
#r "nuget: Controls.UserDialogs.Maui, 1.5.0"
// Install Controls.UserDialogs.Maui as a Cake Addin #addin nuget:?package=Controls.UserDialogs.Maui&version=1.5.0 // Install Controls.UserDialogs.Maui as a Cake Tool #tool nuget:?package=Controls.UserDialogs.Maui&version=1.5.0
<img src="userdialogs_maui_icon.png" width="70" height="70"/> Controls.Userdialogs.Maui
A cross platform library that allows you to call for native user dialogs, which can by styled from your maui application anywhere anytime.
Inspired by Allan Ritchie's Acr.UserDialogs
Since the original (Acr.UserDialogs) repo is out of support, this will give new breath to UserDialogs. It is more flexible to style your dialogs as you want.
Supported Platforms
- .NET8
- .NET8 for Android (min 7.0)(major target 13.0)
- .NET8 for iOS (min 14.2)
- .NET8 for MacCatalyst (min 13.1)
Features
- Alert
- Confirm
- Action Sheets
- Loading/Progress
- Toast
- Snackbar
- Sample
As for now it supports only Android, iOS and macOS. I don't have in plans to add new platforms. You are welcome to submit PR's for issues you may be having or for features you need and they will be reviewed.
Setup
To use, make sure you are using the latest version of .NET MAUI
Add UseUserDialogs(() => { })
to your MauiProgram.cs file
Also there is another overload which allows you to register UserDialogs instance in services and then use it with DI
UseUserDialogs(registerInterface: true, () => { })
builder
.UseMauiApp<App>()
.UseUserDialogs(() =>
{
//setup your default styles for dialogs
AlertConfig.DefaultBackgroundColor = Colors.Purple;
#if ANDROID
AlertConfig.DefaultMessageFontFamily = "OpenSans-Regular.ttf";
#else
AlertConfig.DefaultMessageFontFamily = "OpenSans-Regular";
#endif
ToastConfig.DefaultCornerRadius = 15;
})
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
Note: there are some properties available only for Android or only for iOS/macOS
Powered By:
- Android - Progress/Loading uses Redth's AndHUD
- iOS/macOS - Progress/Loading uses Nic Wise's BTProgressHUD
Frequently Asked Questions
I'm getting a nullreferenceexception when using loading.
- This happens when you run loading (or almost any dialog) from the constructor of your page or viewmodel. The view hasn't been rendered yet, therefore there is nothing to render to.
Navigating while inside of a loading/progress dialog causes exceptions or the progress no longer appears properly
- Hide the progress dialog before navigating
I don't like the way X method works on platform Y
- No problems. Override the implementation like below. Note: this is a partial class which has shared and platform specific realizations
public class MyCustomUserDialogs : Controls.UserDialogs.Maui.UserDialogImplementation { public override .. }
then in you MauiProgram.cs add this
builder .UseMauiApp<App>() .UseUserDialogs(() => { #if ANDROID Controls.UserDialogs.Maui.UserDialogs.Instance = new MyCustomUserDialogs(); //Android realization #elif IOS Controls.UserDialogs.Maui.UserDialogs.Instance = new MyCustomUserDialogs(); //iOS realization #else Controls.UserDialogs.Maui.UserDialogs.Instance = new MyCustomUserDialogs(); //mac realization #endif //setup your default styles for dialogs }) .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); });
Why don't you cancel a dialog when the app goes to the background (AND) why do I get an exception when I call for a dialog?
- USER DIALOGS DOES NOT SOLVE WORLD PEACE! Guess what - most android API version and iOS don't call this. This library is not a window state manager, if you call for a dialog,
it will try to present one. If your app goes to the background and you call for a dialog, iOS & Android are tossing you the exception. The library isn't here to save you from bad design choices.
Call us an anti-pattern if you want, we present dialogs!
- USER DIALOGS DOES NOT SOLVE WORLD PEACE! Guess what - most android API version and iOS don't call this. This library is not a window state manager, if you call for a dialog,
it will try to present one. If your app goes to the background and you call for a dialog, iOS & Android are tossing you the exception. The library isn't here to save you from bad design choices.
Why does the library allow me to open multiple windows?
- Similar to #4 - the library does not manage windows. It opens dialogs - SURPRISE
I'd like to customize the dialogs in native way (e.g. in Android in styles or themes)
- The library wasn't really designed or meant for this. It was meant for using native dialogs with programmatically styling. That's it. If you need something more you are free to contribute here or to use Acr.UserDialogs which is out of support.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-android34.0 is compatible. net8.0-browser was computed. net8.0-ios was computed. net8.0-ios17.0 is compatible. net8.0-maccatalyst was computed. net8.0-maccatalyst17.0 is compatible. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
-
net8.0-android34.0
- AndHUD (>= 2.0.1)
-
net8.0-ios17.0
- BTProgressHUD (>= 2.0.1)
-
net8.0-maccatalyst17.0
- BTProgressHUD (>= 2.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Controls.UserDialogs.Maui:
Package | Downloads |
---|---|
SweetMeSoft.Mobile.Base
SweetMeSoft Mobile MAUI Base Library is a compilation of different utils for MAUI apps |
|
exotel_chatbot
Exotel Chatbot MAUI SDK |
|
ChatBotCustomWebViewPlugin
MAUI Chatbot WebView SDK |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.6.3 | 690 | 9/30/2024 |
1.6.2 | 629 | 9/20/2024 |
1.6.1 | 1,195 | 9/4/2024 |
1.6.0 | 153 | 9/3/2024 |
1.5.4 | 23,823 | 3/20/2024 |
1.5.3 | 5,663 | 2/19/2024 |
1.5.2 | 3,824 | 1/22/2024 |
1.5.1 | 5,091 | 1/4/2024 |
1.5.0 | 3,829 | 11/15/2023 |
1.4.0 | 2,641 | 11/13/2023 |
1.3.0 | 4,270 | 9/20/2023 |
1.2.2 | 698 | 9/7/2023 |
1.2.1 | 588 | 9/4/2023 |
1.1.2 | 365 | 8/4/2023 |
1.1.1 | 193 | 8/4/2023 |
1.1.0 | 344 | 7/23/2023 |
1.0.1 | 197 | 7/21/2023 |
1.0.0 | 214 | 7/19/2023 |