Mohamed Elfiky
09/09/2020, 8:19 PMZach Klippenstein (he/him) [MOD]
09/09/2020, 8:20 PMMohamed Elfiky
09/09/2020, 8:25 PMZach Klippenstein (he/him) [MOD]
09/09/2020, 8:28 PMWithConstraints
uses it, yes. I haven’t seen any good docs on it, and the APIs seem to still be changing quite a bit.WithConstraints
uses it because it can’t compose its children until it knows the constraints, but it can’t know the constraints until the composition pass is done and the layout pass is happening. Since it can’t just compose its children directly, it waits until the layout happens, then creates a new composition for its content that is linked to its position in the original composition. This subcomposition gets ambients and everything from the parent, so if you wrap WithConstraints
with a Providers
it will jsut work.LazyColumnFor
uses it as well, but for a different use case – laziness. It doesn’t compose any of its children at first. Then, when it’s laid out, it sees how much space it has, then creates a subcomposition for the first child. If there’s more space it needs to fill, it creates a subcomposition for its second child, etc. When a child is scrolled out of view, it disposes the subcomposition for that child, so only the children which are actually visible are ever being composed.Mohamed Elfiky
09/09/2020, 8:42 PMZach Klippenstein (he/him) [MOD]
09/09/2020, 8:50 PMDialog()
composable, it actually launches a regular Android dialog in a separate window and everything, and then it composes its content in that dialog as a subcomposition. So the compositions are effectively the same, even though part of it is rendering to an entirely different window.Mohamed Elfiky
09/09/2020, 9:05 PM