What about Portrait vs Landscape with Compose ? Are we just going to build two Composables? What about tablets?
Leland Richardson [G]
07/20/2020, 7:06 PM
its kinda whatever you want. if the content is different enough that it warrants two different composables, go ahead and do that. I’ve found that that usually is not the case
its just like other functions
if the logic is different enough in the two cases that writing two different functions is more understandable, then that’s a reasonable thing to do
but its just as reasonable to do mostly the same thing in either case, but just have some values or ui be conditional
if (isLandscape) … else …
Sean McQuillan [G]
07/21/2020, 4:24 AM
If it's just something simple, an inline if statement works great. It's also practical to make two composables when the layouts are quite different.
This makes the code for responsive layout explicit (including compile time checks 🙂 )
Compose also lets you make even more responsive layouts not just driven by screen rotation – e.g. if the current composable has 800dp wide in it's current layout location site then swap to a different layout.