From 3a886f59f1fd6149b854087b357a2cb07318a030 Mon Sep 17 00:00:00 2001 From: Sergey Salnikov Date: Thu, 17 Mar 2022 15:09:33 +0300 Subject: [PATCH 1/2] 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; } From 1eaf70a04604145f3060736da8627ea13878117f Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 18 Apr 2022 01:26:39 +0200 Subject: [PATCH 2/2] merge --- CHANGELOG.md | 1 + ios/Classes/InAppWebView/FlutterWebViewController.swift | 1 - ios/Classes/InAppWebView/InAppWebView.swift | 4 +--- lib/src/in_app_webview/ios/in_app_webview_options.dart | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48976ee7..47d90d74 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ - Merged "Fixes zoomBy with floats (iOS)" [#1109](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1109) (thanks to [Manuito83](https://github.com/Manuito83)) - Merged "Build on and support Android 12 SDK 31" [#1111](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1111) (thanks to [carloserazo47](https://github.com/carloserazo47)) - Merged "Fix takeScreenshot Crash on iOS" [#1123](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1123) (thanks to [a00012025](https://github.com/a00012025)) +- Merged "Feature. Possibility to disable iOS above keyboard inputAccessoryView" [#1124](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1124) (thanks to [cutzmf](https://github.com/cutzmf)) ## 5.3.2 diff --git a/ios/Classes/InAppWebView/FlutterWebViewController.swift b/ios/Classes/InAppWebView/FlutterWebViewController.swift index 2e338d90..8f883d2b 100755 --- a/ios/Classes/InAppWebView/FlutterWebViewController.swift +++ b/ios/Classes/InAppWebView/FlutterWebViewController.swift @@ -58,7 +58,6 @@ 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 b5256aa7..225c3973 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -2955,10 +2955,8 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { print("InAppWebView - dealloc") } -// var accessoryView: UIView? - var disableInputAccessoryView = false // https://stackoverflow.com/a/58001395/4637638 public override var inputAccessoryView: UIView? { - return disableInputAccessoryView ? nil : super.inputAccessoryView + return options?.disableInputAccessoryView ?? false ? nil : super.inputAccessoryView } } 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 83d71ef4..a0c21e92 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,8 +223,8 @@ 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 + ///Set to `true` to disable the [inputAccessoryView](https://developer.apple.com/documentation/uikit/uiresponder/1621119-inputaccessoryview) above system keyboard. + ///The default value is `false`. bool disableInputAccessoryView; IOSInAppWebViewOptions(