File tree Expand file tree Collapse file tree 5 files changed +29
-14
lines changed Expand file tree Collapse file tree 5 files changed +29
-14
lines changed Original file line number Diff line number Diff line change 22#import " RNTModalMountingHelper.h"
33#import " RNTModalWindowHelper.h"
44
5- @implementation RNTModalMountingHelper
6-
7- - (instancetype )init
8- {
9- [NSException raise: @" init" format: @" init has not been implemented" ];
10- return self;
5+ @implementation RNTModalMountingHelper {
6+ __strong UIWindow *modalWindow;
117}
128
139- (instancetype _Nonnull)initWithViewController : (RNTModalViewController * _Nonnull)viewController {
@@ -53,7 +49,8 @@ - (void)unmountIfNeeded {
5349
5450- (void )mount {
5551 RNTModalWindowHelper *windowHelper = [[RNTModalWindowHelper alloc ] init ];
56- UIViewController *rvc = [windowHelper getRootController ];
52+ modalWindow = [windowHelper createNewKeyWindow ];
53+ UIViewController *rvc = modalWindow.rootViewController ;
5754
5855 if (!rvc) {
5956 NSLog (@" reactViewController not found" );
@@ -69,10 +66,12 @@ - (void)mount {
6966
7067- (void )unmount {
7168 [self .modal dismiss ];
72- _modal = nil ;
73- _isMounted = NO ;
74- _hasProps = NO ;
75- _hasChildren = NO ;
69+ self.modal = nil ;
70+ self.isMounted = NO ;
71+ self.hasProps = NO ;
72+ self.hasChildren = NO ;
73+ modalWindow.hidden = YES ;
74+ modalWindow = nil ;
7675}
7776
7877@end
Original file line number Diff line number Diff line change @@ -56,9 +56,6 @@ - (void)viewDidLayoutSubviews
5656#pragma mark - ModalViewControllerProtocol
5757
5858- (void )presentOn : (UIViewController *)parentVC onView : (UIView *)parentView {
59- self.modalPresentationStyle = UIModalPresentationCustom;
60- self.view .accessibilityViewIsModal = YES ;
61-
6259 [self willMoveToParentViewController: parentVC];
6360 [parentVC addChildViewController: self ];
6461 [parentView addSubview: self .view];
Original file line number Diff line number Diff line change 88- (UIWindow *_Nullable)getKeyWindow ;
99- (UIViewController *_Nullable)getRootController ;
1010- (UIInterfaceOrientation)getWindowOrientation ;
11+ - (UIWindow *_Nonnull)createNewKeyWindow ;
1112
1213@end
1314
Original file line number Diff line number Diff line change @@ -33,4 +33,20 @@ - (UIInterfaceOrientation)getWindowOrientation
3333 return [self getKeyWindow ].windowScene .interfaceOrientation ?: UIInterfaceOrientationPortrait;
3434}
3535
36+ - (UIWindow *)createNewKeyWindow {
37+ UIWindow *keyWindow = [self getKeyWindow ];
38+
39+ UIWindow *nextWindow = [[UIWindow alloc ] initWithFrame: keyWindow.bounds];
40+
41+ nextWindow.windowScene = keyWindow.windowScene ;
42+ nextWindow.rootViewController = [[UIViewController alloc ] init ];
43+ nextWindow.backgroundColor = UIColor.clearColor ;
44+ nextWindow.accessibilityViewIsModal = YES ;
45+ nextWindow.rootViewController .modalPresentationStyle = UIModalPresentationCustom;
46+
47+ [nextWindow makeKeyAndVisible ];
48+
49+ return nextWindow;
50+ }
51+
3652@end
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ - (void)removeReactSubview:(UIView *)subview
4848 [self .mountingHelper unmountIfNeeded ];
4949 [subview removeFromSuperview ];
5050 self.reactSubview = nil ;
51+ self.modalViewController = nil ;
52+ self.mountingHelper = nil ;
5153 });
5254}
5355
You can’t perform that action at this time.
0 commit comments