|
15 | 15 | #import <React/RCTUtils.h>
|
16 | 16 |
|
17 | 17 | #import "CoreModulesPlugins.h"
|
| 18 | +#import "RCTAlertController.h" |
18 | 19 |
|
19 | 20 | @implementation RCTConvert (UIAlertViewStyle)
|
20 | 21 |
|
@@ -99,29 +100,9 @@ - (void)invalidate
|
99 | 100 | }
|
100 | 101 | }
|
101 | 102 |
|
102 |
| - UIViewController *presentingController = RCTPresentedViewController(); |
103 |
| - if (presentingController == nil) { |
104 |
| - RCTLogError(@"Tried to display alert view but there is no application window. args: %@", @{ |
105 |
| - @"title" : args.title() ?: [NSNull null], |
106 |
| - @"message" : args.message() ?: [NSNull null], |
107 |
| - @"buttons" : RCTConvertOptionalVecToArray( |
108 |
| - args.buttons(), |
109 |
| - ^id(id<NSObject> element) { |
110 |
| - return element; |
111 |
| - }) |
112 |
| - ?: [NSNull null], |
113 |
| - @"type" : args.type() ?: [NSNull null], |
114 |
| - @"defaultValue" : args.defaultValue() ?: [NSNull null], |
115 |
| - @"cancelButtonKey" : args.cancelButtonKey() ?: [NSNull null], |
116 |
| - @"destructiveButtonKey" : args.destructiveButtonKey() ?: [NSNull null], |
117 |
| - @"keyboardType" : args.keyboardType() ?: [NSNull null], |
118 |
| - }); |
119 |
| - return; |
120 |
| - } |
121 |
| - |
122 |
| - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title |
123 |
| - message:nil |
124 |
| - preferredStyle:UIAlertControllerStyleAlert]; |
| 103 | + RCTAlertController *alertController = [RCTAlertController alertControllerWithTitle:title |
| 104 | + message:nil |
| 105 | + preferredStyle:UIAlertControllerStyleAlert]; |
125 | 106 | switch (type) {
|
126 | 107 | case RCTAlertViewStylePlainTextInput: {
|
127 | 108 | [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
@@ -170,7 +151,7 @@ - (void)invalidate
|
170 | 151 | } else if ([buttonKey isEqualToString:destructiveButtonKey]) {
|
171 | 152 | buttonStyle = UIAlertActionStyleDestructive;
|
172 | 153 | }
|
173 |
| - __weak UIAlertController *weakAlertController = alertController; |
| 154 | + __weak RCTAlertController *weakAlertController = alertController; |
174 | 155 | [alertController
|
175 | 156 | addAction:[UIAlertAction
|
176 | 157 | actionWithTitle:buttonTitle
|
@@ -202,7 +183,7 @@ - (void)invalidate
|
202 | 183 | [_alertControllers addObject:alertController];
|
203 | 184 |
|
204 | 185 | dispatch_async(dispatch_get_main_queue(), ^{
|
205 |
| - [presentingController presentViewController:alertController animated:YES completion:nil]; |
| 186 | + [alertController show:YES completion:nil]; |
206 | 187 | });
|
207 | 188 | }
|
208 | 189 |
|
|
0 commit comments