IDK if it's related (and I'm not sure if this was ...
# compose-ios
n
IDK if it's related (and I'm not sure if this was the same behaviour with previous versions), but with CMP 1.10.3, I hit a similar issue with a WKWebView embedded in a CMP Dialog. Context : I show a video player iframe in a
WKWebview
, and when I set the video fullscreen, the native iOS fullscreen was displayed below my Dialog. I found a quick & dirty fix by manually updating the new Window level when the web view is visible.
Copy code
/**
 * Intercept fullscreen to display it above a CMP Dialog.
 */
@Composable
internal fun WebFullScreenInterceptor() {
    val uiViewController = LocalUIViewController.current
    val windowLevel = remember(uiViewController) {
        uiViewController.view.window?.windowLevel ?: 0.0
    }

    DisposableEffect(windowLevel) {
        val observer = WebFullScreenInterceptorObject(windowLevel)
        observer.startObserving()
        onDispose { observer.stopObserving() }
    }
}

private class WebFullScreenInterceptorObject(private val cmpWindowLevel: Double): NSObject() {
    private var observer: NSObjectProtocol? = null

    fun startObserving() {
        observer = NSNotificationCenter.defaultCenter.addObserverForName(
            name = UIWindowDidBecomeVisibleNotification,
            `object` = null,
            queue = NSOperationQueue.mainQueue,
        ) { notification ->
            val window = notification?.`object` as? UIWindow ?: return@addObserverForName

            if(window.windowLevel > UIWindowLevelNormal) {
                window.windowLevel = cmpWindowLevel + 1
            }
        }
    }

    fun stopObserving() {
        observer?.let { NSNotificationCenter.defaultCenter.removeObserver(it) }
        observer = null
    }
}
a
@Nicolas Patin, yeah, there where lots of complains - we updated the modal dialog behavior one more time in 1.11 - it should be better now.
👀 1
c
I think the only change really is to make sure you're using UIKitInteropProperties
placedAsOverlay = true
if placing a native view in a dialog. Otherwise you get some awkward flashing from the UI punchout as the dialog is animating in