Vsevolod Ganin
01/09/2021, 3:22 PMpointerInput
? It doesn’t react on lambda changes and always use only first served lambda. Below prints only pointerInput 2
and doesn’t print anything on switch toggle.
@Preview
@Composable
fun PointInputTest() {
var toggled: Boolean by remember { mutableStateOf(false) }
Column {
Switch(checked = toggled, onCheckedChange = { toggled = !toggled })
Box(
modifier = Modifier
.size(50.dp)
.background(Color.Red)
.run {
if (toggled) {
pointerInput {
println("pointerInput 1")
}
} else {
pointerInput {
println("pointerInput 2")
}
}
}
)
}
}
Adam Powell
01/09/2021, 5:50 PMModifier.composed {}
modifiers work plus the current implementation decision to not re-launch pointerInput {}
modifiers on lambda capture change. Some of this predates the rememberUpdatedState
API which solves some of the use cases that the original decision not to re-launch was targeting, so it might be worth us re-evaluating it.Adam Powell
01/09/2021, 5:50 PMAdam Powell
01/09/2021, 5:51 PMVsevolod Ganin
01/09/2021, 6:04 PM