Last active
February 10, 2020 17:23
-
-
Save scarlac/ec162221e11927c52cfc9c94e7252824 to your computer and use it in GitHub Desktop.
Revisions
-
scarlac revised this gist
Feb 10, 2020 . 1 changed file with 26 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ index e421e59..ba461e0 100644 @property (nonatomic, copy) NSString *animationType; @property (nonatomic, assign) UIModalPresentationStyle presentationStyle; diff --git a/node_modules/react-native/React/Views/RCTModalHostView.m b/node_modules/react-native/React/Views/RCTModalHostView.m index bc0cac1..7d36a9b 100644 --- a/node_modules/react-native/React/Views/RCTModalHostView.m +++ b/node_modules/react-native/React/Views/RCTModalHostView.m @@ -12,6 +12,7 @@ @@ -23,27 +23,43 @@ index bc0cac1..06b0e18 100644 #import "RCTTouchHandler.h" #import "RCTUIManager.h" #import "RCTUtils.h" @@ -43,6 +44,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge if ((self = [super initWithFrame:CGRectZero])) { _bridge = bridge; _modalViewController = [RCTModalHostViewController new]; + // Transparency breaks for overFullScreen in iOS < 13 + if (@available(iOS 13.0, *)) { + _modalViewController.presentationController.delegate = self; + } UIView *containerView = [UIView new]; containerView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; _modalViewController.view = containerView; @@ -63,6 +68,24 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge return self; } +// Method must be implemented, otherwise iOS defaults to 'automatic' (pageSheet on >= iOS 13.0) +- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection +{ + if (self.presentationStyle == UIModalPresentationFullScreen && self.isTransparent) { + return UIModalPresentationOverFullScreen; + } + return self.presentationStyle; +} + +// Method must be implemented, otherwise iOS defaults to 'automatic' (pageSheet on >= iOS 13.0) +- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller +{ + if (self.presentationStyle == UIModalPresentationFullScreen && self.isTransparent) { + return UIModalPresentationOverFullScreen; + } + return self.presentationStyle; +} + #if TARGET_OS_TV - (void)menuButtonPressed:(__unused UIGestureRecognizer *)gestureRecognizer { @@ -156,6 +179,14 @@ - (void)didUpdateReactSubviews // Do nothing, as subview (singular) is managed by `insertReactSubview:atIndex:` } -
scarlac revised this gist
Feb 7, 2020 . 1 changed file with 14 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ index e421e59..ba461e0 100644 @property (nonatomic, copy) NSString *animationType; @property (nonatomic, assign) UIModalPresentationStyle presentationStyle; diff --git a/node_modules/react-native/React/Views/RCTModalHostView.m b/node_modules/react-native/React/Views/RCTModalHostView.m index bc0cac1..06b0e18 100644 --- a/node_modules/react-native/React/Views/RCTModalHostView.m +++ b/node_modules/react-native/React/Views/RCTModalHostView.m @@ -12,6 +12,7 @@ @@ -23,7 +23,7 @@ index bc0cac1..56bd0a6 100644 #import "RCTTouchHandler.h" #import "RCTUIManager.h" #import "RCTUtils.h" @@ -58,11 +59,19 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _modalViewController.boundsDidChangeBlock = ^(CGRect newBounds) { [weakSelf notifyForBoundsChange:newBounds]; }; @@ -32,7 +32,18 @@ index bc0cac1..56bd0a6 100644 } return self; } +// Method must be implemented, otherwise iOS defaults to 'automatic' (pageSheet on >= iOS 13.0) +- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection +{ + return self.presentationStyle; +} + #if TARGET_OS_TV - (void)menuButtonPressed:(__unused UIGestureRecognizer *)gestureRecognizer { @@ -156,6 +165,14 @@ - (void)didUpdateReactSubviews // Do nothing, as subview (singular) is managed by `insertReactSubview:atIndex:` } -
scarlac revised this gist
Feb 3, 2020 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,16 @@ diff --git a/node_modules/react-native/React/Views/RCTModalHostView.h b/node_modules/react-native/React/Views/RCTModalHostView.h index e421e59..ba461e0 100644 --- a/node_modules/react-native/React/Views/RCTModalHostView.h +++ b/node_modules/react-native/React/Views/RCTModalHostView.h @@ -17,7 +17,7 @@ @protocol RCTModalHostViewInteractor; -@interface RCTModalHostView : UIView <RCTInvalidating> +@interface RCTModalHostView : UIView <RCTInvalidating, UIAdaptivePresentationControllerDelegate> @property (nonatomic, copy) NSString *animationType; @property (nonatomic, assign) UIModalPresentationStyle presentationStyle; diff --git a/node_modules/react-native/React/Views/RCTModalHostView.m b/node_modules/react-native/React/Views/RCTModalHostView.m index bc0cac1..56bd0a6 100644 --- a/node_modules/react-native/React/Views/RCTModalHostView.m -
scarlac created this gist
Feb 3, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ diff --git a/node_modules/react-native/React/Views/RCTModalHostView.m b/node_modules/react-native/React/Views/RCTModalHostView.m index bc0cac1..56bd0a6 100644 --- a/node_modules/react-native/React/Views/RCTModalHostView.m +++ b/node_modules/react-native/React/Views/RCTModalHostView.m @@ -12,6 +12,7 @@ #import "RCTAssert.h" #import "RCTBridge.h" #import "RCTModalHostViewController.h" +#import "RCTModalManager.h" #import "RCTTouchHandler.h" #import "RCTUIManager.h" #import "RCTUtils.h" @@ -58,6 +59,8 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _modalViewController.boundsDidChangeBlock = ^(CGRect newBounds) { [weakSelf notifyForBoundsChange:newBounds]; }; + + _modalViewController.presentationController.delegate = self; } return self; @@ -156,6 +159,14 @@ - (void)didUpdateReactSubviews // Do nothing, as subview (singular) is managed by `insertReactSubview:atIndex:` } +- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController +{ + // Modal is already dismissed so trigger onDismiss, etc. + if (self.identifier) { + [[_bridge moduleForClass:[RCTModalManager class]] modalDismissed:self.identifier]; + } +} + - (void)dismissModalViewController { if (_isPresented) {