Skip to content

Commit 8aeb5dc

Browse files
sherginalloy
authored andcommittedFeb 25, 2020
Revert D19235758: Implement onRequestClose for iOS 13+ modals
Differential Revision: D19235758 Original commit changeset: c0f1d946c77c fbshipit-source-id: c4a9d7876aa8d07ff5b8419f097b02e9c28e2880
1 parent 360b53d commit 8aeb5dc

File tree

6 files changed

+8
-38
lines changed

6 files changed

+8
-38
lines changed
 

‎Libraries/Modal/Modal.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ export type Props = $ReadOnly<{|
9595

9696
/**
9797
* The `onRequestClose` callback is called when the user taps the hardware
98-
* back button on Android, the menu button on Apple TV, or a modal is dismissed
99-
* with a gesture on iOS 13+.
98+
* back button on Android or the menu button on Apple TV.
10099
*
101100
* This is required on Apple TV and Android.
102101
*

‎Libraries/Modal/RCTModalHostViewNativeComponent.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ type NativeProps = $ReadOnly<{|
7070

7171
/**
7272
* The `onRequestClose` callback is called when the user taps the hardware
73-
* back button on Android, the menu button on Apple TV, or a modal is dismissed
74-
* with a gesture on iOS 13+.
73+
* back button on Android or the menu button on Apple TV.
7574
*
7675
* This is required on Apple TV and Android.
7776
*

‎React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm

+1-17
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
9191
return {orientation};
9292
}
9393

94-
@interface RCTModalHostViewComponentView () <
95-
RCTFabricModalHostViewControllerDelegate,
96-
UIAdaptivePresentationControllerDelegate>
94+
@interface RCTModalHostViewComponentView () <RCTFabricModalHostViewControllerDelegate>
9795

9896
@end
9997

@@ -112,7 +110,6 @@ - (instancetype)initWithFrame:(CGRect)frame
112110
_viewController = [RCTFabricModalHostViewController new];
113111
_viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
114112
_viewController.delegate = self;
115-
_viewController.presentationController.delegate = self;
116113
}
117114

118115
return self;
@@ -217,17 +214,4 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
217214
[childComponentView removeFromSuperview];
218215
}
219216

220-
#pragma mark - UIAdaptivePresentationControllerDelegate
221-
222-
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
223-
{
224-
if (!_eventEmitter) {
225-
return;
226-
}
227-
228-
assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter));
229-
auto eventEmitter = std::static_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter);
230-
eventEmitter->onRequestClose({});
231-
}
232-
233217
@end

‎React/Views/RCTModalHostView.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
@property (nonatomic, copy) NSArray<NSString *> *supportedOrientations;
3333
@property (nonatomic, copy) RCTDirectEventBlock onOrientationChange;
3434

35-
@property (nonatomic, copy) RCTDirectEventBlock onRequestClose;
36-
3735
#if TARGET_OS_TV
36+
@property (nonatomic, copy) RCTDirectEventBlock onRequestClose;
3837
@property (nonatomic, strong) RCTTVRemoteHandler *tvRemoteHandler;
3938
#endif
4039

‎React/Views/RCTModalHostView.m

+1-15
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#import "RCTTVRemoteHandler.h"
2121
#endif
2222

23-
@interface RCTModalHostView () <UIAdaptivePresentationControllerDelegate>
24-
25-
@end
26-
2723
@implementation RCTModalHostView
2824
{
2925
__weak RCTBridge *_bridge;
@@ -50,7 +46,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
5046
UIView *containerView = [UIView new];
5147
containerView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
5248
_modalViewController.view = containerView;
53-
_modalViewController.presentationController.delegate = self;
5449
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge];
5550
#if TARGET_OS_TV
5651
_menuButtonGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuButtonPressed:)];
@@ -75,21 +70,19 @@ - (void)menuButtonPressed:(__unused UIGestureRecognizer *)gestureRecognizer
7570
_onRequestClose(nil);
7671
}
7772
}
78-
#endif
7973

8074
- (void)setOnRequestClose:(RCTDirectEventBlock)onRequestClose
8175
{
8276
_onRequestClose = onRequestClose;
83-
#if TARGET_OS_TV
8477
if (_reactSubview) {
8578
if (_onRequestClose && _menuButtonGestureRecognizer) {
8679
[_reactSubview addGestureRecognizer:_menuButtonGestureRecognizer];
8780
} else {
8881
[_reactSubview removeGestureRecognizer:_menuButtonGestureRecognizer];
8982
}
9083
}
91-
#endif
9284
}
85+
#endif
9386

9487
- (void)notifyForBoundsChange:(CGRect)newBounds
9588
{
@@ -264,11 +257,4 @@ - (UIInterfaceOrientationMask)supportedOrientationsMask
264257
}
265258
#endif
266259

267-
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
268-
{
269-
if (_onRequestClose) {
270-
_onRequestClose(nil);
271-
}
272-
}
273-
274260
@end

‎React/Views/RCTModalHostViewManager.m

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ - (void)invalidate
108108
RCT_EXPORT_VIEW_PROPERTY(identifier, NSNumber)
109109
RCT_EXPORT_VIEW_PROPERTY(supportedOrientations, NSArray)
110110
RCT_EXPORT_VIEW_PROPERTY(onOrientationChange, RCTDirectEventBlock)
111+
112+
#if TARGET_OS_TV
111113
RCT_EXPORT_VIEW_PROPERTY(onRequestClose, RCTDirectEventBlock)
114+
#endif
112115

113116
@end

0 commit comments

Comments
 (0)
Please sign in to comment.