From 9f473b72043e9285d4f82c42742f690afe7efa27 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Fri, 16 Dec 2022 10:37:56 +0100 Subject: [PATCH] fix: Prevent file-viewer to interfere with LockScreen inputs Now that the Lock screen is wrapped inside a FullWindowOverlay we ensure it is displayed on top of every other elements However, as the react-native-file-viewer instantiate a QuickLook controller using fullScreen, we encounter a bug that prevent any interaction with the Lock screen even if it is visible By forcing the QuickLook controller to be displayed as a modal, the interaction bug does not happens anymore This is an acceptable solution as the modal view fits the iOS UI trends which users are used to An issue has been created on react-native-screen project in order to understand why this bug happens when using a fullScreen controller Related issue: software-mansion/react-native-screens#1666 --- patches/react-native-file-viewer+2.1.5.patch | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 patches/react-native-file-viewer+2.1.5.patch diff --git a/patches/react-native-file-viewer+2.1.5.patch b/patches/react-native-file-viewer+2.1.5.patch new file mode 100644 index 000000000..92ebfa27b --- /dev/null +++ b/patches/react-native-file-viewer+2.1.5.patch @@ -0,0 +1,36 @@ +diff --git a/node_modules/react-native-file-viewer/ios/RNFileViewerManager.m b/node_modules/react-native-file-viewer/ios/RNFileViewerManager.m +index 8149cac..6ea97af 100644 +--- a/node_modules/react-native-file-viewer/ios/RNFileViewerManager.m ++++ b/node_modules/react-native-file-viewer/ios/RNFileViewerManager.m +@@ -102,6 +102,12 @@ - (void)previewControllerDidDismiss:(CustomQLViewController *)controller { + [self sendEventWithName:DISMISS_EVENT body: @{@"id": controller.invocation}]; + } + ++- (void)dismissView:(id)sender { ++ UIViewController* controller = [RNFileViewer topViewController]; ++ [self sendEventWithName:DISMISS_EVENT body: @{@"id": ((CustomQLViewController*)controller).invocation}]; ++ [[RNFileViewer topViewController] dismissViewControllerAnimated:YES completion:nil]; ++} ++ + RCT_EXPORT_MODULE() + + - (NSArray *)supportedEvents { +@@ -117,8 +123,17 @@ - (void)previewControllerDidDismiss:(CustomQLViewController *)controller { + QLPreviewController *controller = [[CustomQLViewController alloc] initWithFile:file identifier:invocationId]; + controller.delegate = self; + ++ if (@available(iOS 13.0, *)) { ++ [controller setModalInPresentation: true]; ++ } ++ ++ UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller]; ++ controller.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView:)]; ++ controller.navigationController.navigationBar.translucent = NO; ++ controller.edgesForExtendedLayout = UIRectEdgeNone; ++ + typeof(self) __weak weakSelf = self; +- [[RNFileViewer topViewController] presentViewController:controller animated:YES completion:^{ ++ [[RNFileViewer topViewController] presentViewController:navigationController animated:YES completion:^{ + [weakSelf sendEventWithName:OPEN_EVENT body: @{@"id": invocationId}]; + }]; + }