mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 06:52:57 +00:00
add dialog with default button
This commit is contained in:
parent
e2ebd32f25
commit
31b2a36bcc
10 changed files with 183 additions and 82 deletions
|
@ -32,7 +32,7 @@ fun SliderDialog(
|
|||
range: ClosedFloatingPointRange<Float>,
|
||||
modifier: Modifier = Modifier,
|
||||
showDefault: Boolean = false,
|
||||
onDefault: () -> Unit? = { },
|
||||
onDefault: () -> Unit = { },
|
||||
onValueChanged: (Float) -> Unit = { },
|
||||
title: (@Composable () -> Unit)? = null,
|
||||
intermediateSteps: Int? = null,
|
||||
|
@ -44,21 +44,11 @@ fun SliderDialog(
|
|||
) {
|
||||
var sliderPosition by remember { mutableFloatStateOf(initialValue) }
|
||||
|
||||
AlertDialog(
|
||||
ThreeButtonAlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
confirmButton = { // mis-use the confirm button and put everything in there
|
||||
Row {
|
||||
if (showDefault)
|
||||
TextButton(
|
||||
onClick = { onDismissRequest(); onDefault() }
|
||||
) { Text(stringResource(R.string.button_default)) }
|
||||
Spacer(modifier.weight(1f))
|
||||
TextButton(onClick = onDismissRequest) { Text(stringResource(android.R.string.cancel)) }
|
||||
TextButton(
|
||||
onClick = { onDismissRequest(); onDone(sliderPosition) },
|
||||
) { Text(stringResource(android.R.string.ok)) }
|
||||
}
|
||||
},
|
||||
neutralButtonText = if (showDefault) stringResource(R.string.button_default) else null,
|
||||
onNeutral = onDefault,
|
||||
onConfirmed = { onDone(sliderPosition) },
|
||||
modifier = modifier,
|
||||
title = title,
|
||||
text = {
|
||||
|
@ -86,8 +76,8 @@ fun SliderDialog(
|
|||
}
|
||||
},
|
||||
shape = shape,
|
||||
containerColor = backgroundColor,
|
||||
textContentColor = contentColor,
|
||||
backgroundColor = backgroundColor,
|
||||
contentColor = contentColor,
|
||||
properties = properties,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue