galex

    galex

    2 years ago
    What about Portrait vs Landscape with Compose ? Are we just going to build two Composables? What about tablets?
    l

    Leland Richardson [G]

    2 years ago
    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 …
    etc
    Sean McQuillan [G]

    Sean McQuillan [G]

    2 years ago
    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.
    galex

    galex

    2 years ago
    Makes sense, thanks