Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS 18 cool-modals context menu bug #6112

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
31 changes: 17 additions & 14 deletions src/react-native-cool-modals/ios/RNCMScreen.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// lib
#import "Rainbow-Swift.h"


@interface RNCMScreenView () <UIAdaptivePresentationControllerDelegate, RCTInvalidating>
@end

Expand Down Expand Up @@ -66,7 +65,6 @@ - (void)willDismiss {
- (void) setIsShortFormEnabled:(BOOL)isShortFormEnabled {
_isShortFormEnabled = isShortFormEnabled;
[(PanModalViewController*) [_controller parentVC] panModalSetNeedsLayoutUpdateWrapper];

}

- (void) layout {
Expand All @@ -83,7 +81,6 @@ - (void) setHidden:(BOOL)hidden {
}
[(PanModalViewController*) [_controller parentVC] hide];
});

}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -426,7 +435,6 @@ @implementation RNCMScreenManager
}
[(RNCMScreenView *) view jumpTo:point];
}];

}

RCT_EXPORT_METHOD(layout:(nonnull NSNumber*) reactTag) {
Expand All @@ -438,10 +446,8 @@ @implementation RNCMScreenManager
}
[(RNCMScreenView *) view layout];
}];

}


RCT_EXPORT_MODULE()

RCT_EXPORT_VIEW_PROPERTY(gestureEnabled, BOOL)
Expand Down Expand Up @@ -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];
Expand All @@ -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

Loading