
AlertDialog
In Material 3 Compose@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SliderWithCustomThumbSample() {
val sliderState = rememberSliderState(trackRange = 0f..100f)
val interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
Slider(
state = sliderState,
onValueChange = { sliderState.value = it },
interactionSource = interactionSource,
onValueChangeFinished = {
// launch some business logic update with the state you hold
// viewModel.updateSelectedSliderValue(sliderPosition)
},
thumb = {
Label(
label = {
PlainTooltip(modifier = Modifier.sizeIn(45.dp, 25.dp).wrapContentWidth()) {
Text("%.2f".format(sliderState.value))
}
},
interactionSource = interactionSource,
) {
Icon(
imageVector = Icons.Filled.Favorite,
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize),
tint = Color.Red,
)
}
},
)
}
}