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
15.88k stars 1.15k forks source link

Display cutout WindowInset do not work in landscape mode on iOS #4045

Open Mats-Hjalmar opened 8 months ago

Mats-Hjalmar commented 8 months ago

Describe the bug WindowInset.displayCutout behaves like the camera is on both sides in the or none depending on what side you want calculated. (in Both layout directions)

Affected platforms

Versions

To Reproduce

@Composable
internal fun App() = AppTheme {
    val rightCameraPadding =
        WindowInsets.displayCutout
            .asPaddingValues()
            .calculateRightPadding(LayoutDirection.Ltr)
    Box(
        Modifier.fillMaxSize()
            .padding(end = rightCameraPadding)
            .background(Color.Red)
    )
}

Expected behavior The padding value should be 0 if there is no camera on the right side.

Screenshots

image

Additional context This do not work either (left display cutout values with app in landscape)

image
terrakok commented 8 months ago

Do you have this code on the ios app side?

struct ContentView: View {
    var body: some View {
        ComposeView().ignoresSafeArea(.all)
    }
}
terrakok commented 8 months ago

Because I don't see the initial problem but found another one: If to rotate app through an up side down state then insets won't be updated

@Composable
internal fun App() = AppTheme {
    Box(
        Modifier
            .fillMaxSize()
            .windowInsetsPadding(WindowInsets.displayCutout)
            .background(Color.Red)
    ) {
        Text("TEXT")
    }
}
image image image image
Mats-Hjalmar commented 8 months ago

Do you have this code on the ios app side?

struct ContentView: View {
    var body: some View {
        ComposeView().ignoresSafeArea(.all)
    }
}

That is exactly my code.

Mats-Hjalmar commented 8 months ago

Because I don't see the initial problem but found another one: If to rotate app through an up side down state then insets won't be updated

@Composable
internal fun App() = AppTheme {
    Box(
        Modifier
            .fillMaxSize()
            .windowInsetsPadding(WindowInsets.displayCutout)
            .background(Color.Red)
    ) {
        Text("TEXT")
    }
}

image image image image

Quite amazing edge case. Any idea how to fix it?

okushnikov commented 2 weeks ago

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