Git Product home page Git Product logo

controls.userdialogs.maui's Introduction

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.

NuGet NuGet

Supported Platforms

  • .NET7 for Android (min 7.0)(major target 13.0)
  • .NET7 for iOS (min 14.2)
  • .NET7 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

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

  1. 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.
  2. Navigating while inside of a loading/progress dialog causes exceptions or the progress no longer appears properly

    • Hide the progress dialog before navigating
  3. 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");
        });
  4. 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!
  5. Why does the library allow me to open multiple windows?

    • Similar to #4 - the library does not manage windows. It opens dialogs - SURPRISE
  6. 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.

controls.userdialogs.maui's People

Contributors

alex-dobrynin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.