Skip to content

Commit

Permalink
fix: Prevent file-viewer to interfere with LockScreen inputs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ldoppea committed Dec 19, 2022
1 parent ed60b61 commit 9f869e5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions patches/react-native-file-viewer+2.1.5.patch
Original file line number Diff line number Diff line change
@@ -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<NSString *> *)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}];
}];
}

0 comments on commit 9f869e5

Please sign in to comment.