After using VNDocumentCameraViewController in Compose Multiplatform iOS, all popup-based components (AlertDialog, DatePickerDialog, ExposedDropdownMenuBox) stop working.
- Open AlertDialog - works fine
- Open VNDocumentCameraViewController scanner
- Close scanner
- Try to open AlertDialog again - doesn't show
This is my code:
@Composable actual fun rememberDocumentScanner( onResult: (Result<List<KmpImage>>) -> Unit, options: DocumentScannerOptions ): DocumentScanner { val localViewController = LocalUIViewController.current return object : DocumentScanner { override fun scan() { val controller = VNDocumentCameraViewController() controller.setDelegate( DocumentScannerDelegate( onError = { controller.dismissViewControllerAnimated(true) { restoreComposeWindow(localViewController) } // error handling }, onCancel = { controller.dismissViewControllerAnimated(true) { restoreComposeWindow(localViewController) } }, onResult = { result -> controller.dismissViewControllerAnimated(true) { restoreComposeWindow(localViewController) } // result handling } ) ) localViewController.presentViewController(controller, animated = true) { // scanner configuration } } } } fun restoreComposeWindow(localViewController: UIViewController?) { val view = localViewController?.view ?: return view.setNeedsLayout() view.layoutIfNeeded() view.setNeedsDisplay() } - OK Scanner opens and works perfectly
- OK Regular UI components (TextField, Button, Navigation) work fine
- FAIL AlertDialog - doesn't show after scanner
- FAIL DatePickerDialog - doesn't show after scanner
- FAIL ExposedDropdownMenuBox - doesn't show after scanner
- FAIL All popup-based components fail