public void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { var controller = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); controller.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, x => completionHandler())); PresentViewController(controller, true, null); }
public override void RunJavaScriptAlertPanel ( WKWebView webView, string message, WKFrameInfo frame, Action completionHandler ) { // custom javascript Alert() code possible #if DEBUG StringBuilder sb = new StringBuilder(); sb.AppendLine($"WKWebViewUIDelegate.RunJavaScriptAlertPanel "); sb.AppendLine($" webView.Url.AbsoluteString = {webView.Url.AbsoluteString}"); System.Diagnostics.Debug.WriteLine(sb.ToString()); #endif // COSMOS var alertController = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) => { completionHandler(); })); controller.PresentViewController(alertController, animated: true, null); return; }
public override void RunJavaScriptTextInputPanel( WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { PresentAlertController( webView, prompt, defaultText: defaultText, okAction: x => completionHandler(x.TextFields[0].Text), cancelAction: _ => completionHandler(null) ); }
public void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action <bool> completionHandler) { var alertController = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, okAction => { completionHandler(true); })); alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, cancelAction => { completionHandler(false); })); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); }
private void OnRunJavaScriptAlertPanel(WKWebView webview, string message, WKFrameInfo frame, Action completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().DebugFormat("OnRunJavaScriptAlertPanel: {0}", message); } var controller = webview.FindViewController(); var alert = UIKit.UIAlertController.Create(string.Empty, message, UIKit.UIAlertControllerStyle.Alert); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, null)); controller?.PresentViewController(alert, true, completionHandler); }
public void RunJavaScriptConfirmPanel (WKWebView webView, string message, WKFrameInfo frame, Action<bool> completionHandler) { // Create a native UIAlertController with the message var alertController = UIAlertController.Create (null, message, UIAlertControllerStyle.Alert); // Add two actions to the alert. Based on the result we call the completion handles and pass either true or false alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, okAction => { completionHandler(true); })); alertController.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Default, cancelAction => { completionHandler (false); })); // Present the alert PresentViewController (alertController, true, null); }
public void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action <bool> completionHandler) { // Create a native UIAlertController with the message var alertController = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); // Add two actions to the alert. Based on the result we call the completion handles and pass either true or false alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, okAction => { completionHandler(true); })); alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, cancelAction => { completionHandler(false); })); // Present the alert PresentViewController(alertController, true, null); }
public override void RunJavaScriptAlertPanel ( WKWebView webView, string message, WKFrameInfo frame, Action completionHandler ) { // custom javascript Alert() code possible #if DEBUG StringBuilder sb = new StringBuilder(); sb.AppendLine($"WKWebViewUIDelegate.RunJavaScriptAlertPanel "); sb.AppendLine($" webView.Url.AbsoluteString = {webView.Url.AbsoluteString}"); System.Diagnostics.Debug.WriteLine(sb.ToString()); #endif return; }
private void OnRunJavaScriptConfirmPanel(WKWebView webview, string message, WKFrameInfo frame, Action <bool> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().DebugFormat("OnRunJavaScriptConfirmPanel: {0}", message); } /* * Code taken from: * https://github.com/xamarin/recipes/pull/20/files */ var controller = webview.FindViewController(); var alert = UIKit.UIAlertController.Create(string.Empty, message, UIKit.UIAlertControllerStyle.Alert); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, okAction => completionHandler(true))); alert.AddAction(UIKit.UIAlertAction.Create(CancelString, UIKit.UIAlertActionStyle.Cancel, cancelAction => completionHandler(false))); controller?.PresentViewController(alert, true, null); }
private void OnRunJavaScriptAlertPanel(WKWebView webview, string message, WKFrameInfo frame, Action completionHandler) { if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug)) { this.Log().DebugFormat("OnRunJavaScriptAlertPanel: {0}", message); } var controller = webview.FindViewController(); #if __IOS__ var alert = UIKit.UIAlertController.Create(string.Empty, message, UIKit.UIAlertControllerStyle.Alert); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, null)); controller?.PresentViewController(alert, true, null); completionHandler(); #else var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = message }; alert.RunModal(); completionHandler(); #endif }
private void OnRunJavaScriptConfirmPanel(WKWebView webview, string message, WKFrameInfo frame, Action <bool> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().DebugFormat("OnRunJavaScriptConfirmPanel: {0}", message); } /* * Code taken from: * https://github.com/xamarin/recipes/pull/20/files */ var controller = webview.FindViewController(); #if __IOS__ var alert = UIKit.UIAlertController.Create(string.Empty, message, UIKit.UIAlertControllerStyle.Alert); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, okAction => completionHandler(true))); alert.AddAction(UIKit.UIAlertAction.Create(CancelString, UIKit.UIAlertActionStyle.Cancel, cancelAction => completionHandler(false))); controller?.PresentViewController(alert, true, null); #else var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = message, }; alert.AddButton(OkString); alert.AddButton(CancelString); alert.BeginSheetForResponse(webview.Window, (result) => { var okButtonClicked = result == 1000; completionHandler(okButtonClicked); }); #endif }
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { var alert = UIAlertController.Create("Alert", message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); // Let javascript handle the OK click by passing the completionHandler to the controller ParentController.PresentViewController(alert, true, completionHandler); }
public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action <bool> completionHandler) { PresentAlertController( webView, message, okAction: _ => completionHandler(true), cancelAction: _ => completionHandler(false) ); }
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { PresentAlertController( webView, message, okAction: _ => completionHandler() ); }
public void RunJavaScriptTextInputPanel(WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { var controller = UIAlertController.Create(null, prompt, UIAlertControllerStyle.Alert); controller.AddTextField(textField => { textField.Placeholder = defaultText; controller.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, x => completionHandler(textField.Text))); controller.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, x => completionHandler(null))); PresentViewController(controller, true, null); }); }
public void RunJavaScriptAlertPanel(WebKit.WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { var alertController = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); completionHandler(); }
public override void RunJavaScriptTextInputPanel(WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { var alertController = UIAlertController.Create("", prompt, UIAlertControllerStyle.Alert); alertController.AddTextField((UITextField obj) => obj.Text = defaultText); var actionOk = UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (UIAlertAction obj) => { string text = alertController.TextFields.Any() ? alertController.TextFields.First().Text : defaultText; completionHandler(text); }); var actionCancel = UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, (UIAlertAction obj) => { completionHandler(null); }); alertController.AddAction(actionOk); alertController.AddAction(actionCancel); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); }
public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action <bool> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().Debug($"WKUIDelegate.RunJavaScriptConfirmPanel: {message}"); } _runJavaScriptConfirmPanel?.Invoke(webView, message, frame, completionHandler); }
public override void RunJavaScriptTextInputPanel(WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().Debug($"WKUIDelegate.RunJavaScriptTextInputPanel: {prompt} / {defaultText}"); } _runJavaScriptTextInputPanel?.Invoke(webView, prompt, defaultText, frame, completionHandler); }
private void OnRunJavaScriptTextInputPanel(WKWebView webview, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().Debug($"OnRunJavaScriptTextInputPanel: {prompt}, {defaultText}"); } var alert = UIKit.UIAlertController.Create(string.Empty, prompt, UIKit.UIAlertControllerStyle.Alert); UITextField alertTextField = null; alert.AddTextField((textField) => { textField.Placeholder = defaultText; alertTextField = textField; }); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, okAction => completionHandler(alertTextField.Text))); alert.AddAction(UIKit.UIAlertAction.Create(CancelString, UIKit.UIAlertActionStyle.Cancel, cancelAction => completionHandler(null))); var controller = webview.FindViewController(); controller?.PresentViewController(alert, true, null); }
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug)) { this.Log().Debug($"WKUIDelegate.RunJavaScriptAlertPanel: {message}"); } _runJavaScriptAlertPanel?.Invoke(webView, message, frame, completionHandler); }
private void OnRunJavaScriptTextInputPanel(WKWebView webview, string prompt, string defaultText, WKFrameInfo frame, Action <string> completionHandler) { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug)) { this.Log().Debug($"OnRunJavaScriptTextInputPanel: {prompt}, {defaultText}"); } #if __IOS__ var alert = UIKit.UIAlertController.Create(string.Empty, prompt, UIKit.UIAlertControllerStyle.Alert); UITextField alertTextField = null; alert.AddTextField((textField) => { textField.Placeholder = defaultText; alertTextField = textField; }); alert.AddAction(UIKit.UIAlertAction.Create(OkString, UIKit.UIAlertActionStyle.Default, okAction => completionHandler(alertTextField.Text))); alert.AddAction(UIKit.UIAlertAction.Create(CancelString, UIKit.UIAlertActionStyle.Cancel, cancelAction => completionHandler(null))); var controller = webview.FindViewController(); controller?.PresentViewController(alert, true, null); #else var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = prompt, }; var textField = new NSTextField(new CGRect(0, 0, 300, 20)) { PlaceholderString = defaultText, }; alert.AccessoryView = textField; alert.AddButton(OkString); alert.AddButton(CancelString); alert.BeginSheetForResponse(webview.Window, (result) => { var okButtonClicked = result == 1000; completionHandler(okButtonClicked ? textField.StringValue : null); }); #endif }
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler) { var alertController = UIAlertController.Create("", message, UIAlertControllerStyle.Alert); var actionOk = UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (UIAlertAction obj) => { completionHandler(); }); alertController.AddAction(actionOk); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); }