diff --git a/src/react-native-cool-modals/ios/RNCMScreen.m b/src/react-native-cool-modals/ios/RNCMScreen.m index fdd546b3143..36598655c64 100644 --- a/src/react-native-cool-modals/ios/RNCMScreen.m +++ b/src/react-native-cool-modals/ios/RNCMScreen.m @@ -9,7 +9,6 @@ // lib #import "Rainbow-Swift.h" - @interface RNCMScreenView () @end @@ -66,7 +65,6 @@ - (void)willDismiss { - (void) setIsShortFormEnabled:(BOOL)isShortFormEnabled { _isShortFormEnabled = isShortFormEnabled; [(PanModalViewController*) [_controller parentVC] panModalSetNeedsLayoutUpdateWrapper]; - } - (void) layout { @@ -83,7 +81,6 @@ - (void) setHidden:(BOOL)hidden { } [(PanModalViewController*) [_controller parentVC] hide]; }); - } } @@ -131,7 +128,6 @@ - (void)updateBounds [_bridge.uiManager setSize:self.bounds.size forView:self]; } - - (void)setPointerEvents:(RCTPointerEvents)pointerEvents { // pointer events settings are managed by the parent screen container, we ignore @@ -335,11 +331,14 @@ - (instancetype)initWithView:(UIView *)view - (void)presentModally:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion slackStack:(BOOL)slackStack { return [_parentVC presentModally:viewControllerToPresent animated:flag completion:completion slackStack:slackStack]; - } - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { - return [_parentVC dismissViewControllerAnimated:flag completion:completion]; + if (self.parentViewController) { + [self.parentViewController dismissViewControllerAnimated:flag completion:completion]; + } else { + [super dismissViewControllerAnimated:flag completion:completion]; + } } - (UIViewController *)presentedViewController { @@ -361,6 +360,16 @@ - (void)viewDidLayoutSubviews } } +- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion { + BOOL isContextMenu = [viewControllerToPresent isKindOfClass:NSClassFromString(@"_UIContextMenuActionsOnlyViewController")]; + + if (isContextMenu) { + [_parentVC presentViewController:viewControllerToPresent animated:flag completion:completion]; + } else { + [super presentViewController:viewControllerToPresent animated:flag completion:completion]; + } +} + - (id)findFirstResponder:(UIView*)parent { if (parent.isFirstResponder) { @@ -426,7 +435,6 @@ @implementation RNCMScreenManager } [(RNCMScreenView *) view jumpTo:point]; }]; - } RCT_EXPORT_METHOD(layout:(nonnull NSNumber*) reactTag) { @@ -438,10 +446,8 @@ @implementation RNCMScreenManager } [(RNCMScreenView *) view layout]; }]; - } - RCT_EXPORT_MODULE() RCT_EXPORT_VIEW_PROPERTY(gestureEnabled, BOOL) @@ -476,7 +482,6 @@ @implementation RNCMScreenManager RCT_EXPORT_VIEW_PROPERTY(ignoreBottomOffset, BOOL) RCT_EXPORT_VIEW_PROPERTY(hidden, BOOL) - - (UIView *)view { return [[RNCMScreenView alloc] initWithBridge:self.bridge]; @@ -494,15 +499,13 @@ @implementation RCTConvert (RNSScreen) @"containedModal": @(RNSScreenStackPresentationContainedModal), @"transparentModal": @(RNSScreenStackPresentationTransparentModal), @"containedTransparentModal": @(RNSScreenStackPresentationContainedTransparentModal) - }), RNSScreenStackPresentationPush, integerValue) +}), RNSScreenStackPresentationPush, integerValue) RCT_ENUM_CONVERTER(RNSScreenStackAnimation, (@{ @"default": @(RNSScreenStackAnimationDefault), @"none": @(RNSScreenStackAnimationNone), @"fade": @(RNSScreenStackAnimationFade), @"flip": @(RNSScreenStackAnimationFlip), - }), RNSScreenStackAnimationDefault, integerValue) - +}), RNSScreenStackAnimationDefault, integerValue) @end -