zt
07/09/2025, 11:21 AMhue
, saturation
, or value
params change. But if their type to a lambda producing a float, () -> Float
, there's no recomposing and its skipped. I'm curious why this works and if it's good to do this change.
@Composable
public fun RingColorPicker(
hue: Float,
saturation: Float = 1f,
value: Float = 1f,
onHueChange: (Float) -> Unit,
modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
ringStrokeWidth: Dp = 16.dp,
thumb: @Composable () -> Unit = {
ColorPickerDefaults.Thumb(Color.hsv(hue, saturation, value), interactionSource)
},
onColorChangeFinished: () -> Unit = {}
)
shikasd
07/09/2025, 1:06 PMzt
07/09/2025, 1:16 PMvar hue by remember { mutableStateOf(90f) }
RingColorPicker(
hue = { hue },
onHueChange = { hue = it }
)
shikasd
07/09/2025, 1:27 PMshikasd
07/09/2025, 1:28 PM