mirror of
https://github.com/expo/react-native-webview.git
synced 2026-11-15 09:18:06 -10:00
fix(iOS): Align look and feel of Window.prompt() to Mobile Safari (#677)
This commit is contained in:
1 parent
234075c524
commit
231100dc3c
1 file changed
+9
-4
+9
-4
@@ -643,12 +643,17 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:prompt preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
||||
textField.textColor = [UIColor lightGrayColor];
|
||||
textField.placeholder = defaultText;
|
||||
textField.text = defaultText;
|
||||
}];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
completionHandler([[alert.textFields lastObject] text]);
|
||||
}]];
|
||||
}];
|
||||
[alert addAction:okAction];
|
||||
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
||||
completionHandler(nil);
|
||||
}];
|
||||
[alert addAction:cancelAction];
|
||||
alert.preferredAction = okAction;
|
||||
[[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user