Stylianos Gakis
02/25/2023, 9:15 PMcalculateWindowSizeClass
properly.Stylianos Gakis
02/25/2023, 9:16 PMval sideSpacingModifier = if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded) {
Modifier
.fillMaxWidth(0.8f)
.wrapContentWidth(Alignment.Start)
.align(Alignment.CenterHorizontally)
} else {
Modifier.padding(horizontal = 16.dp)
}
And then in my column of items I do something like this
Column {
Composable1(..., sideSpacingModifier)
Composable2(sideSpacingModifier)
Composable3(Modifier.height(x.dp))
Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)))
}
Do you find yourself doing something like this too? I haven’t seen a lot of code which handles wider screens, aside from those sample apps which change the entire layout completely, like showing more columns instead of just 1, but it isn’t always appropriate for what I may be doing.Alex Vanyo
02/26/2023, 8:34 PMwindowSizeClass
to make decisions based on the overall app layout. From a design perspective, that'd be the overall layout of a screen based on a certain amount of available size. For simper screens, you might only need to change the spacing or alignment, like in your case.
At the same time, individual components should also be responsive and not care too much about how much screen space is available, it should be more about the "local" space available.Alex Vanyo
02/26/2023, 8:40 PMMyProjectButton
, and it internally was making some decision based on the window size class, that'd be a bit suspicious to me. Why is a specific reusable button changing completely based on the overall screen size?
It might be that the design calls for a different arrangement at some screen size, in which case it might make sense to "hoist" that logic outside of a reusable button to keep it closer together with that other logic.Alex Vanyo
02/26/2023, 8:43 PMwindowSizeClass
gets passed down the composable tree, the more suspicious I'd become. At some point, it'd probably be better to "manifest" a specific, named decision based upon the windowSizeClass
(use this alignment, or this padding) then to keep passing it down further and furtherStylianos Gakis
02/26/2023, 9:31 PM