Heehoon Jeon
05/07/2025, 5:27 AM1.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:
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
:
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 = {},
)
}
}
Ivan Matkov
05/07/2025, 6:46 AMThe problem is that when usingThis scenario should definitely work. Could you please file a bug to our tracker? https://youtrack.jetbrains.com/newIssue?project=CMPinandroidx.compose.ui.window.Dialog
, the dialog no longer appears after using features like ancommonMain
or thein-app browser
.native camera
Heehoon Jeon
05/07/2025, 7:12 AMIvan Matkov
05/07/2025, 8:55 AM