Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ios/RNFileViewerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -116,9 +122,18 @@ - (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}];
}];
}
Expand Down