MaterialDialogScope

interface MaterialDialogScope

Interface defining values and functions which are available to any code within a MaterialDialog's content parameter

Functions

DialogCallback
Link copied to clipboard
@Composable
abstract fun DialogCallback(callback: () -> Unit)

Adds a callback to the dialog which is called on positive button press

PositiveButtonEnabled
Link copied to clipboard
@Composable
abstract fun PositiveButtonEnabled(valid: Boolean, onDispose: () -> Unit)

Adds a value to the positiveButtonEnabled map and updates the value in the map when valid changes

reset
Link copied to clipboard
abstract fun reset()

Clears the dialog's state

submit
Link copied to clipboard
abstract fun submit()

Hides the dialog and calls any callbacks from components in the dialog

Properties

autoDismiss
Link copied to clipboard
abstract val autoDismiss: Boolean
callbacks
Link copied to clipboard
abstract val callbacks: SnapshotStateMap<Int, () -> Unit>
dialogButtons
Link copied to clipboard
abstract val dialogButtons: MaterialDialogButtons
dialogState
Link copied to clipboard
abstract val dialogState: MaterialDialogState
positiveButtonEnabled
Link copied to clipboard
abstract val positiveButtonEnabled: SnapshotStateMap<Int, Boolean>

Extensions

customView
Link copied to clipboard
@Composable
fun MaterialDialogScope.customView(content: @Composable () -> Unit)

Create an view in the dialog with the given content and appropriate padding

iconTitle
Link copied to clipboard
@Composable
fun MaterialDialogScope.iconTitle(text: String? = null, @StringRes textRes: Int? = null, icon: @Composable () -> Unit = {})

Adds a title with the given text and icon to the dialog

input
Link copied to clipboard
@Composable
fun MaterialDialogScope.input(label: String, hint: String = "", prefill: String = "", waitForPositiveButton: Boolean = true, visualTransformation: VisualTransformation = VisualTransformation.None, keyboardOptions: KeyboardOptions = KeyboardOptions(), keyboardActions: KeyboardActions = KeyboardActions(), errorMessage: String = "", focusRequester: FocusRequester = FocusRequester.Default, focusOnShow: Boolean = false, isTextValid: (String) -> Boolean = { true }, onInput: (String) -> Unit = {})

Adds an input field with the given parameters to the dialog

listItems
Link copied to clipboard
@Composable
fun <T> MaterialDialogScope.listItems(modifier: Modifier = Modifier, list: List<T>, closeOnClick: Boolean = true, onClick: (index: Int, T) -> Unit = { _, _ -> }, isEnabled: (index: Int) -> Boolean = { _ -> true }, item: @Composable (index: Int, T) -> Unit)

Adds a selectable list with custom items to the dialog

@Composable
fun MaterialDialogScope.listItems(list: List<String>, closeOnClick: Boolean = true, onClick: (index: Int, item: String) -> Unit = { _, _ -> })

Adds a selectable plain text list to the dialog

listItemsMultiChoice
Link copied to clipboard
@Composable
fun MaterialDialogScope.listItemsMultiChoice(list: List<String>, disabledIndices: Set<Int> = setOf(), initialSelection: Set<Int> = setOf(), waitForPositiveButton: Boolean = true, onCheckedChange: (indices: Set<Int>) -> Unit = {})

Adds a multi-choice list view to the dialog

listItemsSingleChoice
Link copied to clipboard
@Composable
fun MaterialDialogScope.listItemsSingleChoice(list: List<String>, disabledIndices: Set<Int> = setOf(), initialSelection: Int? = null, waitForPositiveButton: Boolean = true, onChoiceChange: (selected: Int) -> Unit = {})

Adds a single-choice list view to the dialog

message
Link copied to clipboard
@Composable
fun MaterialDialogScope.message(text: String? = null, @StringRes res: Int? = null)

Adds paragraph of text to the dialog

title
Link copied to clipboard
@Composable
fun MaterialDialogScope.title(text: String? = null, @StringRes res: Int? = null, center: Boolean = false)

Adds a title with the given text to the dialog