https://kotlinlang.org logo
Title
s

Stylianos Gakis

08/16/2022, 2:29 PM
When using a LazyColumn we got access to
contentPadding
which is super convenient to do smth like this
LazyColumn(contentPadding = WindowInsets.safeDrawing.asPaddingValues())
. However when working with something that does not provide this convenient
contentPadding
parameter, one has to do something like this instead
Column(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)).verticalScroll(rememberScrollState())) {
  Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(<http://WindowInsetsSides.Top|WindowInsetsSides.Top>)))
  Stuff()
  Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)))
}
Is this simply the way to go or am I missing some API?
a

Albert Chang

08/16/2022, 3:08 PM
Modifier order matters so you can just use
Column(Modifier.verticalScroll().safeDrawingPadding())
.
s

Stylianos Gakis

08/16/2022, 3:32 PM
Modifier ordering is still something that trips me up sometimes 😅 Thanks a lot, this is exactly what I was trying to go for! Had to change
safeDrawingPadding
with
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom))
since I had a TopAppBar above which was handling the top insets and it now looks exactly how I wanted it to 👌 Thanks a lot!
c

Colton Idle

08/17/2022, 3:43 PM
Am I missing something? I'm still using accompanist insets, but I just use modifier.statusBarPadding on top and navigationBarPadding for the bottom.
s

Stylianos Gakis

08/17/2022, 4:18 PM
How does that work for you when you rotate the screen and the status bars are navigation bar is now on the left/right?
c

Colton Idle

08/17/2022, 4:22 PM
status bars on the left/right? I don't think I've ever seen that.
s

Stylianos Gakis

08/17/2022, 4:22 PM
I meant navigation bar 🙈
c

Colton Idle

08/17/2022, 4:24 PM
Oh. Hm. I guess I've never taken that into account. TIL!
s

Stylianos Gakis

08/17/2022, 7:41 PM
Try you app in landscape and specifically the 3 button navigation (because it's much thicker than the gesture navigation) if you're not handling this at all, you'll probably figure out some things are not clickable at all, some text may be ineligible and/or in general the UI might look super ugly.