Skip to content

Commit

Permalink
added boolean switch inputAccessoryView
Browse files Browse the repository at this point in the history
  • Loading branch information
cutzmf committed Mar 17, 2022
1 parent f06bcdf commit 3a886f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions ios/Classes/InAppWebView/FlutterWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
contextMenu: contextMenu,
channel: channel!,
userScripts: userScripts)
webView?.disableInputAccessoryView = options.disableInputAccessoryView
}

methodCallDelegate = InAppWebViewMethodHandler(webView: webView!)
Expand Down
11 changes: 5 additions & 6 deletions ios/Classes/InAppWebView/InAppWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions ios/Classes/InAppWebView/InAppWebViewOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class InAppWebViewOptions: Options<InAppWebView> {
var applePayAPIEnabled = false
var allowingReadAccessTo: String? = nil
var disableLongPressContextMenuOnLinks = false
var disableInputAccessoryView = false

override init(){
super.init()
Expand Down
9 changes: 8 additions & 1 deletion lib/src/in_app_webview/ios/in_app_webview_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"));
}
Expand Down Expand Up @@ -303,6 +308,7 @@ class IOSInAppWebViewOptions
"applePayAPIEnabled": applePayAPIEnabled,
"allowingReadAccessTo": allowingReadAccessTo.toString(),
"disableLongPressContextMenuOnLinks": disableLongPressContextMenuOnLinks,
"disableInputAccessoryView": disableInputAccessoryView,
};
}

Expand Down Expand Up @@ -365,6 +371,7 @@ class IOSInAppWebViewOptions
: null;
options.disableLongPressContextMenuOnLinks =
map["disableLongPressContextMenuOnLinks"];
options.disableInputAccessoryView = map["disableInputAccessoryView"];
return options;
}

Expand Down

0 comments on commit 3a886f5

Please sign in to comment.