UI
Dialog
BaseDialog
Composable of a basic dialog. Javadoc documentation
Example:
@Composable
private fun BaseDialogPreview() {
val state = rememberDialogState()
state.show()
Surface {
BaseDialog(state) {
Column {
DialogTitle("Example Dialog")
Box(
modifier = Modifier.padding(horizontal = MaterialTheme.spacing.dialogHalf)
) {
Text("Some text")
}
}
}
}
}
PickerDialog
Dialog with a list of elements to select. Javadoc documentation
Example:
@Composable
private fun PickerDialogPreview() {
val state = rememberDialogState()
state.show()
val items = listOf("First", "Second", "Third")
Surface {
PickerDialog(
state,
title = "Example Picker Dialog",
items = items,
onSelected = {}
) {
Text(
text = it,
modifier = Modifier
.padding(vertical = MaterialTheme.spacing.dialogHalf)
.fillMaxWidth()
)
}
}
}
Preference
BasicPreference
Basic preference entry. Javadoc documentation
Example:
@Composable
fun BasicPreferenceExample() {
BasicPreference(
title = "Settings",
subtitle = "Switch to settings screen",
onClick = { println("Clicked!") },
leading = {
IconBox(Icons.Default.Settings)
},
trailing = {
IconBox(Icons.Default.ArrowOutward)
}
)
}
PreferenceGroupTitle
Title component for a group of preferences. Javadoc documentation
Example:
@Composable
fun PreferenceGroupTitleExample() {
Column {
PreferenceGroupTitle("Group title")
SwitcherPreference(
title = "Switcher Preference",
checked = false,
onCheckedChange = {}
)
}
}
PropertyPreference
Preference entry with a property. Javadoc documentation
Example:
@Composable
fun PropertyPreferenceExample() {
val propertyItems = listOf("First", "Second", "Third")
val currentItem by rememberMutable(propertyItems[0])
PropertyPreference(
title = "Property title",
subtitle = "Property subtitle",
leading = {
IconBox(Icons.Default.Lock)
},
currentValue = currentItem,
onClick = { state.show() }
)
}
SwitcherPreference
Preference entry with a switcher. Javadoc documentation
Example:
@Composable
fun SwitcherPreferenceExample() {
val checked = rememberMutable(false)
SwitcherPreference(
title = "Switcher Preference",
checked = checked
)
}