diff --git a/CHANGELOG.md b/CHANGELOG.md index c7799bba..ef69434e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Added `WebAuthenticationSession` for iOS - Added `FindInteractionController` for Android and iOS - Added `pauseAllMediaPlayback`, `setAllMediaPlaybackSuspended`, `closeAllMediaPresentations`, `requestMediaPlaybackState`, `isInFullscreen`, `getCameraCaptureState`, `setCameraCaptureState`, `getMicrophoneCaptureState`, `setMicrophoneCaptureState` WebView controller methods -- Added `underPageBackgroundColor`, `isTextInteractionEnabled`, `isSiteSpecificQuirksModeEnabled`, `upgradeKnownHostsToHTTPS`, `forceDarkStrategy`, `willSuppressErrorPage`, `algorithmicDarkeningAllowed`, `requestedWithHeaderMode`, `enterpriseAuthenticationAppLinkPolicyEnabled`, `isElementFullscreenEnabled`, `isFindInteractionEnabled` WebView settings +- Added `underPageBackgroundColor`, `isTextInteractionEnabled`, `isSiteSpecificQuirksModeEnabled`, `upgradeKnownHostsToHTTPS`, `forceDarkStrategy`, `willSuppressErrorPage`, `algorithmicDarkeningAllowed`, `requestedWithHeaderMode`, `enterpriseAuthenticationAppLinkPolicyEnabled`, `isElementFullscreenEnabled`, `isFindInteractionEnabled`, `minimumViewportInset`, `maximumViewportInset` WebView settings - Added `onCameraCaptureStateChanged`, `onMicrophoneCaptureStateChanged` WebView events - Added support for `onPermissionRequest` event on iOS 15.0+ - Added `debugLoggingSettings` static property for WebView and ChromeSafariBrowser diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index 011d748f..0ab27780 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -416,6 +416,12 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, } } + if #available(iOS 15.5, *) { + if let minViewportInset = settings.minimumViewportInset, let maxViewportInset = settings.maximumViewportInset { + setMinimumViewportInset(minViewportInset, maximumViewportInset: maxViewportInset) + } + } + if #available(iOS 16.0, *) { isFindInteractionEnabled = settings.isFindInteractionEnabled } @@ -1188,11 +1194,17 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, } } if #available(iOS 15.4, *) { - if newSettingsMap["isSiteSpecificQuirksModeEnabled"] != nil && - settings?.isSiteSpecificQuirksModeEnabled != newSettings.isSiteSpecificQuirksModeEnabled { + if newSettingsMap["isSiteSpecificQuirksModeEnabled"] != nil, settings?.isSiteSpecificQuirksModeEnabled != newSettings.isSiteSpecificQuirksModeEnabled { configuration.preferences.isSiteSpecificQuirksModeEnabled = newSettings.isSiteSpecificQuirksModeEnabled } } + if #available(iOS 15.5, *) { + if ((newSettingsMap["minimumViewportInset"] != nil && settings?.minimumViewportInset != newSettings.minimumViewportInset) || + (newSettingsMap["maximumViewportInset"] != nil && settings?.maximumViewportInset != newSettings.maximumViewportInset)), + let minViewportInset = newSettings.minimumViewportInset, let maxViewportInset = newSettings.maximumViewportInset { + setMinimumViewportInset(minViewportInset, maximumViewportInset: maxViewportInset) + } + } scrollView.isScrollEnabled = !(newSettings.disableVerticalScroll && newSettings.disableHorizontalScroll) diff --git a/ios/Classes/InAppWebView/InAppWebViewSettings.swift b/ios/Classes/InAppWebView/InAppWebViewSettings.swift index 60aaf1a8..c024626c 100755 --- a/ios/Classes/InAppWebView/InAppWebViewSettings.swift +++ b/ios/Classes/InAppWebView/InAppWebViewSettings.swift @@ -76,12 +76,23 @@ public class InAppWebViewSettings: ISettings { var upgradeKnownHostsToHTTPS = true var isElementFullscreenEnabled = true var isFindInteractionEnabled = false + var minimumViewportInset: UIEdgeInsets? = nil + var maximumViewportInset: UIEdgeInsets? = nil override init(){ super.init() } override func parse(settings: [String: Any?]) -> InAppWebViewSettings { + var settings = settings // re-assing to be able to use removeValue + if let minimumViewportInsetMap = settings["minimumViewportInset"] as? [String : Double] { + minimumViewportInset = UIEdgeInsets.fromMap(map: minimumViewportInsetMap) + settings.removeValue(forKey: "minimumViewportInset") + } + if let maximumViewportInsetMap = settings["maximumViewportInset"] as? [String : Double] { + maximumViewportInset = UIEdgeInsets.fromMap(map: maximumViewportInsetMap) + settings.removeValue(forKey: "maximumViewportInset") + } let _ = super.parse(settings: settings) if #available(iOS 13.0, *) {} else { applePayAPIEnabled = false @@ -150,6 +161,10 @@ public class InAppWebViewSettings: ISettings { realSettings["isSiteSpecificQuirksModeEnabled"] = configuration.preferences.isSiteSpecificQuirksModeEnabled realSettings["isElementFullscreenEnabled"] = configuration.preferences.isElementFullscreenEnabled } + if #available(iOS 15.5, *) { + realSettings["minimumViewportInset"] = webView.minimumViewportInset.toMap() + realSettings["maximumViewportInset"] = webView.maximumViewportInset.toMap() + } if #available(iOS 16.0, *) { realSettings["isFindInteractionEnabled"] = webView.isFindInteractionEnabled } diff --git a/lib/src/in_app_webview/in_app_webview_settings.dart b/lib/src/in_app_webview/in_app_webview_settings.dart index 93ad6078..02a71670 100755 --- a/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1,6 +1,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; import '../types/requested_with_header_mode.dart'; import 'android/in_app_webview_options.dart'; @@ -11,6 +12,9 @@ import '../util.dart'; import '../in_app_browser/in_app_browser_settings.dart'; import 'webview.dart'; import '../android/webview_feature.dart'; +import '../in_app_webview/in_app_webview_controller.dart'; +import '../context_menu.dart'; + ///This class represents all the WebView settings available. class InAppWebViewSettings { @@ -555,7 +559,7 @@ class InAppWebViewSettings { ///Sets the WebView's over-scroll mode. ///Setting the over-scroll mode of a WebView will have an effect only if the WebView is capable of scrolling. - ///The default value is [OverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS]. + ///The default value is [OverScrollMode.IF_CONTENT_SCROLLS]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1077,6 +1081,24 @@ class InAppWebViewSettings { ///- iOS bool isFindInteractionEnabled; + ///Set minimum viewport inset to the smallest inset a webpage may experience in your app's maximally collapsed UI configuration. + ///Values must be either zero or positive. It must be smaller than [maximumViewportInset]. + /// + ///**NOTE**: available on iOS 15.5+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + EdgeInsets? minimumViewportInset; + + ///Set maximum viewport inset to the largest inset a webpage may experience in your app's maximally expanded UI configuration. + ///Values must be either zero or positive. It must be larger than [minimumViewportInset]. + /// + ///**NOTE**: available on iOS 15.5+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + EdgeInsets? maximumViewportInset; + ///Specifies a feature policy for the `