From 4ce4544cc6203edd8821d58fd043337942ddbb9e Mon Sep 17 00:00:00 2001 From: Andrew n marshall Date: Tue, 13 Nov 2018 13:58:55 -0800 Subject: [PATCH] Temp save of work --- .../xcschemes/xcschememanagement.plist | 5 ++++ .../ios/Blockly WebView/ViewController.swift | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist b/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist index 7cbeeade6..e1e71ff06 100644 --- a/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist @@ -9,6 +9,11 @@ orderHint 0 + Blockly WebView.xcscheme_^#shared#^_ + + orderHint + 0 + diff --git a/demos/mobile/ios/Blockly WebView/ViewController.swift b/demos/mobile/ios/Blockly WebView/ViewController.swift index dee718c07..a9952a857 100644 --- a/demos/mobile/ios/Blockly WebView/ViewController.swift +++ b/demos/mobile/ios/Blockly WebView/ViewController.swift @@ -69,6 +69,34 @@ class ViewController: UIViewController, WKUIDelegate { present(alert, animated: true) } + func webView(_ webView: WKWebView, + runJavaScriptTextInputPanelWithPrompt prompt: String, + defaultText: String?, + initiatedByFrame frame: WKFrameInfo, + completionHandler: @escaping (String?) -> Void) { + + let alert = UIAlertController(title: prompt, message: nil, preferredStyle: .alert) + + alert.addTextField { (textField) in + textField.text = defaultText + } + + let okTitle = NSLocalizedString("OK", comment: "OK button title") + let okAction = UIAlertAction(title: okTitle, style: .default) { (_) in + let textInput = alert.textFields![0] as UITextField + completionHandler(textInput.text) + } + alert.addAction(okAction) + + let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel button title") + let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) { (_) in + completionHandler(nil) + } + alert.addAction(cancelAction) + + present(alert, animated: true) + } + override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated.