Hi there, I have a question regarding iOS during C...
# compose-ios
h
Hi there, I have a question regarding iOS during CMP development. The CMP version I'm using is
1.8.0
, and for multiplatform-navigation, it's
2.9.0-beta01
. The problem is that when using
androidx.compose.ui.window.Dialog
in
commonMain
, the dialog no longer appears after using features like an
in-app browser
or the
native camera
. Is there a way to solve this? this code working in cmp
1.7.3
, navigation
2.8.0-alpha10
Below is the test code:
Copy code
NavHost(
    navController = navController,
    startDestination = startDestination,
) {
    composable(route = "home") {
        Home()
    }
}

@Composable
private fun Home() {
    var openDialog by remember { mutableStateOf(false) }

    Column(
        modifier = Modifier
            .systemBarsPadding()
            .fillMaxWidth(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Text("Home")

        Button(
            onClick = { openDialog = true }
        ) {
            Text("Open Dialog")
        }

        Button(
            onClick = { PlatformInAppBrowserController.launch("<https://blog.jetbrains.com/kotlin/2025/05/compose-multiplatform-1-8-0-released-compose-multiplatform-for-ios-is-stable-and-production-ready/>") }
        ) {
            Text("Open inAppBrowser")
        }
    }

    if (openDialog) {
        Dialog(
            onDismissRequest = { openDialog = false },
            properties = DialogProperties(
                dismissOnBackPress = true,
                dismissOnClickOutside = true,
                usePlatformDefaultWidth = true
            )
        ) {
            Box(
                modifier = Modifier.fillMaxWidth()
                    .background(Color(0xFFFFFFFF))
                    .padding(40.dp)
            ) {
                Text(
                    text = "Home Dialog"
                )
            }
        }
    }
}
PlatformInAppBrowserController.ios.kt
:
Copy code
actual object PlatformInAppBrowserController {

    private var lastPresentViewController: SFSafariViewController? = null

    private val rootViewController: UIViewController?
        get() = UIApplication.sharedApplication.keyWindow?.rootViewController

    actual fun launch(url: String) {
        val rootViewController = rootViewController ?: return
        val viewController = NSURL.URLWithString(url)?.let { nsUrl -> SFSafariViewController(nsUrl) } ?: return
        viewController.modalPresentationStyle = UIModalPresentationFullScreen
        lastPresentViewController = viewController

        rootViewController.presentViewController(
            viewControllerToPresent = viewController,
            animated = true,
            completion = {},
        )
    }
}
i
The problem is that when using
androidx.compose.ui.window.Dialog
in
commonMain
, the dialog no longer appears after using features like an
in-app browser
or the
native camera
.
This scenario should definitely work. Could you please file a bug to our tracker? https://youtrack.jetbrains.com/newIssue?project=CMP
👀 1
1
i
👍🏼 1