mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Revert D19235758: Implement onRequestClose for iOS 13+ modals
Differential Revision: D19235758 Original commit changeset: c0f1d946c77c fbshipit-source-id: c4a9d7876aa8d07ff5b8419f097b02e9c28e2880
This commit is contained in:
committed by
Eloy Durán
parent
360b53d77f
commit
8aeb5dc7ad
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -91,9 +91,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
|
||||
return {orientation};
|
||||
}
|
||||
|
||||
@interface RCTModalHostViewComponentView () <
|
||||
RCTFabricModalHostViewControllerDelegate,
|
||||
UIAdaptivePresentationControllerDelegate>
|
||||
@interface RCTModalHostViewComponentView () <RCTFabricModalHostViewControllerDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@@ -112,7 +110,6 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
|
||||
_viewController = [RCTFabricModalHostViewController new];
|
||||
_viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
|
||||
_viewController.delegate = self;
|
||||
_viewController.presentationController.delegate = self;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -217,17 +214,4 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
|
||||
[childComponentView removeFromSuperview];
|
||||
}
|
||||
|
||||
#pragma mark - UIAdaptivePresentationControllerDelegate
|
||||
|
||||
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
|
||||
{
|
||||
if (!_eventEmitter) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter));
|
||||
auto eventEmitter = std::static_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter);
|
||||
eventEmitter->onRequestClose({});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
@property (nonatomic, copy) NSArray<NSString *> *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
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
#import "RCTTVRemoteHandler.h"
|
||||
#endif
|
||||
|
||||
@interface RCTModalHostView () <UIAdaptivePresentationControllerDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTModalHostView
|
||||
{
|
||||
__weak RCTBridge *_bridge;
|
||||
@@ -50,7 +46,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
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 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
_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 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
[_reactSubview removeGestureRecognizer:_menuButtonGestureRecognizer];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)notifyForBoundsChange:(CGRect)newBounds
|
||||
{
|
||||
@@ -264,11 +257,4 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
|
||||
{
|
||||
if (_onRequestClose) {
|
||||
_onRequestClose(nil);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -108,6 +108,9 @@ RCT_EXPORT_VIEW_PROPERTY(onShow, RCTDirectEventBlock)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user