Skip to content

Latest commit

 

History

History
167 lines (147 loc) · 4.59 KB

MessageDialogDoc.md

File metadata and controls

167 lines (147 loc) · 4.59 KB

MessageDialog Documentation

Message dialog example

MessageDialog messageDialog = new MessageDialog();
messageDialog.Builder(context)
	.setTitle("Title")
       	.setMessage("Message")
       	.show();

MessageDialog example

Builder

Apply the default theme to a dialog

messageDialog.Builder(context)

MessageDialog day-night Apply the app theme to a dialog (only works with material3 theme)

messageDialog.Builder(context,true)

MessageDialog day-night theme

Apply the custom theme to a dialog (only works with material3 theme)

messageDialog.Builder(context,theme)

Old Dialog theme

By default dialog colors will be set to material3 dynamic colors. With this method you can set the dialog color for the background and buttons to the older non-dynamic colors

messageDialog.setOldTheme();

MessageDialog oldTheme

DialogPreset

With DialogPreset, you can create customized dialogs with consistent customizations. Simply create a DialogPreset and implement it across all dialogs that you want to have that customizations.

Creating a DialogPreset

DialogPreset<MessageDialog> preset = dialog -> {
    // add customization here  
};

Example

DialogPreset<MessageDialog> preset = dialog -> {
    dialog.setDialogBackgroundResource(background)
        .setTextColor(textColor)
        .setButtonColor(btnColor);
};

Apply presets to a dialog

messageDialog.setPresets(preset);

It's recommended to apply the presets first before modifying any other properties

Example

messageDialog.Builder(context,true)
    .setPresets(preset)
    .setTitle("Title")
    .setMessage("Message")
    ...

Add onClick Listener

messageDialog.onButtonClick(new DialogButtonEvent() {
	@Override
      	public void onButtonClick() {
      		// Do something
      	}
});

//or

messageDialog.onButtonClick(() -> {
	// Do something
});

Add onShowListener

messageDialog.onShowListener(dialogInterface -> {
    // Do something
});

Add onDismissListener

messageDialog.onDismissListener(dialogInterface -> {
    // Do something
});

Apply Insets

supported values: INSETS_LEFT, INSETS_RIGHT, INSETS_BOTTOM, INSETS_HORIZONTAL, INSETS_ALL or INSETS_NONE.

messageDialog.applyInsets(INSETS_HORIZONTAL);

You can combine multiple values with bitwise-OR ( | ) operator

messageDialog.applyInsets(INSETS_LEFT | INSETS_RIGHT);

All MessageDialog Methods

//Create dialog
messageDialog.Builder(context);

//Usin the old dialog theme
messageDialog.setOldTheme();

//Set title
messageDialog.setTitle("Title");
//Set message
messageDialog.setMessage("Message");

//Set title text alignment
messageDialog.setTitleAlignment(TextAlignment);
//Set message text alignment
messageDialog.setMessageAlignment(TextAlignment);

//Set button text
messageDialog.setButtonText("Text");

//Set text color
messageDialog.setTextColor(color);
//Set title text color
messageDialog.setTitleTextColor(color);
//Set message text color
messageDialog.setMessageTextColor(color);

//Set button color
messageDialog.setButtonColor(color);

//Set button text color
messageDialog.setButtonTextColor(color);

//Set button background resource
messageDialog.setButtonBackgroundResource(drawable);

//Set dialog color
messageDialog.setDialogBackgroundColor(color);
//Set dialog background resource
messageDialog.setDialogBackgroundResource(drawable);

//Set maximum dialog width. Default is 600dp
messageDialog.setMaxDialogWidth(width);

//Get maximum dialog width
int dialogWidth = messageDialog.getMaxDialogWidth();

//Get button
Button Button = messageDialog.getButton();
        
//Set dialog animations
messageDialog.setDialogAnimations(styleRes);

//Enable or disable swipe down to dismiss dialog. 
//By default is set to true
dialog.swipeToDismiss(boolean);

//Set dialog onTouchListener.
//This method will overide swipe down to dismiss action
dialog.setOnTouchListener(onTouchListener);

//Apply insets (INSETS_LEFT, INSETS_RIGHT, INSETS_BOTTOM, INSETS_HORIZONTAL, INSETS_ALL or INSETS_NONE)
messageDialog.applyInsets(insets);

//Shew dialog
messageDialog.show();
//Dismiss dialog
messageDialog.dismiss();