File tree 3 files changed +1
-33
lines changed
3 files changed +1
-33
lines changed Original file line number Diff line number Diff line change 10
10
@interface RCTAlertController : UIAlertController
11
11
12
12
- (void )show : (BOOL )animated completion : (void (^)(void ))completion ;
13
- - (void )hide ;
14
13
15
14
@end
Original file line number Diff line number Diff line change 9
9
10
10
#import < React/RCTAlertController.h>
11
11
12
- @interface RCTAlertController ()
13
-
14
- @property (nonatomic , strong ) UIWindow *alertWindow;
15
-
16
- @end
17
-
18
12
@implementation RCTAlertController
19
13
20
- - (UIWindow *)alertWindow
21
- {
22
- if (_alertWindow == nil ) {
23
- _alertWindow = [[UIWindow alloc ] initWithFrame: RCTSharedApplication ().keyWindow.bounds];
24
- _alertWindow.rootViewController = [UIViewController new ];
25
- _alertWindow.windowLevel = UIWindowLevelAlert + 1 ;
26
- }
27
- return _alertWindow;
28
- }
29
-
30
14
- (void )show : (BOOL )animated completion : (void (^)(void ))completion
31
15
{
32
16
if (@available (iOS 13.0 , *)) {
33
17
UIUserInterfaceStyle style =
34
18
RCTSharedApplication ().delegate .window .overrideUserInterfaceStyle ?: UIUserInterfaceStyleUnspecified;
35
19
self.overrideUserInterfaceStyle = style;
36
20
}
37
- [self .alertWindow makeKeyAndVisible ];
38
- [self .alertWindow.rootViewController presentViewController: self animated: animated completion: completion];
39
- }
40
-
41
- - (void )hide
42
- {
43
- [_alertWindow setHidden: YES ];
44
-
45
- if (@available (iOS 13 , *)) {
46
- _alertWindow.windowScene = nil ;
47
- }
48
-
49
- _alertWindow = nil ;
21
+ [[RCTKeyWindow () rootViewController ] presentViewController: self animated: animated completion: completion];
50
22
}
51
23
52
24
@end
Original file line number Diff line number Diff line change @@ -185,20 +185,17 @@ - (void)invalidate
185
185
case RCTAlertViewStylePlainTextInput:
186
186
case RCTAlertViewStyleSecureTextInput:
187
187
callback (@[ buttonKey, [weakAlertController.textFields.firstObject text ] ]);
188
- [weakAlertController hide ];
189
188
break ;
190
189
case RCTAlertViewStyleLoginAndPasswordInput: {
191
190
NSDictionary <NSString *, NSString *> *loginCredentials = @{
192
191
@" login" : [weakAlertController.textFields.firstObject text ],
193
192
@" password" : [weakAlertController.textFields.lastObject text ]
194
193
};
195
194
callback (@[ buttonKey, loginCredentials ]);
196
- [weakAlertController hide ];
197
195
break ;
198
196
}
199
197
case RCTAlertViewStyleDefault:
200
198
callback (@[ buttonKey ]);
201
- [weakAlertController hide ];
202
199
break ;
203
200
}
204
201
}];
You can’t perform that action at this time.
0 commit comments