From 3a886f59f1fd6149b854087b357a2cb07318a030 Mon Sep 17 00:00:00 2001 From: Sergey Salnikov Date: Thu, 17 Mar 2022 15:09:33 +0300 Subject: [PATCH] added boolean switch inputAccessoryView --- .../InAppWebView/FlutterWebViewController.swift | 1 + ios/Classes/InAppWebView/InAppWebView.swift | 11 +++++------ ios/Classes/InAppWebView/InAppWebViewOptions.swift | 1 + .../in_app_webview/ios/in_app_webview_options.dart | 9 ++++++++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ios/Classes/InAppWebView/FlutterWebViewController.swift b/ios/Classes/InAppWebView/FlutterWebViewController.swift index 8f883d2b..2e338d90 100755 --- a/ios/Classes/InAppWebView/FlutterWebViewController.swift +++ b/ios/Classes/InAppWebView/FlutterWebViewController.swift @@ -58,6 +58,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView { contextMenu: contextMenu, channel: channel!, userScripts: userScripts) + webView?.disableInputAccessoryView = options.disableInputAccessoryView } methodCallDelegate = InAppWebViewMethodHandler(webView: webView!) diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index f49fcef7..9ea0f3ef 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -2942,10 +2942,9 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { } // var accessoryView: UIView? -// -// // https://stackoverflow.com/a/58001395/4637638 -// public override var inputAccessoryView: UIView? { -// // remove/replace the default accessory view -// return accessoryView -// } + var disableInputAccessoryView = false + // https://stackoverflow.com/a/58001395/4637638 + public override var inputAccessoryView: UIView? { + return disableInputAccessoryView ? nil : super.inputAccessoryView + } } diff --git a/ios/Classes/InAppWebView/InAppWebViewOptions.swift b/ios/Classes/InAppWebView/InAppWebViewOptions.swift index 28c69094..fcb3f009 100755 --- a/ios/Classes/InAppWebView/InAppWebViewOptions.swift +++ b/ios/Classes/InAppWebView/InAppWebViewOptions.swift @@ -69,6 +69,7 @@ public class InAppWebViewOptions: Options { var applePayAPIEnabled = false var allowingReadAccessTo: String? = nil var disableLongPressContextMenuOnLinks = false + var disableInputAccessoryView = false override init(){ super.init() diff --git a/lib/src/in_app_webview/ios/in_app_webview_options.dart b/lib/src/in_app_webview/ios/in_app_webview_options.dart index 740a2269..83d71ef4 100755 --- a/lib/src/in_app_webview/ios/in_app_webview_options.dart +++ b/lib/src/in_app_webview/ios/in_app_webview_options.dart @@ -223,6 +223,10 @@ class IOSInAppWebViewOptions ///The default value is `false`. bool disableLongPressContextMenuOnLinks; + ///Set to `true` to disable inputAccessoryView above system keyboard + ///https://developer.apple.com/documentation/uikit/uiresponder/1621119-inputaccessoryview + bool disableInputAccessoryView; + IOSInAppWebViewOptions( {this.disallowOverScroll = false, this.enableViewportScale = false, @@ -255,7 +259,8 @@ class IOSInAppWebViewOptions this.useOnNavigationResponse = false, this.applePayAPIEnabled = false, this.allowingReadAccessTo, - this.disableLongPressContextMenuOnLinks = false}) { + this.disableLongPressContextMenuOnLinks = false, + this.disableInputAccessoryView = false}) { assert( allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file")); } @@ -303,6 +308,7 @@ class IOSInAppWebViewOptions "applePayAPIEnabled": applePayAPIEnabled, "allowingReadAccessTo": allowingReadAccessTo.toString(), "disableLongPressContextMenuOnLinks": disableLongPressContextMenuOnLinks, + "disableInputAccessoryView": disableInputAccessoryView, }; } @@ -365,6 +371,7 @@ class IOSInAppWebViewOptions : null; options.disableLongPressContextMenuOnLinks = map["disableLongPressContextMenuOnLinks"]; + options.disableInputAccessoryView = map["disableInputAccessoryView"]; return options; }