JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.3k stars 1.18k forks source link

WindowInsets.statusBars in version 1.5.10 #3901

Closed k-kertykamary closed 1 year ago

k-kertykamary commented 1 year ago

Hello :),

With the following dependency versions:

kotlin.version=1.9.10
agp.version=8.1.2
compose.version=1.5.3

I observe the following behavior:

val top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
println("TOP == $top")
=====> 59.dp (on iOS)

However, when you switch to the following dependency versions:

kotlin.version=1.9.20
agp.version=8.1.2
compose.version=1.5.10

The behavior changes to:

val top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
println("TOP == $top")
=====> 0.dp (on iOS)
MatkovIvan commented 1 year ago

Hi @k-kertykamary,

Just re-checked - it works as expected. You probably trying to get it inside Popup/Dialog. In the last version, we fixed the behavior of WindowInsets inside Popup/Dialog - it zeroed to avoid double application and match Android behavior now.

Closing this for now, but if it's not your case, please let me know.

k-kertykamary commented 1 year ago

Hi @MatkovIvan , Thank's !!! :) Yes, that's right. I'm trying to add a top padding to a Row with that value in a Popup. If it's reset to zero in the new version, how can I retrieve that value in iOS ? Thank you

MatkovIvan commented 1 year ago

Popup is inside safe area by default, you don't need to add this padding explicitly. That's why it is zero now.

how can I retrieve that value in iOS

As I said, you probably don't need to do that - WindowInsets is not simple constant padding; it has de-duplication logic under the hood. But if you really need that, you can use the same method as on Android - just read the value outside Popup but apply inside. In this case, you most likely are using the wrong tools to achieve your goal. Could you please describe your use case?

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.