MaterialDialogScope

interface MaterialDialogScope

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

Functions

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

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

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

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

Link copied to clipboard
abstract fun reset()

Clears the dialog's state

Link copied to clipboard
abstract fun submit()

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

Properties

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

Extensions

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

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

Link copied to clipboard
fun MaterialDialogScope.iconTitle(    text: String? = null,     @StringRes textRes: Int? = null,     color: Color = MaterialTheme.colors.onSurface,     style: TextStyle = MaterialTheme.typography.h6,     icon: @Composable () -> Unit = {})

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

Link copied to clipboard
fun MaterialDialogScope.input(    modifier: Modifier = Modifier,     label: String,     placeholder: String = "",     prefill: String = "",     enabled: Boolean = true,     readOnly: Boolean = false,     textStyle: TextStyle = LocalTextStyle.current,     leadingIcon: @Composable () -> Unit? = null,     trailingIcon: @Composable () -> Unit? = null,     visualTransformation: VisualTransformation = VisualTransformation.None,     keyboardOptions: KeyboardOptions = KeyboardOptions.Default,     keyboardActions: KeyboardActions = KeyboardActions(),     singleLine: Boolean = false,     maxLines: Int = Int.MAX_VALUE,     interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },     colors: TextFieldColors = TextFieldDefaults.textFieldColors(),     textFieldStyle: TextFieldStyle = TextFieldStyle.Filled,     waitForPositiveButton: Boolean = true,     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

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

Adds a selectable list with custom items to the dialog

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

Adds a selectable plain text list to the dialog

Link copied to clipboard
fun MaterialDialogScope.listItemsMultiChoice(    list: List<String>,     state: LazyListState = rememberLazyListState(),     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

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

Adds a single-choice list view to the dialog

Link copied to clipboard
fun MaterialDialogScope.message(    text: String? = null,     color: Color = MaterialTheme.colors.onSurface,     style: TextStyle = MaterialTheme.typography.body1,     @StringRes res: Int? = null)

Adds paragraph of text to the dialog

Link copied to clipboard
fun MaterialDialogScope.title(    text: String? = null,     @StringRes res: Int? = null,     color: Color = MaterialTheme.colors.onSurface,     style: TextStyle = MaterialTheme.typography.h6,     center: Boolean = false)

Adds a title with the given text to the dialog