Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS use platformLayers=true by default #1031

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

dima-avdeev-jb
Copy link

@dima-avdeev-jb dima-avdeev-jb commented Jan 30, 2024

We changed default iOS behavior for Dialogs and Popups. Now they will be opened in new platfrom layer, and will be positioned on fully available Application size.
It means that you may use Compose as a small part of iOS Application, but Dialogs may be opened bigger that initial Compose size.

For example, let's use Compose as a small part of SwiftUI screen:

struct ContentView: View {
    var body: some View {
        ComposeView()
                .frame(width: 200, height: 200)
    }
}

And Kotlin Code:

    ComposeUIViewController {
        Box(Modifier.fillMaxSize().background(Color.Blue.copy(0.5f)))
    }
image

As you can see Compose layouts just in small rectangle inside SwiftUI.

Now, let's add Dialog to Kotlin Code to display Dialog:

    ComposeUIViewController {
        var isDialogOpened by remember { mutableStateOf(false) }
        Box(Modifier.fillMaxSize().background(Color.Blue.copy(0.5f))) {
            Button(onClick = { isDialogOpened = true }) {
                Text("Open Dialog")
            }
        }
        if (isDialogOpened) {
            Dialog(
                onDismissRequest = { isDialogOpened = false }
            ) {
                Box(Modifier.size(400.dp).background(Color.Yellow.copy(0.5f))) {
                    Text("I am Dialog")
                }
            }
        }
    }

And result will be:

image

Now, Dialogs and Popups may have size bigger than initial Compose view.

But also we provide ability to switch this behavior to old once with flag platfomLayer:

ComposeUIViewController(
        configure = {
            platformLayers = false
        }
    ) {
// your Compose code
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants