Shakil Karim
03/14/2021, 12:28 PMAdam Powell
03/14/2021, 2:35 PMShakil Karim
03/14/2021, 4:18 PMAdam Powell
03/14/2021, 4:24 PMalphaFraction
being a composable function parameter before it is provided to the graphicsLayer
block is likely causing a lot of recomposition whenever alpha changes. I'll bet you'll see a difference if you pass that as getAlphaFraction: () -> Float
instead, graphicsLayer
can pull the value in the places it's used when it changes (presuming you pass something like { computeBasedOn(someSnapshotState.value) }
) rather than using recomposition to push new valuesAdam Powell
03/14/2021, 4:25 PM.graphicsLayer {
alpha = getAlpha() // call the provided function here
}
and these graphicsLayer
blocks would be the only places where that function is actually calledShakil Karim
03/14/2021, 5:25 PMShakil Karim
03/14/2021, 5:27 PMAdam Powell
03/14/2021, 5:29 PM.then(alphaModifier)
Adam Powell
03/14/2021, 5:30 PMval getAlpha = { (1f - collapseFraction).coerceIn(0f, 1f) }
would turn into
val alphaModifier = Modifier.graphicsLayer { alpha = (1f - collapseFraction).coerceIn(0f, 1f) }
Adam Powell
03/14/2021, 5:31 PMShakil Karim
03/14/2021, 5:42 PMAdam Powell
03/14/2021, 6:18 PM