diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 3a4f6d153587f5..8cc55ffe5727d2 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -95,8 +95,7 @@ export type Props = $ReadOnly<{| /** * The `onRequestClose` callback is called when the user taps the hardware - * back button on Android, the menu button on Apple TV, or a modal is dismissed - * with a gesture on iOS 13+. + * back button on Android or the menu button on Apple TV. * * This is required on Apple TV and Android. * diff --git a/Libraries/Modal/RCTModalHostViewNativeComponent.js b/Libraries/Modal/RCTModalHostViewNativeComponent.js index 43428715b8461a..9363a3b98d3c46 100644 --- a/Libraries/Modal/RCTModalHostViewNativeComponent.js +++ b/Libraries/Modal/RCTModalHostViewNativeComponent.js @@ -70,8 +70,7 @@ type NativeProps = $ReadOnly<{| /** * The `onRequestClose` callback is called when the user taps the hardware - * back button on Android, the menu button on Apple TV, or a modal is dismissed - * with a gesture on iOS 13+. + * back button on Android or the menu button on Apple TV. * * This is required on Apple TV and Android. * diff --git a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 9b610dfaefe9bd..0da7300e45f1a3 100644 --- a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -91,9 +91,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r return {orientation}; } -@interface RCTModalHostViewComponentView () < - RCTFabricModalHostViewControllerDelegate, - UIAdaptivePresentationControllerDelegate> +@interface RCTModalHostViewComponentView () @end @@ -112,7 +110,6 @@ - (instancetype)initWithFrame:(CGRect)frame _viewController = [RCTFabricModalHostViewController new]; _viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; _viewController.delegate = self; - _viewController.presentationController.delegate = self; } return self; @@ -217,17 +214,4 @@ - (void)unmountChildComponentView:(UIView *)childCompo [childComponentView removeFromSuperview]; } -#pragma mark - UIAdaptivePresentationControllerDelegate - -- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController -{ - if (!_eventEmitter) { - return; - } - - assert(std::dynamic_pointer_cast(_eventEmitter)); - auto eventEmitter = std::static_pointer_cast(_eventEmitter); - eventEmitter->onRequestClose({}); -} - @end diff --git a/React/Views/RCTModalHostView.h b/React/Views/RCTModalHostView.h index 6a35fb29565e25..e16dd222b50fe0 100644 --- a/React/Views/RCTModalHostView.h +++ b/React/Views/RCTModalHostView.h @@ -32,9 +32,8 @@ @property (nonatomic, copy) NSArray *supportedOrientations; @property (nonatomic, copy) RCTDirectEventBlock onOrientationChange; -@property (nonatomic, copy) RCTDirectEventBlock onRequestClose; - #if TARGET_OS_TV +@property (nonatomic, copy) RCTDirectEventBlock onRequestClose; @property (nonatomic, strong) RCTTVRemoteHandler *tvRemoteHandler; #endif diff --git a/React/Views/RCTModalHostView.m b/React/Views/RCTModalHostView.m index 9b767155def6c5..95d572bf3eb352 100644 --- a/React/Views/RCTModalHostView.m +++ b/React/Views/RCTModalHostView.m @@ -20,10 +20,6 @@ #import "RCTTVRemoteHandler.h" #endif -@interface RCTModalHostView () - -@end - @implementation RCTModalHostView { __weak RCTBridge *_bridge; @@ -50,7 +46,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge UIView *containerView = [UIView new]; containerView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; _modalViewController.view = containerView; - _modalViewController.presentationController.delegate = self; _touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge]; #if TARGET_OS_TV _menuButtonGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuButtonPressed:)]; @@ -75,12 +70,10 @@ - (void)menuButtonPressed:(__unused UIGestureRecognizer *)gestureRecognizer _onRequestClose(nil); } } -#endif - (void)setOnRequestClose:(RCTDirectEventBlock)onRequestClose { _onRequestClose = onRequestClose; - #if TARGET_OS_TV if (_reactSubview) { if (_onRequestClose && _menuButtonGestureRecognizer) { [_reactSubview addGestureRecognizer:_menuButtonGestureRecognizer]; @@ -88,8 +81,8 @@ - (void)setOnRequestClose:(RCTDirectEventBlock)onRequestClose [_reactSubview removeGestureRecognizer:_menuButtonGestureRecognizer]; } } - #endif } +#endif - (void)notifyForBoundsChange:(CGRect)newBounds { @@ -264,11 +257,4 @@ - (UIInterfaceOrientationMask)supportedOrientationsMask } #endif -- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController -{ - if (_onRequestClose) { - _onRequestClose(nil); - } -} - @end diff --git a/React/Views/RCTModalHostViewManager.m b/React/Views/RCTModalHostViewManager.m index 9c0d13c478f341..44f9ac9d2dac08 100644 --- a/React/Views/RCTModalHostViewManager.m +++ b/React/Views/RCTModalHostViewManager.m @@ -108,6 +108,9 @@ - (void)invalidate RCT_EXPORT_VIEW_PROPERTY(identifier, NSNumber) RCT_EXPORT_VIEW_PROPERTY(supportedOrientations, NSArray) RCT_EXPORT_VIEW_PROPERTY(onOrientationChange, RCTDirectEventBlock) + +#if TARGET_OS_TV RCT_EXPORT_VIEW_PROPERTY(onRequestClose, RCTDirectEventBlock) +#endif @end