updated ChromeSafariBrowser class, Renamed Chrome Custom Tab addShareButton option to addDefaultShareMenuItem, Renamed ChromeSafariBrowser onLoaded to onCompletedInitialLoad, Renamed all iOS and Android webview options class, fix #229, Added packageName and keepAliveEnabled ChromeCustomTab options for Android

This commit is contained in:
Lorenzo Pichilli 2019-12-18 01:56:21 +01:00
parent 9c7ac0da8f
commit 4d752ee9d9
19 changed files with 330 additions and 278 deletions

View File

@ -11,6 +11,7 @@
- Added `reloadFromOrigin` webview method for iOS - Added `reloadFromOrigin` webview method for iOS
- Added `automaticallyAdjustsScrollIndicatorInsets` webview options for iOS - Added `automaticallyAdjustsScrollIndicatorInsets` webview options for iOS
- Added `WebStorageManager` class which manages the web storage used by WebView instances - Added `WebStorageManager` class which manages the web storage used by WebView instances
- Added `packageName` [#229](https://github.com/pichillilorenzo/flutter_inappwebview/issues/229) and `keepAliveEnabled` ChromeCustomTab options for Android
- Updated for Flutter 1.12 new Java Embedding API (Android) - Updated for Flutter 1.12 new Java Embedding API (Android)
- Updated `clearCache` for Android - Updated `clearCache` for Android
- Updated default value for `domStorageEnabled` and `databaseEnabled` options to `true` for Android - Updated default value for `domStorageEnabled` and `databaseEnabled` options to `true` for Android
@ -34,7 +35,9 @@
- Renamed `onPermissionRequest` to `androidOnPermissionRequest` - Renamed `onPermissionRequest` to `androidOnPermissionRequest`
- Updated attribute names for `InAppWebViewWidgetOptions`, `InAppBrowserClassOptions` and `ChromeSafariBrowserClassOptions` classes - Updated attribute names for `InAppWebViewWidgetOptions`, `InAppBrowserClassOptions` and `ChromeSafariBrowserClassOptions` classes
- Renamed and updated `onNavigationStateChange` to `onUpdateVisitedHistory` - Renamed and updated `onNavigationStateChange` to `onUpdateVisitedHistory`
- Renamed all iOS options prefix from `Ios` to `IOS` - Renamed all iOS and Android webview options class
- Renamed Chrome Custom Tab `addShareButton` option to `addDefaultShareMenuItem`
- Renamed ChromeSafariBrowser `onLoaded` to `onCompletedInitialLoad`
## 2.1.0+1 ## 2.1.0+1

View File

@ -641,8 +641,8 @@ Specific options of the `InAppBrowser` class are:
* `toolbarBottomTranslucent`: Set to `true` to set the toolbar at the bottom translucent. The default value is `true`. * `toolbarBottomTranslucent`: Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
* `closeButtonCaption`: Set the custom text for the close button. * `closeButtonCaption`: Set the custom text for the close button.
* `closeButtonColor`: Set the custom color for the close button. * `closeButtonColor`: Set the custom color for the close button.
* `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IosWebViewOptionsPresentationStyle.FULL_SCREEN`. * `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IOSUIModalPresentationStyle.FULL_SCREEN`.
* `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IosWebViewOptionsTransitionStyle.COVER_VERTICAL`. * `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IOSUIModalTransitionStyle.COVER_VERTICAL`.
* `spinner`: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`. * `spinner`: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
#### `InAppBrowser` Events #### `InAppBrowser` Events
@ -698,8 +698,8 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
} }
@override @override
void onLoaded() { void onCompletedInitialLoad() {
print("ChromeSafari browser loaded"); print("ChromeSafari browser initial load completed");
} }
@override @override
@ -737,7 +737,7 @@ class _MyAppState extends State<MyApp> {
await widget.browser.open( await widget.browser.open(
url: "https://flutter.dev/", url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions( options: ChromeSafariBrowserClassOptions(
android: AndroidChromeCustomTabsOptions(addShareButton: false), android: AndroidChromeCustomTabsOptions(addDefaultShareMenuItem: false),
ios: IosSafariOptions(barCollapsingEnabled: true))); ios: IosSafariOptions(barCollapsingEnabled: true)));
}, },
child: Text("Open Chrome Safari Browser")), child: Text("Open Chrome Safari Browser")),
@ -767,26 +767,28 @@ Screenshots:
##### `ChromeSafariBrowser` Android-specific options ##### `ChromeSafariBrowser` Android-specific options
* `addShareButton`: Set to `false` if you don't want the default share button. The default value is `true`. * `addDefaultShareMenuItem`: Set to `false` if you don't want the default share item to the menu. The default value is `true`.
* `showTitle`: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. * `showTitle`: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
* `toolbarBackgroundColor`: Set the custom background color of the toolbar. * `toolbarBackgroundColor`: Set the custom background color of the toolbar.
* `enableUrlBarHiding`: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`. * `enableUrlBarHiding`: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
* `instantAppsEnabled`: Set to `true` to enable Instant Apps. The default value is `false`. * `instantAppsEnabled`: Set to `true` to enable Instant Apps. The default value is `false`.
* `packageName`: Set the name of the application package to handle the intent (for example `com.android.chrome`), or null to allow any application package.
* `keepAliveEnabled`: Set to `true` to enable Keep Alive. The default value is `false`.
##### `ChromeSafariBrowser` iOS-specific options ##### `ChromeSafariBrowser` iOS-specific options
* `entersReaderIfAvailable`: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. * `entersReaderIfAvailable`: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
* `barCollapsingEnabled`: Set to `true` to enable bar collapsing. The default value is `false`. * `barCollapsingEnabled`: Set to `true` to enable bar collapsing. The default value is `false`.
* `dismissButtonStyle`: Set the custom style for the dismiss button. The default value is `IosSafariOptionsDismissButtonStyle.DONE`. * `dismissButtonStyle`: Set the custom style for the dismiss button. The default value is `IOSSafariDismissButtonStyle.DONE`.
* `preferredBarTintColor`: Set the custom background color of the navigation bar and the toolbar. * `preferredBarTintColor`: Set the custom background color of the navigation bar and the toolbar.
* `preferredControlTintColor`: Set the custom color of the control buttons on the navigation bar and the toolbar. * `preferredControlTintColor`: Set the custom color of the control buttons on the navigation bar and the toolbar.
* `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IosWebViewOptionsPresentationStyle.FULL_SCREEN`. * `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IOSUIModalPresentationStyle.FULL_SCREEN`.
* `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IosWebViewOptionsTransitionStyle.COVER_VERTICAL`. * `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IOSUIModalTransitionStyle.COVER_VERTICAL`.
#### `ChromeSafariBrowser` Events #### `ChromeSafariBrowser` Events
* `onOpened`: Event fires when the `ChromeSafariBrowser` is opened. * `onOpened`: Event fires when the `ChromeSafariBrowser` is opened.
* `onLoaded`: Event fires when the `ChromeSafariBrowser` is loaded. * `onCompletedInitialLoad`: Event fires when the initial URL load is complete.
* `onClosed`: Event fires when the `ChromeSafariBrowser` is closed. * `onClosed`: Event fires when the `ChromeSafariBrowser` is closed.
### `InAppLocalhostServer` class ### `InAppLocalhostServer` class

View File

@ -5,7 +5,12 @@ import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import androidx.browser.customtabs.CustomTabsCallback;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsService;
import androidx.browser.customtabs.CustomTabsSession;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin; import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.R; import com.pichillilorenzo.flutter_inappwebview.R;
@ -20,7 +25,10 @@ public class ChromeCustomTabsActivity extends Activity {
CustomTabsIntent.Builder builder; CustomTabsIntent.Builder builder;
ChromeCustomTabsOptions options; ChromeCustomTabsOptions options;
private CustomTabActivityHelper customTabActivityHelper; private CustomTabActivityHelper customTabActivityHelper;
private CustomTabsSession customTabsSession;
private final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100; private final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;
private boolean onChromeSafariBrowserOpened = false;
private boolean onChromeSafariBrowserCompletedInitialLoad = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -31,30 +39,82 @@ public class ChromeCustomTabsActivity extends Activity {
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
assert b != null; assert b != null;
uuid = b.getString("uuid"); uuid = b.getString("uuid");
String url = b.getString("url"); final String url = b.getString("url");
options = new ChromeCustomTabsOptions(); options = new ChromeCustomTabsOptions();
options.parse((HashMap<String, Object>) b.getSerializable("options")); options.parse((HashMap<String, Object>) b.getSerializable("options"));
InAppWebViewFlutterPlugin.inAppBrowser.chromeCustomTabsActivities.put(uuid, this); InAppWebViewFlutterPlugin.inAppBrowser.chromeCustomTabsActivities.put(uuid, this);
final ChromeCustomTabsActivity chromeCustomTabsActivity = this;
customTabActivityHelper = new CustomTabActivityHelper(); customTabActivityHelper = new CustomTabActivityHelper();
builder = new CustomTabsIntent.Builder(); customTabActivityHelper.setConnectionCallback(new CustomTabActivityHelper.ConnectionCallback() {
@Override
public void onCustomTabsConnected() {
customTabsSession = customTabActivityHelper.getSession();
Uri uri = Uri.parse(url);
customTabActivityHelper.mayLaunchUrl(uri, null, null);
prepareCustomTabs(); builder = new CustomTabsIntent.Builder(customTabsSession);
CustomTabsIntent customTabsIntent = builder.build();
prepareCustomTabs(customTabsIntent);
CustomTabActivityHelper.openCustomTab(chromeCustomTabsActivity, customTabsIntent, uri, CHROME_CUSTOM_TAB_REQUEST_CODE);
}
CustomTabsIntent customTabsIntent = builder.build(); @Override
public void onCustomTabsDisconnected() {
customTabsSession = null;
finish();
Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid);
InAppWebViewFlutterPlugin.inAppBrowser.channel.invokeMethod("onChromeSafariBrowserClosed", obj);
}
});
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, Uri.parse(url), CHROME_CUSTOM_TAB_REQUEST_CODE); customTabActivityHelper.setCustomTabsCallback(new CustomTabsCallback() {
@Override
public void onNavigationEvent(int navigationEvent, Bundle extras) {
if (navigationEvent == TAB_SHOWN && !onChromeSafariBrowserOpened) {
onChromeSafariBrowserOpened = true;
Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid);
InAppWebViewFlutterPlugin.inAppBrowser.channel.invokeMethod("onChromeSafariBrowserOpened", obj);
}
Map<String, Object> obj = new HashMap<>(); if (navigationEvent == NAVIGATION_FINISHED && !onChromeSafariBrowserCompletedInitialLoad) {
obj.put("uuid", uuid); onChromeSafariBrowserCompletedInitialLoad = true;
InAppWebViewFlutterPlugin.inAppBrowser.channel.invokeMethod("onChromeSafariBrowserOpened", obj); Map<String, Object> obj = new HashMap<>();
InAppWebViewFlutterPlugin.inAppBrowser.channel.invokeMethod("onChromeSafariBrowserLoaded", obj); obj.put("uuid", uuid);
InAppWebViewFlutterPlugin.inAppBrowser.channel.invokeMethod("onChromeSafariBrowserCompletedInitialLoad", obj);
}
}
@Override
public void extraCallback(String callbackName, Bundle args) {
}
@Override
public void onMessageChannelReady(Bundle extras) {
}
@Override
public void onPostMessage(String message, Bundle extras) {
}
@Override
public void onRelationshipValidationResult(@CustomTabsService.Relation int relation, Uri requestedOrigin,
boolean result, Bundle extras) {
}
});
} }
private void prepareCustomTabs() { private void prepareCustomTabs(CustomTabsIntent customTabsIntent) {
if (options.addShareButton) if (options.addDefaultShareMenuItem)
builder.addDefaultShareMenuItem(); builder.addDefaultShareMenuItem();
if (!options.toolbarBackgroundColor.isEmpty()) if (!options.toolbarBackgroundColor.isEmpty())
@ -66,6 +126,14 @@ public class ChromeCustomTabsActivity extends Activity {
builder.enableUrlBarHiding(); builder.enableUrlBarHiding();
builder.setInstantAppsEnabled(options.instantAppsEnabled); builder.setInstantAppsEnabled(options.instantAppsEnabled);
if (options.packageName != null)
customTabsIntent.intent.setPackage(options.packageName);
else
customTabsIntent.intent.setPackage(CustomTabsHelper.getPackageNameToUse(this));
if (options.keepAliveEnabled)
CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
} }
@Override @Override
@ -83,6 +151,7 @@ public class ChromeCustomTabsActivity extends Activity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) { if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) {
customTabsSession = null;
finish(); finish();
Map<String, Object> obj = new HashMap<>(); Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid); obj.put("uuid", uuid);

View File

@ -6,10 +6,12 @@ public class ChromeCustomTabsOptions extends Options {
final static String LOG_TAG = "ChromeCustomTabsOptions"; final static String LOG_TAG = "ChromeCustomTabsOptions";
public boolean addShareButton = true; public Boolean addDefaultShareMenuItem = true;
public boolean showTitle = true; public Boolean showTitle = true;
public String toolbarBackgroundColor = ""; public String toolbarBackgroundColor = "";
public boolean enableUrlBarHiding = false; public Boolean enableUrlBarHiding = false;
public boolean instantAppsEnabled = false; public Boolean instantAppsEnabled = false;
public String packageName;
public Boolean keepAliveEnabled = false;
} }

View File

@ -3,6 +3,8 @@ package com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs;
import android.app.Activity; import android.app.Activity;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.browser.customtabs.CustomTabsCallback;
import androidx.browser.customtabs.CustomTabsClient; import androidx.browser.customtabs.CustomTabsClient;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsServiceConnection; import androidx.browser.customtabs.CustomTabsServiceConnection;
@ -18,6 +20,7 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
private CustomTabsClient mClient; private CustomTabsClient mClient;
private CustomTabsServiceConnection mConnection; private CustomTabsServiceConnection mConnection;
private ConnectionCallback mConnectionCallback; private ConnectionCallback mConnectionCallback;
private CustomTabsCallback mCustomTabsCallback;
/** /**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView. * Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView.
@ -59,7 +62,7 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
if (mClient == null) { if (mClient == null) {
mCustomTabsSession = null; mCustomTabsSession = null;
} else if (mCustomTabsSession == null) { } else if (mCustomTabsSession == null) {
mCustomTabsSession = mClient.newSession(null); mCustomTabsSession = mClient.newSession(mCustomTabsCallback);
} }
return mCustomTabsSession; return mCustomTabsSession;
} }
@ -72,6 +75,10 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
this.mConnectionCallback = connectionCallback; this.mConnectionCallback = connectionCallback;
} }
public void setCustomTabsCallback(CustomTabsCallback customTabsCallback) {
this.mCustomTabsCallback = customTabsCallback;
}
/** /**
* Binds the Activity to the Custom Tabs Service. * Binds the Activity to the Custom Tabs Service.
* @param activity the activity to be binded to the service. * @param activity the activity to be binded to the service.

View File

@ -9,6 +9,8 @@ import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.browser.customtabs.CustomTabsService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -23,8 +25,6 @@ public class CustomTabsHelper {
static final String LOCAL_PACKAGE = "com.google.android.apps.chrome"; static final String LOCAL_PACKAGE = "com.google.android.apps.chrome";
private static final String EXTRA_CUSTOM_TABS_KEEP_ALIVE = private static final String EXTRA_CUSTOM_TABS_KEEP_ALIVE =
"android.support.customtabs.extra.KEEP_ALIVE"; "android.support.customtabs.extra.KEEP_ALIVE";
private static final String ACTION_CUSTOM_TABS_CONNECTION =
"android.support.customtabs.action.CustomTabsService";
private static String sPackageNameToUse; private static String sPackageNameToUse;
@ -63,7 +63,7 @@ public class CustomTabsHelper {
List<String> packagesSupportingCustomTabs = new ArrayList<>(); List<String> packagesSupportingCustomTabs = new ArrayList<>();
for (ResolveInfo info : resolvedActivityList) { for (ResolveInfo info : resolvedActivityList) {
Intent serviceIntent = new Intent(); Intent serviceIntent = new Intent();
serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION); serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
serviceIntent.setPackage(info.activityInfo.packageName); serviceIntent.setPackage(info.activityInfo.packageName);
if (pm.resolveService(serviceIntent, 0) != null) { if (pm.resolveService(serviceIntent, 0) != null) {
packagesSupportingCustomTabs.add(info.activityInfo.packageName); packagesSupportingCustomTabs.add(info.activityInfo.packageName);

View File

@ -4,13 +4,13 @@ public class InAppBrowserOptions extends Options {
public static final String LOG_TAG = "InAppBrowserOptions"; public static final String LOG_TAG = "InAppBrowserOptions";
public boolean hidden = false; public Boolean hidden = false;
public boolean toolbarTop = true; public Boolean toolbarTop = true;
public String toolbarTopBackgroundColor = ""; public String toolbarTopBackgroundColor = "";
public String toolbarTopFixedTitle = ""; public String toolbarTopFixedTitle = "";
public boolean hideUrlBar = false; public Boolean hideUrlBar = false;
public boolean hideTitleBar = false; public Boolean hideTitleBar = false;
public boolean closeOnCannotGoBack = true; public Boolean closeOnCannotGoBack = true;
public boolean progressBar = true; public Boolean progressBar = true;
} }

View File

@ -1,4 +1,4 @@
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">

View File

@ -1,4 +1,4 @@
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">

View File

@ -1,4 +1,4 @@
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">

View File

@ -12,8 +12,8 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
} }
@override @override
void onLoaded() { void onCompletedInitialLoad() {
print("ChromeSafari browser loaded"); print("ChromeSafari browser initial load completed");
} }
@override @override
@ -52,7 +52,7 @@ class _ChromeSafariBrowserExampleScreenState
await widget.browser.open( await widget.browser.open(
url: "https://flutter.dev/", url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions( options: ChromeSafariBrowserClassOptions(
android: AndroidChromeCustomTabsOptions(addShareButton: false), android: AndroidChromeCustomTabsOptions(addDefaultShareMenuItem: false, keepAliveEnabled: true),
ios: IOSSafariOptions(barCollapsingEnabled: true))); ios: IOSSafariOptions(barCollapsingEnabled: true)));
}, },
child: Text("Open Chrome Safari Browser")), child: Text("Open Chrome Safari Browser")),

View File

@ -71,29 +71,6 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
setState(() { setState(() {
this.url = url; this.url = url;
}); });
/*var origins = await WebStorageManager.instance().android.getOrigins();
for (var origin in origins) {
print(origin);
print(await WebStorageManager.instance().android.getQuotaForOrigin(origin: origin.origin));
print(await WebStorageManager.instance().android.getUsageForOrigin(origin: origin.origin));
}
await WebStorageManager.instance().android.deleteAllData();
print("\n\nDELETED\n\n");
origins = await WebStorageManager.instance().android.getOrigins();
for (var origin in origins) {
print(origin);
await WebStorageManager.instance().android.deleteOrigin(origin: origin.origin);
}*/
/*var records = await WebStorageManager.instance().ios.fetchDataRecords(dataTypes: IOSWKWebsiteDataType.ALL);
for(var record in records) {
print(record);
}
await WebStorageManager.instance().ios.removeDataModifiedSince(dataTypes: IOSWKWebsiteDataType.ALL, date: DateTime(0));
print("\n\nDELETED\n\n");
records = await WebStorageManager.instance().ios.fetchDataRecords(dataTypes: IOSWKWebsiteDataType.ALL);
for(var record in records) {
print(record);
}*/
}, },
onProgressChanged: (InAppWebViewController controller, int progress) { onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() { setState(() {

View File

@ -1036,8 +1036,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
dataDetectorTypes = WKDataDetectorTypes(rawValue: dataDetectorTypes.rawValue | dataDetectorType.rawValue) dataDetectorTypes = WKDataDetectorTypes(rawValue: dataDetectorTypes.rawValue | dataDetectorType.rawValue)
} }
configuration.dataDetectorTypes = dataDetectorTypes configuration.dataDetectorTypes = dataDetectorTypes
} else {
// Fallback on earlier versions
} }
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
@ -1046,8 +1044,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.defaultWebpagePreferences.preferredContentMode = WKWebpagePreferences.ContentMode(rawValue: (options?.preferredContentMode)!)! configuration.defaultWebpagePreferences.preferredContentMode = WKWebpagePreferences.ContentMode(rawValue: (options?.preferredContentMode)!)!
} }
scrollView.automaticallyAdjustsScrollIndicatorInsets = (options?.automaticallyAdjustsScrollIndicatorInsets)! scrollView.automaticallyAdjustsScrollIndicatorInsets = (options?.automaticallyAdjustsScrollIndicatorInsets)!
} else {
// Fallback on earlier versions
} }
scrollView.showsVerticalScrollIndicator = (options?.verticalScrollBarEnabled)! scrollView.showsVerticalScrollIndicator = (options?.verticalScrollBarEnabled)!
@ -1110,8 +1106,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.setURLSchemeHandler(CustomeSchemeHandler(), forURLScheme: scheme) configuration.setURLSchemeHandler(CustomeSchemeHandler(), forURLScheme: scheme)
} }
} }
} else {
// Fallback on earlier versions
} }
return configuration return configuration
@ -1335,12 +1329,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
} }
configuration.dataDetectorTypes = dataDetectorTypes configuration.dataDetectorTypes = dataDetectorTypes
} }
} else {
// Fallback on earlier versions
} }
scrollView
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
if newOptionsMap["isFraudulentWebsiteWarningEnabled"] != nil && options?.isFraudulentWebsiteWarningEnabled != newOptions.isFraudulentWebsiteWarningEnabled { if newOptionsMap["isFraudulentWebsiteWarningEnabled"] != nil && options?.isFraudulentWebsiteWarningEnabled != newOptions.isFraudulentWebsiteWarningEnabled {
configuration.preferences.isFraudulentWebsiteWarningEnabled = newOptions.isFraudulentWebsiteWarningEnabled configuration.preferences.isFraudulentWebsiteWarningEnabled = newOptions.isFraudulentWebsiteWarningEnabled
@ -1351,8 +1341,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if newOptionsMap["automaticallyAdjustsScrollIndicatorInsets"] != nil && options?.automaticallyAdjustsScrollIndicatorInsets != newOptions.automaticallyAdjustsScrollIndicatorInsets { if newOptionsMap["automaticallyAdjustsScrollIndicatorInsets"] != nil && options?.automaticallyAdjustsScrollIndicatorInsets != newOptions.automaticallyAdjustsScrollIndicatorInsets {
scrollView.automaticallyAdjustsScrollIndicatorInsets = newOptions.automaticallyAdjustsScrollIndicatorInsets scrollView.automaticallyAdjustsScrollIndicatorInsets = newOptions.automaticallyAdjustsScrollIndicatorInsets
} }
} else {
// Fallback on earlier versions
} }
if newOptionsMap["verticalScrollBarEnabled"] != nil && options?.verticalScrollBarEnabled != newOptions.verticalScrollBarEnabled { if newOptionsMap["verticalScrollBarEnabled"] != nil && options?.verticalScrollBarEnabled != newOptions.verticalScrollBarEnabled {

View File

@ -59,13 +59,32 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
func safariViewController(_ controller: SFSafariViewController, func safariViewController(_ controller: SFSafariViewController,
didCompleteInitialLoad didLoadSuccessfully: Bool) { didCompleteInitialLoad didLoadSuccessfully: Bool) {
if didLoadSuccessfully { if didLoadSuccessfully {
statusDelegate?.onChromeSafariBrowserLoaded(uuid: self.uuid) statusDelegate?.onChromeSafariBrowserCompletedInitialLoad(uuid: self.uuid)
} }
else { else {
print("Cant load successfully the 'SafariViewController'.") print("Cant load successfully the 'SafariViewController'.")
} }
} }
func safariViewController(_ controller: SFSafariViewController, activityItemsFor URL: URL, title: String?) -> [UIActivity] {
// print("activityItemsFor")
// print(URL)
// print(title)
return []
}
func safariViewController(_ controller: SFSafariViewController, excludedActivityTypesFor URL: URL, title: String?) -> [UIActivity.ActivityType] {
// print("excludedActivityTypesFor")
// print(URL)
// print(title)
return []
}
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo URL: URL) {
// print("initialLoadDidRedirectTo")
// print(URL)
}
// Helper function to convert hex color string to UIColor // Helper function to convert hex color string to UIColor
// Assumes input like "#00FF00" (#RRGGBB). // Assumes input like "#00FF00" (#RRGGBB).
// Taken from https://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string // Taken from https://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string

View File

@ -432,11 +432,10 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
safari.safariOptions = safariOptions safari.safariOptions = safariOptions
self.safariViewControllers[uuid] = safari self.safariViewControllers[uuid] = safari
tmpController.present(self.safariViewControllers[uuid]! as! SFSafariViewController, animated: true) {
tmpController.present(self.safariViewControllers[uuid]! as! SFSafariViewController, animated: true) self.onChromeSafariBrowserOpened(uuid: uuid)
onChromeSafariBrowserOpened(uuid: uuid) result(true)
result(true) }
return return
} }
else { else {
@ -742,9 +741,9 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
} }
} }
public func onChromeSafariBrowserLoaded(uuid: String) { public func onChromeSafariBrowserCompletedInitialLoad(uuid: String) {
if self.safariViewControllers[uuid] != nil { if self.safariViewControllers[uuid] != nil {
self.channel!.invokeMethod("onChromeSafariBrowserLoaded", arguments: ["uuid": uuid]) self.channel!.invokeMethod("onChromeSafariBrowserCompletedInitialLoad", arguments: ["uuid": uuid])
} }
} }

View File

@ -1,30 +0,0 @@
//
// TestWebView.swift
// flutter_inappwebview
//
// Created by Lorenzo Pichilli on 14/12/2019.
//
import Flutter
import Foundation
import WebKit
public class TestWebView: WKWebView {
override init(frame: CGRect, configuration: WKWebViewConfiguration) {
super.init(frame: frame, configuration: configuration)
}
required public init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
public override func removeFromSuperview() {
configuration.userContentController.removeAllUserScripts()
super.removeFromSuperview()
print("\n\n DISPOSE \n\n")
}
deinit {
print("dealloc") // never called
}
}

View File

@ -32,8 +32,8 @@ class ChromeSafariBrowser {
case "onChromeSafariBrowserOpened": case "onChromeSafariBrowserOpened":
onOpened(); onOpened();
break; break;
case "onChromeSafariBrowserLoaded": case "onChromeSafariBrowserCompletedInitialLoad":
onLoaded(); onCompletedInitialLoad();
break; break;
case "onChromeSafariBrowserClosed": case "onChromeSafariBrowserClosed":
onClosed(); onClosed();
@ -109,8 +109,8 @@ class ChromeSafariBrowser {
///Event fires when the [ChromeSafariBrowser] is opened. ///Event fires when the [ChromeSafariBrowser] is opened.
void onOpened() {} void onOpened() {}
///Event fires when the [ChromeSafariBrowser] is loaded. ///Event fires when the initial URL load is complete.
void onLoaded() {} void onCompletedInitialLoad() {}
///Event fires when the [ChromeSafariBrowser] is closed. ///Event fires when the [ChromeSafariBrowser] is closed.
void onClosed() {} void onClosed() {}

View File

@ -723,13 +723,13 @@ class Favicon {
} }
} }
///AndroidInAppWebViewCacheMode class represents an Android-specific class used to override the way the cache is used. ///AndroidCacheMode class represents an Android-specific class used to override the way the cache is used.
class AndroidInAppWebViewCacheMode { class AndroidCacheMode {
final int _value; final int _value;
const AndroidInAppWebViewCacheMode._internal(this._value); const AndroidCacheMode._internal(this._value);
static AndroidInAppWebViewCacheMode fromValue(int value) { static AndroidCacheMode fromValue(int value) {
if (value != null && value >= 0 && value <= 3) if (value != null && value >= 0 && value <= 3)
return AndroidInAppWebViewCacheMode._internal(value); return AndroidCacheMode._internal(value);
return null; return null;
} }
@ -751,18 +751,18 @@ class AndroidInAppWebViewCacheMode {
///Default cache usage mode. If the navigation type doesn't impose any specific behavior, ///Default cache usage mode. If the navigation type doesn't impose any specific behavior,
///use cached resources when they are available and not expired, otherwise load resources from the network. ///use cached resources when they are available and not expired, otherwise load resources from the network.
static const LOAD_DEFAULT = const AndroidInAppWebViewCacheMode._internal(-1); static const LOAD_DEFAULT = const AndroidCacheMode._internal(-1);
///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network. ///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network.
static const LOAD_CACHE_ELSE_NETWORK = static const LOAD_CACHE_ELSE_NETWORK =
const AndroidInAppWebViewCacheMode._internal(1); const AndroidCacheMode._internal(1);
///Don't use the cache, load from the network. ///Don't use the cache, load from the network.
static const LOAD_NO_CACHE = const AndroidInAppWebViewCacheMode._internal(2); static const LOAD_NO_CACHE = const AndroidCacheMode._internal(2);
///Don't use the network, load from the cache. ///Don't use the network, load from the cache.
static const LOAD_CACHE_ONLY = static const LOAD_CACHE_ONLY =
const AndroidInAppWebViewCacheMode._internal(3); const AndroidCacheMode._internal(3);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -770,15 +770,15 @@ class AndroidInAppWebViewCacheMode {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///AndroidInAppWebViewModeMenuItem class represents an Android-specific class used to disable the action mode menu items. ///AndroidActionModeMenuItem class represents an Android-specific class used to disable the action mode menu items.
/// ///
///**NOTE**: available on Android 24+. ///**NOTE**: available on Android 24+.
class AndroidInAppWebViewModeMenuItem { class AndroidActionModeMenuItem {
final int _value; final int _value;
const AndroidInAppWebViewModeMenuItem._internal(this._value); const AndroidActionModeMenuItem._internal(this._value);
static AndroidInAppWebViewModeMenuItem fromValue(int value) { static AndroidActionModeMenuItem fromValue(int value) {
if (value != null && value != 3 && value >= 0 && value <= 4) if (value != null && value != 3 && value >= 0 && value <= 4)
return AndroidInAppWebViewModeMenuItem._internal(value); return AndroidActionModeMenuItem._internal(value);
return null; return null;
} }
@ -800,19 +800,19 @@ class AndroidInAppWebViewModeMenuItem {
///No menu items should be disabled. ///No menu items should be disabled.
static const MENU_ITEM_NONE = static const MENU_ITEM_NONE =
const AndroidInAppWebViewModeMenuItem._internal(0); const AndroidActionModeMenuItem._internal(0);
///Disable menu item "Share". ///Disable menu item "Share".
static const MENU_ITEM_SHARE = static const MENU_ITEM_SHARE =
const AndroidInAppWebViewModeMenuItem._internal(1); const AndroidActionModeMenuItem._internal(1);
///Disable menu item "Web Search". ///Disable menu item "Web Search".
static const MENU_ITEM_WEB_SEARCH = static const MENU_ITEM_WEB_SEARCH =
const AndroidInAppWebViewModeMenuItem._internal(2); const AndroidActionModeMenuItem._internal(2);
///Disable all the action mode menu items for text processing. ///Disable all the action mode menu items for text processing.
static const MENU_ITEM_PROCESS_TEXT = static const MENU_ITEM_PROCESS_TEXT =
const AndroidInAppWebViewModeMenuItem._internal(4); const AndroidActionModeMenuItem._internal(4);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -820,15 +820,15 @@ class AndroidInAppWebViewModeMenuItem {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///AndroidInAppWebViewForceDark class represents an Android-specific class used to indicate the force dark mode. ///AndroidForceDark class represents an Android-specific class used to indicate the force dark mode.
/// ///
///**NOTE**: available on Android 29+. ///**NOTE**: available on Android 29+.
class AndroidInAppWebViewForceDark { class AndroidForceDark {
final int _value; final int _value;
const AndroidInAppWebViewForceDark._internal(this._value); const AndroidForceDark._internal(this._value);
static AndroidInAppWebViewForceDark fromValue(int value) { static AndroidForceDark fromValue(int value) {
if (value != null && value >= 0 && value <= 2) if (value != null && value >= 0 && value <= 2)
return AndroidInAppWebViewForceDark._internal(value); return AndroidForceDark._internal(value);
return null; return null;
} }
@ -848,14 +848,14 @@ class AndroidInAppWebViewForceDark {
///Disable force dark, irrespective of the force dark mode of the WebView parent. ///Disable force dark, irrespective of the force dark mode of the WebView parent.
///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
static const FORCE_DARK_OFF = const AndroidInAppWebViewForceDark._internal(0); static const FORCE_DARK_OFF = const AndroidForceDark._internal(0);
///Enable force dark dependent on the state of the WebView parent view. ///Enable force dark dependent on the state of the WebView parent view.
static const FORCE_DARK_AUTO = static const FORCE_DARK_AUTO =
const AndroidInAppWebViewForceDark._internal(1); const AndroidForceDark._internal(1);
///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme.
static const FORCE_DARK_ON = const AndroidInAppWebViewForceDark._internal(2); static const FORCE_DARK_ON = const AndroidForceDark._internal(2);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -863,13 +863,13 @@ class AndroidInAppWebViewForceDark {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///AndroidInAppWebViewLayoutAlgorithm class represents an Android-specific class used to set the underlying layout algorithm. ///AndroidLayoutAlgorithm class represents an Android-specific class used to set the underlying layout algorithm.
class AndroidInAppWebViewLayoutAlgorithm { class AndroidLayoutAlgorithm {
final String _value; final String _value;
const AndroidInAppWebViewLayoutAlgorithm._internal(this._value); const AndroidLayoutAlgorithm._internal(this._value);
static AndroidInAppWebViewLayoutAlgorithm fromValue(String value) { static AndroidLayoutAlgorithm fromValue(String value) {
return (["NORMAL", "TEXT_AUTOSIZING"].contains(value)) return (["NORMAL", "TEXT_AUTOSIZING"].contains(value))
? AndroidInAppWebViewLayoutAlgorithm._internal(value) ? AndroidLayoutAlgorithm._internal(value)
: null; : null;
} }
@ -879,14 +879,14 @@ class AndroidInAppWebViewLayoutAlgorithm {
///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions.
static const NORMAL = static const NORMAL =
const AndroidInAppWebViewLayoutAlgorithm._internal("NORMAL"); const AndroidLayoutAlgorithm._internal("NORMAL");
///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode.
///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode.
/// ///
///**NOTE**: available on Android 19+. ///**NOTE**: available on Android 19+.
static const TEXT_AUTOSIZING = static const TEXT_AUTOSIZING =
const AndroidInAppWebViewLayoutAlgorithm._internal("TEXT_AUTOSIZING"); const AndroidLayoutAlgorithm._internal("TEXT_AUTOSIZING");
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -894,15 +894,15 @@ class AndroidInAppWebViewLayoutAlgorithm {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///AndroidInAppWebViewMixedContentMode class represents an Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. ///AndroidMixedContentMode class represents an Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
/// ///
///**NOTE**: available on Android 21+. ///**NOTE**: available on Android 21+.
class AndroidInAppWebViewMixedContentMode { class AndroidMixedContentMode {
final int _value; final int _value;
const AndroidInAppWebViewMixedContentMode._internal(this._value); const AndroidMixedContentMode._internal(this._value);
static AndroidInAppWebViewMixedContentMode fromValue(int value) { static AndroidMixedContentMode fromValue(int value) {
if (value != null && value >= 0 && value <= 2) if (value != null && value >= 0 && value <= 2)
return AndroidInAppWebViewMixedContentMode._internal(value); return AndroidMixedContentMode._internal(value);
return null; return null;
} }
@ -923,20 +923,20 @@ class AndroidInAppWebViewMixedContentMode {
///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode.
static const MIXED_CONTENT_ALWAYS_ALLOW = static const MIXED_CONTENT_ALWAYS_ALLOW =
const AndroidInAppWebViewMixedContentMode._internal(0); const AndroidMixedContentMode._internal(0);
///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin.
///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode.
static const MIXED_CONTENT_NEVER_ALLOW = static const MIXED_CONTENT_NEVER_ALLOW =
const AndroidInAppWebViewMixedContentMode._internal(1); const AndroidMixedContentMode._internal(1);
///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked.
///The types of content are allowed or blocked may change release to release and are not explicitly defined. ///The types of content are allowed or blocked may change release to release and are not explicitly defined.
///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment.
///For highest security, apps are recommended to use [AndroidInAppWebViewMixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. ///For highest security, apps are recommended to use [AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW].
static const MIXED_CONTENT_COMPATIBILITY_MODE = static const MIXED_CONTENT_COMPATIBILITY_MODE =
const AndroidInAppWebViewMixedContentMode._internal(2); const AndroidMixedContentMode._internal(2);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -944,13 +944,13 @@ class AndroidInAppWebViewMixedContentMode {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///IOSInAppWebViewSelectionGranularity class represents an iOS-specific class used to set the level of granularity with which the user can interactively select content in the web view. ///IOSWKSelectionGranularity class represents an iOS-specific class used to set the level of granularity with which the user can interactively select content in the web view.
class IOSInAppWebViewSelectionGranularity { class IOSWKSelectionGranularity {
final int _value; final int _value;
const IOSInAppWebViewSelectionGranularity._internal(this._value); const IOSWKSelectionGranularity._internal(this._value);
static IOSInAppWebViewSelectionGranularity fromValue(int value) { static IOSWKSelectionGranularity fromValue(int value) {
if (value != null && value >= 0 && value <= 1) if (value != null && value >= 0 && value <= 1)
return IOSInAppWebViewSelectionGranularity._internal(value); return IOSWKSelectionGranularity._internal(value);
return null; return null;
} }
@ -967,11 +967,11 @@ class IOSInAppWebViewSelectionGranularity {
} }
///Selection granularity varies automatically based on the selection. ///Selection granularity varies automatically based on the selection.
static const DYNAMIC = const IOSInAppWebViewSelectionGranularity._internal(0); static const DYNAMIC = const IOSWKSelectionGranularity._internal(0);
///Selection endpoints can be placed at any character boundary. ///Selection endpoints can be placed at any character boundary.
static const CHARACTER = static const CHARACTER =
const IOSInAppWebViewSelectionGranularity._internal(1); const IOSWKSelectionGranularity._internal(1);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -979,13 +979,13 @@ class IOSInAppWebViewSelectionGranularity {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///IOSInAppWebViewDataDetectorTypes class represents an iOS-specific class used to specify a dataDetectoryTypes value that adds interactivity to web content that matches the value. ///IOSWKDataDetectorTypes class represents an iOS-specific class used to specify a dataDetectoryTypes value that adds interactivity to web content that matches the value.
/// ///
///**NOTE**: available on iOS 10.0+. ///**NOTE**: available on iOS 10.0+.
class IOSInAppWebViewDataDetectorTypes { class IOSWKDataDetectorTypes {
final String _value; final String _value;
const IOSInAppWebViewDataDetectorTypes._internal(this._value); const IOSWKDataDetectorTypes._internal(this._value);
static IOSInAppWebViewDataDetectorTypes fromValue(String value) { static IOSWKDataDetectorTypes fromValue(String value) {
return ([ return ([
"NONE", "NONE",
"PHONE_NUMBER", "PHONE_NUMBER",
@ -999,7 +999,7 @@ class IOSInAppWebViewDataDetectorTypes {
"SPOTLIGHT_SUGGESTION", "SPOTLIGHT_SUGGESTION",
"ALL" "ALL"
].contains(value)) ].contains(value))
? IOSInAppWebViewDataDetectorTypes._internal(value) ? IOSWKDataDetectorTypes._internal(value)
: null; : null;
} }
@ -1008,41 +1008,41 @@ class IOSInAppWebViewDataDetectorTypes {
String toString() => _value; String toString() => _value;
///No detection is performed. ///No detection is performed.
static const NONE = const IOSInAppWebViewDataDetectorTypes._internal("NONE"); static const NONE = const IOSWKDataDetectorTypes._internal("NONE");
///Phone numbers are detected and turned into links. ///Phone numbers are detected and turned into links.
static const PHONE_NUMBER = static const PHONE_NUMBER =
const IOSInAppWebViewDataDetectorTypes._internal("PHONE_NUMBER"); const IOSWKDataDetectorTypes._internal("PHONE_NUMBER");
///URLs in text are detected and turned into links. ///URLs in text are detected and turned into links.
static const LINK = const IOSInAppWebViewDataDetectorTypes._internal("LINK"); static const LINK = const IOSWKDataDetectorTypes._internal("LINK");
///Addresses are detected and turned into links. ///Addresses are detected and turned into links.
static const ADDRESS = static const ADDRESS =
const IOSInAppWebViewDataDetectorTypes._internal("ADDRESS"); const IOSWKDataDetectorTypes._internal("ADDRESS");
///Dates and times that are in the future are detected and turned into links. ///Dates and times that are in the future are detected and turned into links.
static const CALENDAR_EVENT = static const CALENDAR_EVENT =
const IOSInAppWebViewDataDetectorTypes._internal("CALENDAR_EVENT"); const IOSWKDataDetectorTypes._internal("CALENDAR_EVENT");
///Tracking numbers are detected and turned into links. ///Tracking numbers are detected and turned into links.
static const TRACKING_NUMBER = static const TRACKING_NUMBER =
const IOSInAppWebViewDataDetectorTypes._internal("TRACKING_NUMBER"); const IOSWKDataDetectorTypes._internal("TRACKING_NUMBER");
///Flight numbers are detected and turned into links. ///Flight numbers are detected and turned into links.
static const FLIGHT_NUMBER = static const FLIGHT_NUMBER =
const IOSInAppWebViewDataDetectorTypes._internal("FLIGHT_NUMBER"); const IOSWKDataDetectorTypes._internal("FLIGHT_NUMBER");
///Lookup suggestions are detected and turned into links. ///Lookup suggestions are detected and turned into links.
static const LOOKUP_SUGGESTION = static const LOOKUP_SUGGESTION =
const IOSInAppWebViewDataDetectorTypes._internal("LOOKUP_SUGGESTION"); const IOSWKDataDetectorTypes._internal("LOOKUP_SUGGESTION");
///Spotlight suggestions are detected and turned into links. ///Spotlight suggestions are detected and turned into links.
static const SPOTLIGHT_SUGGESTION = static const SPOTLIGHT_SUGGESTION =
const IOSInAppWebViewDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); const IOSWKDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION");
///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added.
static const ALL = const IOSInAppWebViewDataDetectorTypes._internal("ALL"); static const ALL = const IOSWKDataDetectorTypes._internal("ALL");
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -1050,13 +1050,13 @@ class IOSInAppWebViewDataDetectorTypes {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///InAppWebViewUserPreferredContentMode class represents the content mode to prefer when loading and rendering a webpage. ///UserPreferredContentMode class represents the content mode to prefer when loading and rendering a webpage.
class InAppWebViewUserPreferredContentMode { class UserPreferredContentMode {
final int _value; final int _value;
const InAppWebViewUserPreferredContentMode._internal(this._value); const UserPreferredContentMode._internal(this._value);
static InAppWebViewUserPreferredContentMode fromValue(int value) { static UserPreferredContentMode fromValue(int value) {
if (value != null && value >= 0 && value <= 2) if (value != null && value >= 0 && value <= 2)
return InAppWebViewUserPreferredContentMode._internal(value); return UserPreferredContentMode._internal(value);
return null; return null;
} }
@ -1076,14 +1076,14 @@ class InAppWebViewUserPreferredContentMode {
///The recommended content mode for the current platform. ///The recommended content mode for the current platform.
static const RECOMMENDED = static const RECOMMENDED =
const InAppWebViewUserPreferredContentMode._internal(0); const UserPreferredContentMode._internal(0);
///Represents content targeting mobile browsers. ///Represents content targeting mobile browsers.
static const MOBILE = const InAppWebViewUserPreferredContentMode._internal(1); static const MOBILE = const UserPreferredContentMode._internal(1);
///Represents content targeting desktop browsers. ///Represents content targeting desktop browsers.
static const DESKTOP = static const DESKTOP =
const InAppWebViewUserPreferredContentMode._internal(2); const UserPreferredContentMode._internal(2);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -1091,13 +1091,13 @@ class InAppWebViewUserPreferredContentMode {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///IOSWebViewOptionsPresentationStyle class represents an iOS-specific class used to specify the modal presentation style when presenting a view controller. ///IOSUIModalPresentationStyle class represents an iOS-specific class used to specify the modal presentation style when presenting a view controller.
class IOSWebViewOptionsPresentationStyle { class IOSUIModalPresentationStyle {
final int _value; final int _value;
const IOSWebViewOptionsPresentationStyle._internal(this._value); const IOSUIModalPresentationStyle._internal(this._value);
static IOSWebViewOptionsPresentationStyle fromValue(int value) { static IOSUIModalPresentationStyle fromValue(int value) {
if (value != null && value >= 0 && value <= 9) if (value != null && value >= 0 && value <= 9)
return IOSWebViewOptionsPresentationStyle._internal(value); return IOSUIModalPresentationStyle._internal(value);
return null; return null;
} }
@ -1131,42 +1131,42 @@ class IOSWebViewOptionsPresentationStyle {
///A presentation style in which the presented view covers the screen. ///A presentation style in which the presented view covers the screen.
static const FULL_SCREEN = static const FULL_SCREEN =
const IOSWebViewOptionsPresentationStyle._internal(0); const IOSUIModalPresentationStyle._internal(0);
///A presentation style that partially covers the underlying content. ///A presentation style that partially covers the underlying content.
static const PAGE_SHEET = static const PAGE_SHEET =
const IOSWebViewOptionsPresentationStyle._internal(1); const IOSUIModalPresentationStyle._internal(1);
///A presentation style that displays the content centered in the screen. ///A presentation style that displays the content centered in the screen.
static const FORM_SHEET = static const FORM_SHEET =
const IOSWebViewOptionsPresentationStyle._internal(2); const IOSUIModalPresentationStyle._internal(2);
///A presentation style where the content is displayed over another view controllers content. ///A presentation style where the content is displayed over another view controllers content.
static const CURRENT_CONTEXT = static const CURRENT_CONTEXT =
const IOSWebViewOptionsPresentationStyle._internal(3); const IOSUIModalPresentationStyle._internal(3);
///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects.
static const CUSTOM = const IOSWebViewOptionsPresentationStyle._internal(4); static const CUSTOM = const IOSUIModalPresentationStyle._internal(4);
///A view presentation style in which the presented view covers the screen. ///A view presentation style in which the presented view covers the screen.
static const OVER_FULL_SCREEN = static const OVER_FULL_SCREEN =
const IOSWebViewOptionsPresentationStyle._internal(5); const IOSUIModalPresentationStyle._internal(5);
///A presentation style where the content is displayed over another view controllers content. ///A presentation style where the content is displayed over another view controllers content.
static const OVER_CURRENT_CONTEXT = static const OVER_CURRENT_CONTEXT =
const IOSWebViewOptionsPresentationStyle._internal(6); const IOSUIModalPresentationStyle._internal(6);
///A presentation style where the content is displayed in a popover view. ///A presentation style where the content is displayed in a popover view.
static const POPOVER = const IOSWebViewOptionsPresentationStyle._internal(7); static const POPOVER = const IOSUIModalPresentationStyle._internal(7);
///A presentation style that indicates no adaptations should be made. ///A presentation style that indicates no adaptations should be made.
static const NONE = const IOSWebViewOptionsPresentationStyle._internal(8); static const NONE = const IOSUIModalPresentationStyle._internal(8);
///The default presentation style chosen by the system. ///The default presentation style chosen by the system.
/// ///
///**NOTE**: available on iOS 13.0+. ///**NOTE**: available on iOS 13.0+.
static const AUTOMATIC = static const AUTOMATIC =
const IOSWebViewOptionsPresentationStyle._internal(9); const IOSUIModalPresentationStyle._internal(9);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -1174,13 +1174,13 @@ class IOSWebViewOptionsPresentationStyle {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///IOSWebViewOptionsTransitionStyle class represents an iOS-specific class used to specify the transition style when presenting a view controller. ///IOSUIModalTransitionStyle class represents an iOS-specific class used to specify the transition style when presenting a view controller.
class IOSWebViewOptionsTransitionStyle { class IOSUIModalTransitionStyle {
final int _value; final int _value;
const IOSWebViewOptionsTransitionStyle._internal(this._value); const IOSUIModalTransitionStyle._internal(this._value);
static IOSWebViewOptionsTransitionStyle fromValue(int value) { static IOSUIModalTransitionStyle fromValue(int value) {
if (value != null && value >= 0 && value <= 3) if (value != null && value >= 0 && value <= 3)
return IOSWebViewOptionsTransitionStyle._internal(value); return IOSUIModalTransitionStyle._internal(value);
return null; return null;
} }
@ -1203,24 +1203,24 @@ class IOSWebViewOptionsTransitionStyle {
///When the view controller is presented, its view slides up from the bottom of the screen. ///When the view controller is presented, its view slides up from the bottom of the screen.
///On dismissal, the view slides back down. This is the default transition style. ///On dismissal, the view slides back down. This is the default transition style.
static const COVER_VERTICAL = static const COVER_VERTICAL =
const IOSWebViewOptionsTransitionStyle._internal(0); const IOSUIModalTransitionStyle._internal(0);
///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left,
///resulting in the revealing of the new view as if it were on the back of the previous view. ///resulting in the revealing of the new view as if it were on the back of the previous view.
///On dismissal, the flip occurs from left-to-right, returning to the original view. ///On dismissal, the flip occurs from left-to-right, returning to the original view.
static const FLIP_HORIZONTAL = static const FLIP_HORIZONTAL =
const IOSWebViewOptionsTransitionStyle._internal(1); const IOSUIModalTransitionStyle._internal(1);
///When the view controller is presented, the current view fades out while the new view fades in at the same time. ///When the view controller is presented, the current view fades out while the new view fades in at the same time.
///On dismissal, a similar type of cross-fade is used to return to the original view. ///On dismissal, a similar type of cross-fade is used to return to the original view.
static const CROSS_DISSOLVE = static const CROSS_DISSOLVE =
const IOSWebViewOptionsTransitionStyle._internal(2); const IOSUIModalTransitionStyle._internal(2);
///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath.
///On dismissal, the curled up page unfurls itself back on top of the presented view. ///On dismissal, the curled up page unfurls itself back on top of the presented view.
///A view controller presented using this transition is itself prevented from presenting any additional view controllers. ///A view controller presented using this transition is itself prevented from presenting any additional view controllers.
static const PARTIAL_CURL = static const PARTIAL_CURL =
const IOSWebViewOptionsTransitionStyle._internal(3); const IOSUIModalTransitionStyle._internal(3);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -1228,15 +1228,15 @@ class IOSWebViewOptionsTransitionStyle {
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
} }
///IOSSafariOptionsDismissButtonStyle class represents an iOS-specific class used to set the custom style for the dismiss button. ///IOSSafariDismissButtonStyle class represents an iOS-specific class used to set the custom style for the dismiss button.
/// ///
///**NOTE**: available on iOS 11.0+. ///**NOTE**: available on iOS 11.0+.
class IOSSafariOptionsDismissButtonStyle { class IOSSafariDismissButtonStyle {
final int _value; final int _value;
const IOSSafariOptionsDismissButtonStyle._internal(this._value); const IOSSafariDismissButtonStyle._internal(this._value);
static IOSSafariOptionsDismissButtonStyle fromValue(int value) { static IOSSafariDismissButtonStyle fromValue(int value) {
if (value != null && value >= 0 && value <= 2) if (value != null && value >= 0 && value <= 2)
return IOSSafariOptionsDismissButtonStyle._internal(value); return IOSSafariDismissButtonStyle._internal(value);
return null; return null;
} }
@ -1255,13 +1255,13 @@ class IOSSafariOptionsDismissButtonStyle {
} }
///Makes the button title the localized string "Done". ///Makes the button title the localized string "Done".
static const DONE = const IOSSafariOptionsDismissButtonStyle._internal(0); static const DONE = const IOSSafariDismissButtonStyle._internal(0);
///Makes the button title the localized string "Close". ///Makes the button title the localized string "Close".
static const CLOSE = const IOSSafariOptionsDismissButtonStyle._internal(1); static const CLOSE = const IOSSafariDismissButtonStyle._internal(1);
///Makes the button title the localized string "Cancel". ///Makes the button title the localized string "Cancel".
static const CANCEL = const IOSSafariOptionsDismissButtonStyle._internal(2); static const CANCEL = const IOSSafariDismissButtonStyle._internal(2);
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;

View File

@ -98,10 +98,10 @@ class InAppWebViewOptions
///**NOTE**: available on iOS 11.0+. ///**NOTE**: available on iOS 11.0+.
List<ContentBlocker> contentBlockers; List<ContentBlocker> contentBlockers;
///Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is [InAppWebViewUserPreferredContentMode.RECOMMENDED]. ///Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is [UserPreferredContentMode.RECOMMENDED].
/// ///
///**NOTE**: available on iOS 13.0+. ///**NOTE**: available on iOS 13.0+.
InAppWebViewUserPreferredContentMode preferredContentMode; UserPreferredContentMode preferredContentMode;
///Set to `true` to be able to listen at the [shouldInterceptAjaxRequest] event. The default value is `false`. ///Set to `true` to be able to listen at the [shouldInterceptAjaxRequest] event. The default value is `false`.
bool useShouldInterceptAjaxRequest; bool useShouldInterceptAjaxRequest;
@ -145,7 +145,7 @@ class InAppWebViewOptions
this.resourceCustomSchemes = const [], this.resourceCustomSchemes = const [],
this.contentBlockers = const [], this.contentBlockers = const [],
this.preferredContentMode = this.preferredContentMode =
InAppWebViewUserPreferredContentMode.RECOMMENDED, UserPreferredContentMode.RECOMMENDED,
this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptAjaxRequest = false,
this.useShouldInterceptFetchRequest = false, this.useShouldInterceptFetchRequest = false,
this.incognito = false, this.incognito = false,
@ -223,7 +223,7 @@ class InAppWebViewOptions
List<String>.from(map["resourceCustomSchemes"] ?? []); List<String>.from(map["resourceCustomSchemes"] ?? []);
options.contentBlockers = contentBlockers; options.contentBlockers = contentBlockers;
options.preferredContentMode = options.preferredContentMode =
InAppWebViewUserPreferredContentMode.fromValue( UserPreferredContentMode.fromValue(
map["preferredContentMode"]); map["preferredContentMode"]);
options.useShouldInterceptAjaxRequest = options.useShouldInterceptAjaxRequest =
map["useShouldInterceptAjaxRequest"]; map["useShouldInterceptAjaxRequest"];
@ -277,7 +277,7 @@ class AndroidInAppWebViewOptions
///Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. ///Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
/// ///
///**NOTE**: available on Android 21+. ///**NOTE**: available on Android 21+.
AndroidInAppWebViewMixedContentMode mixedContentMode; AndroidMixedContentMode mixedContentMode;
///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`. ///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`.
bool allowContentAccess; bool allowContentAccess;
@ -307,8 +307,8 @@ class AndroidInAppWebViewOptions
bool blockNetworkLoads; bool blockNetworkLoads;
///Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed. ///Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed.
///When navigating back, content is not revalidated, instead the content is just retrieved from the cache. The default value is [AndroidInAppWebViewCacheMode.LOAD_DEFAULT]. ///When navigating back, content is not revalidated, instead the content is just retrieved from the cache. The default value is [AndroidCacheMode.LOAD_DEFAULT].
AndroidInAppWebViewCacheMode cacheMode; AndroidCacheMode cacheMode;
///Sets the cursive font family name. The default value is `"cursive"`. ///Sets the cursive font family name. The default value is `"cursive"`.
String cursiveFontFamily; String cursiveFontFamily;
@ -325,7 +325,7 @@ class AndroidInAppWebViewOptions
///Disables the action mode menu items according to menuItems flag. ///Disables the action mode menu items according to menuItems flag.
/// ///
///**NOTE**: available on Android 24+. ///**NOTE**: available on Android 24+.
AndroidInAppWebViewModeMenuItem disabledActionModeMenuItems; AndroidActionModeMenuItem disabledActionModeMenuItems;
///Sets the fantasy font family name. The default value is `"fantasy"`. ///Sets the fantasy font family name. The default value is `"fantasy"`.
String fantasyFontFamily; String fantasyFontFamily;
@ -333,16 +333,16 @@ class AndroidInAppWebViewOptions
///Sets the fixed font family name. The default value is `"monospace"`. ///Sets the fixed font family name. The default value is `"monospace"`.
String fixedFontFamily; String fixedFontFamily;
///Set the force dark mode for this WebView. The default value is [AndroidInAppWebViewForceDark.FORCE_DARK_OFF]. ///Set the force dark mode for this WebView. The default value is [AndroidForceDark.FORCE_DARK_OFF].
/// ///
///**NOTE**: available on Android 29+. ///**NOTE**: available on Android 29+.
AndroidInAppWebViewForceDark forceDark; AndroidForceDark forceDark;
///Sets whether Geolocation API is enabled. The default value is `true`. ///Sets whether Geolocation API is enabled. The default value is `true`.
bool geolocationEnabled; bool geolocationEnabled;
///Sets the underlying layout algorithm. This will cause a re-layout of the WebView. ///Sets the underlying layout algorithm. This will cause a re-layout of the WebView.
AndroidInAppWebViewLayoutAlgorithm layoutAlgorithm; AndroidLayoutAlgorithm layoutAlgorithm;
///Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width. ///Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width.
///This setting is taken into account when the content width is greater than the width of the WebView control, for example, when [useWideViewPort] is enabled. ///This setting is taken into account when the content width is greater than the width of the WebView control, for example, when [useWideViewPort] is enabled.
@ -426,7 +426,7 @@ class AndroidInAppWebViewOptions
this.appCachePath, this.appCachePath,
this.blockNetworkImage = false, this.blockNetworkImage = false,
this.blockNetworkLoads = false, this.blockNetworkLoads = false,
this.cacheMode = AndroidInAppWebViewCacheMode.LOAD_DEFAULT, this.cacheMode = AndroidCacheMode.LOAD_DEFAULT,
this.cursiveFontFamily = "cursive", this.cursiveFontFamily = "cursive",
this.defaultFixedFontSize = 16, this.defaultFixedFontSize = 16,
this.defaultFontSize = 16, this.defaultFontSize = 16,
@ -434,7 +434,7 @@ class AndroidInAppWebViewOptions
this.disabledActionModeMenuItems, this.disabledActionModeMenuItems,
this.fantasyFontFamily = "fantasy", this.fantasyFontFamily = "fantasy",
this.fixedFontFamily = "monospace", this.fixedFontFamily = "monospace",
this.forceDark = AndroidInAppWebViewForceDark.FORCE_DARK_OFF, this.forceDark = AndroidForceDark.FORCE_DARK_OFF,
this.geolocationEnabled = true, this.geolocationEnabled = true,
this.layoutAlgorithm, this.layoutAlgorithm,
this.loadWithOverviewMode = true, this.loadWithOverviewMode = true,
@ -512,7 +512,7 @@ class AndroidInAppWebViewOptions
options.useWideViewPort = map["useWideViewPort"]; options.useWideViewPort = map["useWideViewPort"];
options.safeBrowsingEnabled = map["safeBrowsingEnabled"]; options.safeBrowsingEnabled = map["safeBrowsingEnabled"];
options.mixedContentMode = options.mixedContentMode =
AndroidInAppWebViewMixedContentMode.fromValue(map["mixedContentMode"]); AndroidMixedContentMode.fromValue(map["mixedContentMode"]);
options.allowContentAccess = map["allowContentAccess"]; options.allowContentAccess = map["allowContentAccess"];
options.allowFileAccess = map["allowFileAccess"]; options.allowFileAccess = map["allowFileAccess"];
options.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"]; options.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"];
@ -522,21 +522,21 @@ class AndroidInAppWebViewOptions
options.blockNetworkImage = map["blockNetworkImage"]; options.blockNetworkImage = map["blockNetworkImage"];
options.blockNetworkLoads = map["blockNetworkLoads"]; options.blockNetworkLoads = map["blockNetworkLoads"];
options.cacheMode = options.cacheMode =
AndroidInAppWebViewCacheMode.fromValue(map["cacheMode"]); AndroidCacheMode.fromValue(map["cacheMode"]);
options.cursiveFontFamily = map["cursiveFontFamily"]; options.cursiveFontFamily = map["cursiveFontFamily"];
options.defaultFixedFontSize = map["defaultFixedFontSize"]; options.defaultFixedFontSize = map["defaultFixedFontSize"];
options.defaultFontSize = map["defaultFontSize"]; options.defaultFontSize = map["defaultFontSize"];
options.defaultTextEncodingName = map["defaultTextEncodingName"]; options.defaultTextEncodingName = map["defaultTextEncodingName"];
options.disabledActionModeMenuItems = options.disabledActionModeMenuItems =
AndroidInAppWebViewModeMenuItem.fromValue( AndroidActionModeMenuItem.fromValue(
map["disabledActionModeMenuItems"]); map["disabledActionModeMenuItems"]);
options.fantasyFontFamily = map["fantasyFontFamily"]; options.fantasyFontFamily = map["fantasyFontFamily"];
options.fixedFontFamily = map["fixedFontFamily"]; options.fixedFontFamily = map["fixedFontFamily"];
options.forceDark = options.forceDark =
AndroidInAppWebViewForceDark.fromValue(map["forceDark"]); AndroidForceDark.fromValue(map["forceDark"]);
options.geolocationEnabled = map["geolocationEnabled"]; options.geolocationEnabled = map["geolocationEnabled"];
options.layoutAlgorithm = options.layoutAlgorithm =
AndroidInAppWebViewLayoutAlgorithm.fromValue(map["layoutAlgorithm"]); AndroidLayoutAlgorithm.fromValue(map["layoutAlgorithm"]);
options.loadWithOverviewMode = map["loadWithOverviewMode"]; options.loadWithOverviewMode = map["loadWithOverviewMode"];
options.loadsImagesAutomatically = map["loadsImagesAutomatically"]; options.loadsImagesAutomatically = map["loadsImagesAutomatically"];
options.minimumLogicalFontSize = map["minimumLogicalFontSize"]; options.minimumLogicalFontSize = map["minimumLogicalFontSize"];
@ -599,15 +599,15 @@ class IOSInAppWebViewOptions
bool isFraudulentWebsiteWarningEnabled; bool isFraudulentWebsiteWarningEnabled;
///The level of granularity with which the user can interactively select content in the web view. ///The level of granularity with which the user can interactively select content in the web view.
///The default value is [IOSInAppWebViewSelectionGranularity.DYNAMIC] ///The default value is [IOSWKSelectionGranularity.DYNAMIC]
IOSInAppWebViewSelectionGranularity selectionGranularity; IOSWKSelectionGranularity selectionGranularity;
///Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value. ///Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value.
///For example, Safari adds a link to apple.com in the text Visit apple.com if the dataDetectorTypes property is set to [IOSInAppWebViewDataDetectorTypes.LINK]. ///For example, Safari adds a link to apple.com in the text Visit apple.com if the dataDetectorTypes property is set to [IOSWKDataDetectorTypes.LINK].
///The default value is [IOSInAppWebViewDataDetectorTypes.NONE]. ///The default value is [IOSWKDataDetectorTypes.NONE].
/// ///
///**NOTE**: available on iOS 10.0+. ///**NOTE**: available on iOS 10.0+.
List<IOSInAppWebViewDataDetectorTypes> dataDetectorTypes; List<IOSWKDataDetectorTypes> dataDetectorTypes;
///Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView. ///Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView.
///The default value is `false`. ///The default value is `false`.
@ -632,8 +632,8 @@ class IOSInAppWebViewOptions
this.allowsInlineMediaPlayback = false, this.allowsInlineMediaPlayback = false,
this.allowsPictureInPictureMediaPlayback = true, this.allowsPictureInPictureMediaPlayback = true,
this.isFraudulentWebsiteWarningEnabled = true, this.isFraudulentWebsiteWarningEnabled = true,
this.selectionGranularity = IOSInAppWebViewSelectionGranularity.DYNAMIC, this.selectionGranularity = IOSWKSelectionGranularity.DYNAMIC,
this.dataDetectorTypes = const [IOSInAppWebViewDataDetectorTypes.NONE], this.dataDetectorTypes = const [IOSWKDataDetectorTypes.NONE],
this.sharedCookiesEnabled = false, this.sharedCookiesEnabled = false,
this.automaticallyAdjustsScrollIndicatorInsets = false}); this.automaticallyAdjustsScrollIndicatorInsets = false});
@ -665,12 +665,12 @@ class IOSInAppWebViewOptions
} }
static IOSInAppWebViewOptions fromMap(Map<String, dynamic> map) { static IOSInAppWebViewOptions fromMap(Map<String, dynamic> map) {
List<IOSInAppWebViewDataDetectorTypes> dataDetectorTypes = []; List<IOSWKDataDetectorTypes> dataDetectorTypes = [];
List<String> dataDetectorTypesList = List<String> dataDetectorTypesList =
List<String>.from(map["dataDetectorTypes"] ?? []); List<String>.from(map["dataDetectorTypes"] ?? []);
dataDetectorTypesList.forEach((dataDetectorType) { dataDetectorTypesList.forEach((dataDetectorType) {
dataDetectorTypes dataDetectorTypes
.add(IOSInAppWebViewDataDetectorTypes.fromValue(dataDetectorType)); .add(IOSWKDataDetectorTypes.fromValue(dataDetectorType));
}); });
IOSInAppWebViewOptions options = new IOSInAppWebViewOptions(); IOSInAppWebViewOptions options = new IOSInAppWebViewOptions();
@ -690,7 +690,7 @@ class IOSInAppWebViewOptions
options.isFraudulentWebsiteWarningEnabled = options.isFraudulentWebsiteWarningEnabled =
map["isFraudulentWebsiteWarningEnabled"]; map["isFraudulentWebsiteWarningEnabled"];
options.selectionGranularity = options.selectionGranularity =
IOSInAppWebViewSelectionGranularity.fromValue( IOSWKSelectionGranularity.fromValue(
map["selectionGranularity"]); map["selectionGranularity"]);
options.dataDetectorTypes = dataDetectorTypes; options.dataDetectorTypes = dataDetectorTypes;
options.sharedCookiesEnabled = map["sharedCookiesEnabled"]; options.sharedCookiesEnabled = map["sharedCookiesEnabled"];
@ -798,11 +798,11 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions {
///Set the custom color for the close button. ///Set the custom color for the close button.
String closeButtonColor; String closeButtonColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [IOSWebViewOptionsPresentationStyle.FULL_SCREEN]. ///Set the custom modal presentation style when presenting the WebView. The default value is [IOSUIModalPresentationStyle.FULL_SCREEN].
IOSWebViewOptionsPresentationStyle presentationStyle; IOSUIModalPresentationStyle presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [IOSWebViewOptionsTransitionStyle.COVER_VERTICAL]. ///Set to the custom transition style when presenting the WebView. The default value is [IOSUIModalTransitionStyle.COVER_VERTICAL].
IOSWebViewOptionsTransitionStyle transitionStyle; IOSUIModalTransitionStyle transitionStyle;
///Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`. ///Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
bool spinner; bool spinner;
@ -813,8 +813,8 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions {
this.toolbarBottomTranslucent = true, this.toolbarBottomTranslucent = true,
this.closeButtonCaption = "", this.closeButtonCaption = "",
this.closeButtonColor = "", this.closeButtonColor = "",
this.presentationStyle = IOSWebViewOptionsPresentationStyle.FULL_SCREEN, this.presentationStyle = IOSUIModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = IOSWebViewOptionsTransitionStyle.COVER_VERTICAL, this.transitionStyle = IOSUIModalTransitionStyle.COVER_VERTICAL,
this.spinner = true}); this.spinner = true});
@override @override
@ -839,9 +839,9 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions {
options.closeButtonCaption = map["closeButtonCaption"]; options.closeButtonCaption = map["closeButtonCaption"];
options.closeButtonColor = map["closeButtonColor"]; options.closeButtonColor = map["closeButtonColor"];
options.presentationStyle = options.presentationStyle =
IOSWebViewOptionsPresentationStyle.fromValue(map["presentationStyle"]); IOSUIModalPresentationStyle.fromValue(map["presentationStyle"]);
options.transitionStyle = options.transitionStyle =
IOSWebViewOptionsTransitionStyle.fromValue(map["transitionStyle"]); IOSUIModalTransitionStyle.fromValue(map["transitionStyle"]);
options.spinner = map["spinner"]; options.spinner = map["spinner"];
return options; return options;
} }
@ -850,8 +850,8 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions {
///This class represents all the Android-only [ChromeSafariBrowser] options available. ///This class represents all the Android-only [ChromeSafariBrowser] options available.
class AndroidChromeCustomTabsOptions class AndroidChromeCustomTabsOptions
implements ChromeSafariBrowserOptions, AndroidOptions { implements ChromeSafariBrowserOptions, AndroidOptions {
///Set to `false` if you don't want the default share button. The default value is `true`. ///Set to `false` if you don't want the default share item to the menu. The default value is `true`.
bool addShareButton; bool addDefaultShareMenuItem;
///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. ///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
bool showTitle; bool showTitle;
@ -865,32 +865,48 @@ class AndroidChromeCustomTabsOptions
///Set to `true` to enable Instant Apps. The default value is `false`. ///Set to `true` to enable Instant Apps. The default value is `false`.
bool instantAppsEnabled; bool instantAppsEnabled;
///Set an explicit application package name that limits
///the components this Intent will resolve to. If left to the default
///value of null, all components in all applications will considered.
///If non-null, the Intent can only match the components in the given
///application package.
String packageName;
///Set to `true` to enable Keep Alive. The default value is `false`.
bool keepAliveEnabled;
AndroidChromeCustomTabsOptions( AndroidChromeCustomTabsOptions(
{this.addShareButton = true, {this.addDefaultShareMenuItem = true,
this.showTitle = true, this.showTitle = true,
this.toolbarBackgroundColor = "", this.toolbarBackgroundColor = "",
this.enableUrlBarHiding = false, this.enableUrlBarHiding = false,
this.instantAppsEnabled = false}); this.instantAppsEnabled = false,
this.packageName,
this.keepAliveEnabled = false});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
"addShareButton": addShareButton, "addDefaultShareMenuItem": addDefaultShareMenuItem,
"showTitle": showTitle, "showTitle": showTitle,
"toolbarBackgroundColor": toolbarBackgroundColor, "toolbarBackgroundColor": toolbarBackgroundColor,
"enableUrlBarHiding": enableUrlBarHiding, "enableUrlBarHiding": enableUrlBarHiding,
"instantAppsEnabled": instantAppsEnabled "instantAppsEnabled": instantAppsEnabled,
"packageName": packageName,
"keepAliveEnabled": keepAliveEnabled
}; };
} }
static AndroidChromeCustomTabsOptions fromMap(Map<String, dynamic> map) { static AndroidChromeCustomTabsOptions fromMap(Map<String, dynamic> map) {
AndroidChromeCustomTabsOptions options = AndroidChromeCustomTabsOptions options =
new AndroidChromeCustomTabsOptions(); new AndroidChromeCustomTabsOptions();
options.addShareButton = map["addShareButton"]; options.addDefaultShareMenuItem = map["addDefaultShareMenuItem"];
options.showTitle = map["showTitle"]; options.showTitle = map["showTitle"];
options.toolbarBackgroundColor = map["toolbarBackgroundColor"]; options.toolbarBackgroundColor = map["toolbarBackgroundColor"];
options.enableUrlBarHiding = map["enableUrlBarHiding"]; options.enableUrlBarHiding = map["enableUrlBarHiding"];
options.instantAppsEnabled = map["instantAppsEnabled"]; options.instantAppsEnabled = map["instantAppsEnabled"];
options.packageName = map["packageName"];
options.keepAliveEnabled = map["keepAliveEnabled"];
return options; return options;
} }
} }
@ -903,10 +919,10 @@ class IOSSafariOptions implements ChromeSafariBrowserOptions, IosOptions {
///Set to `true` to enable bar collapsing. The default value is `false`. ///Set to `true` to enable bar collapsing. The default value is `false`.
bool barCollapsingEnabled; bool barCollapsingEnabled;
///Set the custom style for the dismiss button. The default value is [IOSSafariOptionsDismissButtonStyle.DONE]. ///Set the custom style for the dismiss button. The default value is [IOSSafariDismissButtonStyle.DONE].
/// ///
///**NOTE**: available on iOS 11.0+. ///**NOTE**: available on iOS 11.0+.
IOSSafariOptionsDismissButtonStyle dismissButtonStyle; IOSSafariDismissButtonStyle dismissButtonStyle;
///Set the custom background color of the navigation bar and the toolbar. ///Set the custom background color of the navigation bar and the toolbar.
/// ///
@ -918,20 +934,20 @@ class IOSSafariOptions implements ChromeSafariBrowserOptions, IosOptions {
///**NOTE**: available on iOS 10.0+. ///**NOTE**: available on iOS 10.0+.
String preferredControlTintColor; String preferredControlTintColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [IOSWebViewOptionsPresentationStyle.FULL_SCREEN]. ///Set the custom modal presentation style when presenting the WebView. The default value is [IOSUIModalPresentationStyle.FULL_SCREEN].
IOSWebViewOptionsPresentationStyle presentationStyle; IOSUIModalPresentationStyle presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [IOSWebViewOptionsTransitionStyle.COVER_VERTICAL]. ///Set to the custom transition style when presenting the WebView. The default value is [IOSUIModalTransitionStyle.COVER_VERTICAL].
IOSWebViewOptionsTransitionStyle transitionStyle; IOSUIModalTransitionStyle transitionStyle;
IOSSafariOptions( IOSSafariOptions(
{this.entersReaderIfAvailable = false, {this.entersReaderIfAvailable = false,
this.barCollapsingEnabled = false, this.barCollapsingEnabled = false,
this.dismissButtonStyle = IOSSafariOptionsDismissButtonStyle.DONE, this.dismissButtonStyle = IOSSafariDismissButtonStyle.DONE,
this.preferredBarTintColor = "", this.preferredBarTintColor = "",
this.preferredControlTintColor = "", this.preferredControlTintColor = "",
this.presentationStyle = IOSWebViewOptionsPresentationStyle.FULL_SCREEN, this.presentationStyle = IOSUIModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = IOSWebViewOptionsTransitionStyle.COVER_VERTICAL}); this.transitionStyle = IOSUIModalTransitionStyle.COVER_VERTICAL});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -951,13 +967,13 @@ class IOSSafariOptions implements ChromeSafariBrowserOptions, IosOptions {
options.entersReaderIfAvailable = map["entersReaderIfAvailable"]; options.entersReaderIfAvailable = map["entersReaderIfAvailable"];
options.barCollapsingEnabled = map["barCollapsingEnabled"]; options.barCollapsingEnabled = map["barCollapsingEnabled"];
options.dismissButtonStyle = options.dismissButtonStyle =
IOSSafariOptionsDismissButtonStyle.fromValue(map["dismissButtonStyle"]); IOSSafariDismissButtonStyle.fromValue(map["dismissButtonStyle"]);
options.preferredBarTintColor = map["preferredBarTintColor"]; options.preferredBarTintColor = map["preferredBarTintColor"];
options.preferredControlTintColor = map["preferredControlTintColor"]; options.preferredControlTintColor = map["preferredControlTintColor"];
options.presentationStyle = options.presentationStyle =
IOSWebViewOptionsPresentationStyle.fromValue(map["presentationStyle"]); IOSUIModalPresentationStyle.fromValue(map["presentationStyle"]);
options.transitionStyle = options.transitionStyle =
IOSWebViewOptionsTransitionStyle.fromValue(map["transitionStyle"]); IOSUIModalTransitionStyle.fromValue(map["transitionStyle"]);
return options; return options;
} }
} }