Giter VIP home page Giter VIP logo

userdialogs2's Introduction

UserDialogs

Common UserDialogs interface for xamarin.forms(android/ios).

Component

  1. Alert
  2. Confirm
  3. Toast
  4. ActionSheet
  5. Loading
  6. Progress
  7. DateTimePicker
  8. OptionsPicker
  9. Prompt
  10. Prompt with Multi-line (eg: Login Prompt )

Support Platforms

  1. Android 7.1+
  2. iOS 10+
  3. NET Standard 2.0

Setup

Install nuget package in share/standard and platform projects. Passingwind.UserDialogs

Install-Package Passingwind.UserDialogs

a. Android Initialization (In your main activity)

UserDialogs.Init(this);

b. iOS (nothing to do)

Interface

void Toast(string message);

void Toast(ToastConfig config);

IDisposable Snackbar(string message, Action action = null);

IDisposable Snackbar(SnackbarConfig config);

void Alert(string message);

void Alert(AlertConfig config);

IDisposable ActionSheet(ActionSheetConfig config);

IDisposable Loading(LoadingConfig config);

IProgressDialog Progress(ProgressConfig config);

void Prompt(PromptConfig config);

void Form(PromptFormConfig config);

Useage

  1. Alert

    Set default field:

    AlertConfig.DefaultOkText = ""; // default 'yes'
    // AlertConfig.DefaultCancelText

    Alert message:

    UserDialogs.Instance.Alert("you message");
    
    UserDialogs.Instance.Alert(new AlertConfig("you message").AddOkButton());

    Confirm Message:

    UserDialogs.Instance.Alert(new AlertConfig("you confirm message")
                                            .AddOkButton(action: () => {
                                                // ok handle
                                            })
                                            .AddCancelButton());
  2. Toast

    UserDialogs.Instance.Toast("you message");
  3. Snackbar

    Set default field:

    SnackbarConfig.DefaultTimeSpan = TimeSpan.FromSeconds(1.2); // default 1.2s
    SnackbarConfig.DefaultActionText = null;
    SnackbarConfig.DefaultBackgroundColor = null;
    SnackbarConfig.DefaultTextColor = null;
    SnackbarConfig.DefaultActionTextColor = null;
    UserDialogs.Instance.Snackbar(new SnackbarConfig()
    {
        Message = "well down !!!",
        //Duration = TimeSpan.FromSeconds(3),
        //TextColor = Color.BurlyWood,
        //BackgroundColor = Color.Yellow,
        //ActionText = "sure",
        //ActionTextColor = Color.Red,
    
        Action = () => {
            // you handle here
         }
    });
  4. ActionSheet

    Set default field:

    ActionSheetConfig.DefaultCancelText = "Cancel"; // default 'Cancel'
    ActionSheetConfig.DefaultDestructiveText = "Remove"; // default 'Remove'
    ActionSheetConfig.DefaultBottomSheet = false;  // default false
    var config = new ActionSheetConfig
    {
        Title = "Title",
        Message = "you message",
    
        // BottomSheet = false,
        // ItemTextAlgin = ActionSheetItemTextAlgin.Center;
    };
    
    c.AddItem("item1");
    c.AddItem("item2");
    c.AddItem("item3", action: () => {
        // you handle 
    });
    
    //config.AddCancel();
    //config.AddDestructive();
    
    UserDialogs.Instance.ActionSheet(config);
  5. Loading

    Show loading hub when task start.

    var dialog = UserDialogs.Instance.Loading(new LoadingConfig("please wait")
        {
            Cancellable = true, // can cancel loading when show loading
            CancelAction = () => // you action handle 
    
            Duration = TimeSpan.FromSeconds(5), // show loading duration second
    
            // MarkType = MarkType.Black 
        });
    
    // close dialog if you need.
    dialog.Dispose();
  6. Progress

    show progress hub.

    var dialog = UserDialogs.Instance.Progress(new ProgressConfig("download...")
    {
        Cancellable = true, // can cancel loading when show loading 
        CancelAction = () => // you action handle
    
    });
    
    // set current progress value when task update
    dialog.SetProgress(30);   // 1-100
    
    // close dialog if you need.
    dialog.Hide();
  7. Form

    show prompt form

    UserDialogs.Instance.Form(new PromptFormConfig()
    {
        Title = "Please Login", 
    
        OnAction = (result) =>
        {
            if(result.Ok){ 
                var username = result.Result["username"]; 
                // then you code ...
            } 
        }
    }
    .AddItem("username", "username", maxLength: 16) // add 'username' inputbox
    .AddItem("password", "password", InputType.Password, maxLength: 6) // add 'password' password inputbox
    );

Powered By

  1. Android- Progress/Loading uses KProgressHUD
  2. iOS - Progress/Loading/Toast uses MBProgressHUD
  3. iOS - Snackbar uses TTGSnackbar

userdialogs2's People

Contributors

imgbotapp avatar jxnkwlp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wx0322 kiddailey

userdialogs2's Issues

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.