2019-10-28 03:58:25 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2019-10-31 02:20:07 +00:00
|
|
|
import 'types.dart';
|
2019-10-26 20:11:23 +00:00
|
|
|
import 'package:flutter_inappbrowser/src/content_blocker.dart';
|
|
|
|
|
2019-10-31 02:20:07 +00:00
|
|
|
class AndroidOptions {}
|
2019-11-04 00:39:23 +00:00
|
|
|
class IosOptions {}
|
2019-10-31 02:20:07 +00:00
|
|
|
|
2019-10-26 20:11:23 +00:00
|
|
|
class WebViewOptions {
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
static WebViewOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-10-27 03:35:05 +00:00
|
|
|
class BrowserOptions {
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
static BrowserOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ChromeSafariBrowserOptions {
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
static ChromeSafariBrowserOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-10-27 03:35:05 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool useShouldOverrideUrlLoading;
|
|
|
|
bool useOnLoadResource;
|
|
|
|
bool useOnDownloadStart;
|
|
|
|
bool useOnTargetBlank;
|
|
|
|
bool clearCache;
|
|
|
|
String userAgent;
|
2019-11-07 23:32:29 +00:00
|
|
|
String applicationNameForUserAgent;
|
2019-10-26 20:11:23 +00:00
|
|
|
bool javaScriptEnabled;
|
2019-10-29 16:51:55 +00:00
|
|
|
bool debuggingEnabled;
|
2019-10-26 20:11:23 +00:00
|
|
|
bool javaScriptCanOpenWindowsAutomatically;
|
|
|
|
bool mediaPlaybackRequiresUserGesture;
|
|
|
|
int textZoom;
|
2019-10-28 03:58:25 +00:00
|
|
|
int minimumFontSize;
|
2019-10-26 20:11:23 +00:00
|
|
|
bool verticalScrollBarEnabled;
|
|
|
|
bool horizontalScrollBarEnabled;
|
|
|
|
List<String> resourceCustomSchemes;
|
|
|
|
List<ContentBlocker> contentBlockers;
|
2019-10-31 22:09:54 +00:00
|
|
|
InAppWebViewUserPreferredContentMode preferredContentMode;
|
2019-11-05 02:44:22 +00:00
|
|
|
bool useShouldInterceptAjaxRequest;
|
|
|
|
bool useShouldInterceptFetchRequest;
|
2019-11-07 23:32:29 +00:00
|
|
|
bool incognito;
|
|
|
|
bool cacheEnabled;
|
|
|
|
bool transparentBackground;
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
InAppWebViewOptions({this.useShouldOverrideUrlLoading = false, this.useOnLoadResource = false, this.useOnDownloadStart = false, this.useOnTargetBlank = false,
|
2019-11-07 23:32:29 +00:00
|
|
|
this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", this.javaScriptEnabled = true, this.debuggingEnabled = false, this.javaScriptCanOpenWindowsAutomatically = false,
|
2019-10-28 03:58:25 +00:00
|
|
|
this.mediaPlaybackRequiresUserGesture = true, this.textZoom = 100, this.minimumFontSize, this.verticalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true,
|
2019-11-05 02:44:22 +00:00
|
|
|
this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = InAppWebViewUserPreferredContentMode.RECOMMENDED,
|
2019-11-07 23:32:29 +00:00
|
|
|
this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptFetchRequest = false, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false}) {
|
2019-10-28 03:58:25 +00:00
|
|
|
if (this.minimumFontSize == null)
|
|
|
|
this.minimumFontSize = Platform.isAndroid ? 8 : 0;
|
2019-11-02 18:58:01 +00:00
|
|
|
assert(!this.resourceCustomSchemes.contains("http") && !this.resourceCustomSchemes.contains("https"));
|
2019-10-28 03:58:25 +00:00
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
List<Map<String, Map<String, dynamic>>> contentBlockersMapList = [];
|
|
|
|
contentBlockers.forEach((contentBlocker) {
|
|
|
|
contentBlockersMapList.add(contentBlocker.toMap());
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
"useShouldOverrideUrlLoading": useShouldOverrideUrlLoading,
|
|
|
|
"useOnLoadResource": useOnLoadResource,
|
|
|
|
"useOnDownloadStart": useOnDownloadStart,
|
|
|
|
"useOnTargetBlank": useOnTargetBlank,
|
|
|
|
"clearCache": clearCache,
|
|
|
|
"userAgent": userAgent,
|
2019-11-07 23:32:29 +00:00
|
|
|
"applicationNameForUserAgent": applicationNameForUserAgent,
|
2019-10-26 20:11:23 +00:00
|
|
|
"javaScriptEnabled": javaScriptEnabled,
|
2019-11-04 00:39:23 +00:00
|
|
|
"debuggingEnabled": debuggingEnabled,
|
2019-10-26 20:11:23 +00:00
|
|
|
"javaScriptCanOpenWindowsAutomatically": javaScriptCanOpenWindowsAutomatically,
|
|
|
|
"mediaPlaybackRequiresUserGesture": mediaPlaybackRequiresUserGesture,
|
|
|
|
"textZoom": textZoom,
|
|
|
|
"verticalScrollBarEnabled": verticalScrollBarEnabled,
|
|
|
|
"horizontalScrollBarEnabled": horizontalScrollBarEnabled,
|
|
|
|
"resourceCustomSchemes": resourceCustomSchemes,
|
|
|
|
"contentBlockers": contentBlockersMapList,
|
2019-11-05 02:44:22 +00:00
|
|
|
"preferredContentMode": preferredContentMode?.toValue(),
|
|
|
|
"useShouldInterceptAjaxRequest": useShouldInterceptAjaxRequest,
|
2019-11-07 23:32:29 +00:00
|
|
|
"useShouldInterceptFetchRequest": useShouldInterceptFetchRequest,
|
|
|
|
"incognito": incognito,
|
|
|
|
"cacheEnabled": cacheEnabled,
|
|
|
|
"transparentBackground": transparentBackground
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static InAppWebViewOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
List<ContentBlocker> contentBlockers = [];
|
|
|
|
List<dynamic> contentBlockersMapList = map["contentBlockers"];
|
|
|
|
if (contentBlockersMapList != null) {
|
|
|
|
contentBlockersMapList.forEach((contentBlocker) {
|
|
|
|
contentBlockers.add(ContentBlocker.fromMap(
|
|
|
|
Map<dynamic, Map<dynamic, dynamic>>.from(Map<dynamic, dynamic>.from(contentBlocker))
|
|
|
|
));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
InAppWebViewOptions options = new InAppWebViewOptions();
|
|
|
|
options.useShouldOverrideUrlLoading = map["useShouldOverrideUrlLoading"];
|
|
|
|
options.useOnLoadResource = map["useOnLoadResource"];
|
|
|
|
options.useOnDownloadStart = map["useOnDownloadStart"];
|
|
|
|
options.useOnTargetBlank = map["useOnTargetBlank"];
|
|
|
|
options.clearCache = map["clearCache"];
|
|
|
|
options.userAgent = map["userAgent"];
|
2019-11-07 23:32:29 +00:00
|
|
|
options.applicationNameForUserAgent = map["applicationNameForUserAgent"];
|
2019-11-04 00:39:23 +00:00
|
|
|
options.javaScriptEnabled = map["javaScriptEnabled"];
|
2019-11-07 23:32:29 +00:00
|
|
|
options.debuggingEnabled = map["debuggingEnabled"];
|
2019-11-04 00:39:23 +00:00
|
|
|
options.javaScriptCanOpenWindowsAutomatically = map["javaScriptCanOpenWindowsAutomatically"];
|
|
|
|
options.mediaPlaybackRequiresUserGesture = map["mediaPlaybackRequiresUserGesture"];
|
|
|
|
options.textZoom = map["textZoom"];
|
|
|
|
options.verticalScrollBarEnabled = map["verticalScrollBarEnabled"];
|
|
|
|
options.horizontalScrollBarEnabled = map["horizontalScrollBarEnabled"];
|
|
|
|
options.resourceCustomSchemes = List<String>.from(map["resourceCustomSchemes"] ?? []);
|
|
|
|
options.contentBlockers = contentBlockers;
|
|
|
|
options.preferredContentMode = InAppWebViewUserPreferredContentMode.fromValue(map["preferredContentMode"]);
|
2019-11-07 23:32:29 +00:00
|
|
|
options.useShouldInterceptAjaxRequest = map["useShouldInterceptAjaxRequest"];
|
|
|
|
options.useShouldInterceptFetchRequest = map["useShouldInterceptFetchRequest"];
|
|
|
|
options.incognito = map["incognito"];
|
|
|
|
options.cacheEnabled = map["cacheEnabled"];
|
|
|
|
options.transparentBackground = map["transparentBackground"];
|
2019-11-04 00:39:23 +00:00
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 02:20:07 +00:00
|
|
|
class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool clearSessionCache;
|
|
|
|
bool builtInZoomControls;
|
|
|
|
bool displayZoomControls;
|
|
|
|
bool supportZoom;
|
|
|
|
bool databaseEnabled;
|
|
|
|
bool domStorageEnabled;
|
|
|
|
bool useWideViewPort;
|
|
|
|
bool safeBrowsingEnabled;
|
2019-10-28 03:58:25 +00:00
|
|
|
AndroidInAppWebViewMixedContentMode mixedContentMode;
|
|
|
|
bool allowContentAccess;
|
|
|
|
bool allowFileAccess;
|
|
|
|
bool allowFileAccessFromFileURLs;
|
|
|
|
bool allowUniversalAccessFromFileURLs;
|
|
|
|
String appCachePath;
|
|
|
|
bool blockNetworkImage;
|
|
|
|
bool blockNetworkLoads;
|
|
|
|
AndroidInAppWebViewCacheMode cacheMode;
|
|
|
|
String cursiveFontFamily;
|
|
|
|
int defaultFixedFontSize;
|
|
|
|
int defaultFontSize;
|
|
|
|
String defaultTextEncodingName;
|
|
|
|
AndroidInAppWebViewModeMenuItem disabledActionModeMenuItems;
|
|
|
|
String fantasyFontFamily;
|
|
|
|
String fixedFontFamily;
|
|
|
|
AndroidInAppWebViewForceDark forceDark;
|
|
|
|
bool geolocationEnabled;
|
|
|
|
AndroidInAppWebViewLayoutAlgorithm layoutAlgorithm;
|
|
|
|
bool loadWithOverviewMode;
|
|
|
|
bool loadsImagesAutomatically;
|
|
|
|
int minimumLogicalFontSize;
|
2019-11-08 06:39:15 +00:00
|
|
|
int initialScale;
|
2019-10-28 03:58:25 +00:00
|
|
|
bool needInitialFocus;
|
|
|
|
bool offscreenPreRaster;
|
|
|
|
String sansSerifFontFamily;
|
|
|
|
String serifFontFamily;
|
|
|
|
String standardFontFamily;
|
2019-11-07 23:32:29 +00:00
|
|
|
bool saveFormData;
|
|
|
|
bool thirdPartyCookiesEnabled;
|
|
|
|
bool hardwareAcceleration;
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
AndroidInAppWebViewOptions({this.clearSessionCache = false, this.builtInZoomControls = false, this.displayZoomControls = false, this.supportZoom = true, this.databaseEnabled = false,
|
2019-11-07 23:32:29 +00:00
|
|
|
this.domStorageEnabled = false, this.useWideViewPort = true, this.safeBrowsingEnabled = true, this.mixedContentMode,
|
2019-10-28 03:58:25 +00:00
|
|
|
this.allowContentAccess = true, this.allowFileAccess = true, this.allowFileAccessFromFileURLs = true, this.allowUniversalAccessFromFileURLs = true,
|
2019-11-07 23:32:29 +00:00
|
|
|
this.appCachePath, this.blockNetworkImage = false, this.blockNetworkLoads = false, this.cacheMode = AndroidInAppWebViewCacheMode.LOAD_DEFAULT,
|
2019-10-28 03:58:25 +00:00
|
|
|
this.cursiveFontFamily = "cursive", this.defaultFixedFontSize = 16, this.defaultFontSize = 16, this.defaultTextEncodingName = "UTF-8",
|
|
|
|
this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", this.forceDark = AndroidInAppWebViewForceDark.FORCE_DARK_OFF,
|
|
|
|
this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, this.loadsImagesAutomatically = true,
|
|
|
|
this.minimumLogicalFontSize = 8, this.needInitialFocus = true, this.offscreenPreRaster = false, this.sansSerifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif",
|
2019-11-08 14:11:28 +00:00
|
|
|
this.standardFontFamily = "sans-serif", this.saveFormData = true, this.thirdPartyCookiesEnabled = true, this.hardwareAcceleration = true, this.initialScale
|
2019-10-28 03:58:25 +00:00
|
|
|
});
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"clearSessionCache": clearSessionCache,
|
|
|
|
"builtInZoomControls": builtInZoomControls,
|
|
|
|
"displayZoomControls": displayZoomControls,
|
|
|
|
"supportZoom": supportZoom,
|
|
|
|
"databaseEnabled": databaseEnabled,
|
|
|
|
"domStorageEnabled": domStorageEnabled,
|
|
|
|
"useWideViewPort": useWideViewPort,
|
|
|
|
"safeBrowsingEnabled": safeBrowsingEnabled,
|
2019-10-28 03:58:25 +00:00
|
|
|
"mixedContentMode": mixedContentMode?.toValue(),
|
|
|
|
"allowContentAccess": allowContentAccess,
|
|
|
|
"allowFileAccess": allowFileAccess,
|
|
|
|
"allowFileAccessFromFileURLs": allowFileAccessFromFileURLs,
|
|
|
|
"allowUniversalAccessFromFileURLs": allowUniversalAccessFromFileURLs,
|
|
|
|
"appCachePath": appCachePath,
|
|
|
|
"blockNetworkImage": blockNetworkImage,
|
|
|
|
"blockNetworkLoads": blockNetworkLoads,
|
|
|
|
"cacheMode": cacheMode?.toValue(),
|
|
|
|
"cursiveFontFamily": cursiveFontFamily,
|
|
|
|
"defaultFixedFontSize": defaultFixedFontSize,
|
|
|
|
"defaultFontSize": defaultFontSize,
|
|
|
|
"defaultTextEncodingName": defaultTextEncodingName,
|
|
|
|
"disabledActionModeMenuItems": disabledActionModeMenuItems?.toValue(),
|
|
|
|
"fantasyFontFamily": fantasyFontFamily,
|
|
|
|
"fixedFontFamily": fixedFontFamily,
|
|
|
|
"forceDark": forceDark?.toValue(),
|
|
|
|
"geolocationEnabled": geolocationEnabled,
|
|
|
|
"layoutAlgorithm": layoutAlgorithm?.toValue(),
|
|
|
|
"loadWithOverviewMode": loadWithOverviewMode,
|
|
|
|
"loadsImagesAutomatically": loadsImagesAutomatically,
|
|
|
|
"minimumLogicalFontSize": minimumLogicalFontSize,
|
2019-11-08 06:39:15 +00:00
|
|
|
"initialScale": initialScale,
|
2019-10-28 03:58:25 +00:00
|
|
|
"needInitialFocus": needInitialFocus,
|
|
|
|
"offscreenPreRaster": offscreenPreRaster,
|
|
|
|
"sansSerifFontFamily": sansSerifFontFamily,
|
|
|
|
"serifFontFamily": serifFontFamily,
|
2019-11-07 23:32:29 +00:00
|
|
|
"standardFontFamily": standardFontFamily,
|
|
|
|
"saveFormData": saveFormData,
|
|
|
|
"thirdPartyCookiesEnabled": thirdPartyCookiesEnabled,
|
|
|
|
"hardwareAcceleration": hardwareAcceleration
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static AndroidInAppWebViewOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
AndroidInAppWebViewOptions options = new AndroidInAppWebViewOptions();
|
|
|
|
options.clearSessionCache = map["clearSessionCache"];
|
|
|
|
options.builtInZoomControls = map["builtInZoomControls"];
|
|
|
|
options.displayZoomControls = map["displayZoomControls"];
|
|
|
|
options.supportZoom = map["supportZoom"];
|
|
|
|
options.databaseEnabled = map["databaseEnabled"];
|
|
|
|
options.domStorageEnabled = map["domStorageEnabled"];
|
|
|
|
options.useWideViewPort = map["useWideViewPort"];
|
|
|
|
options.safeBrowsingEnabled = map["safeBrowsingEnabled"];
|
|
|
|
options.mixedContentMode = AndroidInAppWebViewMixedContentMode.fromValue(map["mixedContentMode"]);
|
|
|
|
options.allowContentAccess = map["allowContentAccess"];
|
|
|
|
options.allowFileAccess = map["allowFileAccess"];
|
|
|
|
options.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"];
|
|
|
|
options.allowUniversalAccessFromFileURLs = map["allowUniversalAccessFromFileURLs"];
|
|
|
|
options.appCachePath = map["appCachePath"];
|
|
|
|
options.blockNetworkImage = map["blockNetworkImage"];
|
|
|
|
options.blockNetworkLoads = map["blockNetworkLoads"];
|
|
|
|
options.cacheMode = AndroidInAppWebViewCacheMode.fromValue(map["cacheMode"]);
|
|
|
|
options.cursiveFontFamily = map["cursiveFontFamily"];
|
|
|
|
options.defaultFixedFontSize = map["defaultFixedFontSize"];
|
|
|
|
options.defaultFontSize = map["defaultFontSize"];
|
|
|
|
options.defaultTextEncodingName = map["defaultTextEncodingName"];
|
|
|
|
options.disabledActionModeMenuItems = AndroidInAppWebViewModeMenuItem.fromValue(map["disabledActionModeMenuItems"]);
|
|
|
|
options.fantasyFontFamily = map["fantasyFontFamily"];
|
|
|
|
options.fixedFontFamily = map["fixedFontFamily"];
|
|
|
|
options.forceDark = AndroidInAppWebViewForceDark.fromValue(map["forceDark"]);
|
|
|
|
options.geolocationEnabled = map["geolocationEnabled"];
|
|
|
|
options.layoutAlgorithm = AndroidInAppWebViewLayoutAlgorithm.fromValue(map["layoutAlgorithm"]);
|
|
|
|
options.loadWithOverviewMode = map["loadWithOverviewMode"];
|
|
|
|
options.loadsImagesAutomatically = map["loadsImagesAutomatically"];
|
|
|
|
options.minimumLogicalFontSize = map["minimumLogicalFontSize"];
|
2019-11-08 06:39:15 +00:00
|
|
|
options.initialScale = map["initialScale"];
|
2019-11-04 00:39:23 +00:00
|
|
|
options.needInitialFocus = map["needInitialFocus"];
|
|
|
|
options.offscreenPreRaster = map["offscreenPreRaster"];
|
|
|
|
options.sansSerifFontFamily = map["sansSerifFontFamily"];
|
|
|
|
options.serifFontFamily = map["serifFontFamily"];
|
|
|
|
options.standardFontFamily = map["standardFontFamily"];
|
2019-11-07 23:32:29 +00:00
|
|
|
options.saveFormData = map["saveFormData"];
|
|
|
|
options.thirdPartyCookiesEnabled = map["thirdPartyCookiesEnabled"];
|
|
|
|
options.hardwareAcceleration = map["hardwareAcceleration"];
|
2019-11-04 00:39:23 +00:00
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
class IosInAppWebViewOptions implements WebViewOptions, BrowserOptions, IosOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool disallowOverScroll;
|
|
|
|
bool enableViewportScale;
|
|
|
|
bool suppressesIncrementalRendering;
|
|
|
|
bool allowsAirPlayForMediaPlayback;
|
|
|
|
bool allowsBackForwardNavigationGestures;
|
|
|
|
bool allowsLinkPreview;
|
|
|
|
bool ignoresViewportScaleLimits;
|
|
|
|
bool allowsInlineMediaPlayback;
|
|
|
|
bool allowsPictureInPictureMediaPlayback;
|
2019-10-28 03:58:25 +00:00
|
|
|
bool isFraudulentWebsiteWarningEnabled;
|
2019-11-04 00:39:23 +00:00
|
|
|
IosInAppWebViewSelectionGranularity selectionGranularity;
|
|
|
|
List<IosInAppWebViewDataDetectorTypes> dataDetectorTypes;
|
2019-11-07 23:32:29 +00:00
|
|
|
bool sharedCookiesEnabled;
|
2019-10-28 03:58:25 +00:00
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
IosInAppWebViewOptions({this.disallowOverScroll = false, this.enableViewportScale = false, this.suppressesIncrementalRendering = false, this.allowsAirPlayForMediaPlayback = true,
|
2019-10-26 20:11:23 +00:00
|
|
|
this.allowsBackForwardNavigationGestures = true, this.allowsLinkPreview = true, this.ignoresViewportScaleLimits = false, this.allowsInlineMediaPlayback = false,
|
2019-11-07 23:32:29 +00:00
|
|
|
this.allowsPictureInPictureMediaPlayback = true, this.isFraudulentWebsiteWarningEnabled = true,
|
|
|
|
this.selectionGranularity = IosInAppWebViewSelectionGranularity.DYNAMIC, this.dataDetectorTypes = const [IosInAppWebViewDataDetectorTypes.NONE], this.sharedCookiesEnabled = false
|
2019-10-28 03:58:25 +00:00
|
|
|
});
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
2019-10-28 03:58:25 +00:00
|
|
|
List<String> dataDetectorTypesList = [];
|
|
|
|
dataDetectorTypes.forEach((dataDetectorType) {
|
|
|
|
dataDetectorTypesList.add(dataDetectorType.toValue());
|
|
|
|
});
|
|
|
|
|
2019-10-26 20:11:23 +00:00
|
|
|
return {
|
|
|
|
"disallowOverScroll": disallowOverScroll,
|
|
|
|
"enableViewportScale": enableViewportScale,
|
|
|
|
"suppressesIncrementalRendering": suppressesIncrementalRendering,
|
|
|
|
"allowsAirPlayForMediaPlayback": allowsAirPlayForMediaPlayback,
|
|
|
|
"allowsBackForwardNavigationGestures": allowsBackForwardNavigationGestures,
|
|
|
|
"allowsLinkPreview": allowsLinkPreview,
|
|
|
|
"ignoresViewportScaleLimits": ignoresViewportScaleLimits,
|
|
|
|
"allowsInlineMediaPlayback": allowsInlineMediaPlayback,
|
|
|
|
"allowsPictureInPictureMediaPlayback": allowsPictureInPictureMediaPlayback,
|
2019-10-28 03:58:25 +00:00
|
|
|
"isFraudulentWebsiteWarningEnabled": isFraudulentWebsiteWarningEnabled,
|
|
|
|
"selectionGranularity": selectionGranularity.toValue(),
|
2019-11-07 23:32:29 +00:00
|
|
|
"dataDetectorTypes": dataDetectorTypesList,
|
|
|
|
"sharedCookiesEnabled": sharedCookiesEnabled
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static IosInAppWebViewOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
List<IosInAppWebViewDataDetectorTypes> dataDetectorTypes = [];
|
|
|
|
List<String> dataDetectorTypesList = List<String>.from(map["dataDetectorTypes"] ?? []);
|
|
|
|
dataDetectorTypesList.forEach((dataDetectorType) {
|
|
|
|
dataDetectorTypes.add(IosInAppWebViewDataDetectorTypes.fromValue(dataDetectorType));
|
|
|
|
});
|
|
|
|
|
|
|
|
IosInAppWebViewOptions options = new IosInAppWebViewOptions();
|
|
|
|
options.disallowOverScroll = map["disallowOverScroll"];
|
|
|
|
options.enableViewportScale = map["enableViewportScale"];
|
|
|
|
options.suppressesIncrementalRendering = map["suppressesIncrementalRendering"];
|
|
|
|
options.allowsAirPlayForMediaPlayback = map["allowsAirPlayForMediaPlayback"];
|
|
|
|
options.allowsBackForwardNavigationGestures = map["allowsBackForwardNavigationGestures"];
|
|
|
|
options.allowsLinkPreview = map["allowsLinkPreview"];
|
|
|
|
options.ignoresViewportScaleLimits = map["ignoresViewportScaleLimits"];
|
|
|
|
options.allowsInlineMediaPlayback = map["allowsInlineMediaPlayback"];
|
|
|
|
options.allowsPictureInPictureMediaPlayback = map["allowsPictureInPictureMediaPlayback"];
|
|
|
|
options.isFraudulentWebsiteWarningEnabled = map["isFraudulentWebsiteWarningEnabled"];
|
|
|
|
options.selectionGranularity = IosInAppWebViewSelectionGranularity.fromValue(map["selectionGranularity"]);
|
|
|
|
options.dataDetectorTypes = dataDetectorTypes;
|
2019-11-07 23:32:29 +00:00
|
|
|
options.sharedCookiesEnabled = map["sharedCookiesEnabled"];
|
2019-11-04 00:39:23 +00:00
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
class InAppBrowserOptions implements BrowserOptions, AndroidOptions, IosOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool hidden;
|
|
|
|
bool toolbarTop;
|
|
|
|
String toolbarTopBackgroundColor;
|
|
|
|
String toolbarTopFixedTitle;
|
|
|
|
bool hideUrlBar;
|
|
|
|
|
|
|
|
InAppBrowserOptions({this.hidden = false, this.toolbarTop = true, this.toolbarTopBackgroundColor = "", this.toolbarTopFixedTitle = "", this.hideUrlBar = false});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"hidden": hidden,
|
|
|
|
"toolbarTop": toolbarTop,
|
|
|
|
"toolbarTopBackgroundColor": toolbarTopBackgroundColor,
|
|
|
|
"toolbarTopFixedTitle": toolbarTopFixedTitle,
|
2019-11-04 00:39:23 +00:00
|
|
|
"hideUrlBar": hideUrlBar
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static InAppBrowserOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
InAppBrowserOptions options = new InAppBrowserOptions();
|
|
|
|
options.hidden = map["hidden"];
|
|
|
|
options.toolbarTop = map["toolbarTop"];
|
|
|
|
options.toolbarTopBackgroundColor = map["toolbarTopBackgroundColor"];
|
|
|
|
options.toolbarTopFixedTitle = map["toolbarTopFixedTitle"];
|
|
|
|
options.hideUrlBar = map["hideUrlBar"];
|
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 02:20:07 +00:00
|
|
|
class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool hideTitleBar;
|
|
|
|
bool closeOnCannotGoBack;
|
|
|
|
bool progressBar;
|
|
|
|
|
|
|
|
AndroidInAppBrowserOptions({this.hideTitleBar = true, this.closeOnCannotGoBack = true, this.progressBar = true});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"hideTitleBar": hideTitleBar,
|
|
|
|
"closeOnCannotGoBack": closeOnCannotGoBack,
|
|
|
|
"progressBar": progressBar,
|
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static AndroidInAppBrowserOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
AndroidInAppBrowserOptions options = new AndroidInAppBrowserOptions();
|
|
|
|
options.hideTitleBar = map["hideTitleBar"];
|
|
|
|
options.closeOnCannotGoBack = map["closeOnCannotGoBack"];
|
|
|
|
options.progressBar = map["progressBar"];
|
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
class IosInAppBrowserOptions implements BrowserOptions, IosOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool toolbarBottom;
|
|
|
|
String toolbarBottomBackgroundColor;
|
|
|
|
bool toolbarBottomTranslucent;
|
|
|
|
String closeButtonCaption;
|
|
|
|
String closeButtonColor;
|
2019-11-04 00:39:23 +00:00
|
|
|
IosWebViewOptionsPresentationStyle presentationStyle;
|
|
|
|
IosWebViewOptionsTransitionStyle transitionStyle;
|
2019-10-26 20:11:23 +00:00
|
|
|
bool spinner;
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
IosInAppBrowserOptions({this.toolbarBottom = true, this.toolbarBottomBackgroundColor = "", this.toolbarBottomTranslucent = true, this.closeButtonCaption = "",
|
|
|
|
this.closeButtonColor = "", this.presentationStyle = IosWebViewOptionsPresentationStyle.FULL_SCREEN,
|
|
|
|
this.transitionStyle = IosWebViewOptionsTransitionStyle.COVER_VERTICAL, this.spinner = true});
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"toolbarBottom": toolbarBottom,
|
|
|
|
"toolbarBottomBackgroundColor": toolbarBottomBackgroundColor,
|
|
|
|
"toolbarBottomTranslucent": toolbarBottomTranslucent,
|
|
|
|
"closeButtonCaption": closeButtonCaption,
|
|
|
|
"closeButtonColor": closeButtonColor,
|
2019-10-29 14:27:50 +00:00
|
|
|
"presentationStyle": presentationStyle.toValue(),
|
|
|
|
"transitionStyle": transitionStyle.toValue(),
|
2019-11-04 00:39:23 +00:00
|
|
|
"spinner": spinner
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
@override
|
|
|
|
static IosInAppBrowserOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
IosInAppBrowserOptions options = new IosInAppBrowserOptions();
|
|
|
|
options.toolbarBottom = map["toolbarBottom"];
|
|
|
|
options.toolbarBottomBackgroundColor = map["toolbarBottomBackgroundColor"];
|
|
|
|
options.toolbarBottomTranslucent = map["toolbarBottomTranslucent"];
|
|
|
|
options.closeButtonCaption = map["closeButtonCaption"];
|
|
|
|
options.closeButtonColor = map["closeButtonColor"];
|
|
|
|
options.presentationStyle = IosWebViewOptionsPresentationStyle.fromValue(map["presentationStyle"]);
|
|
|
|
options.transitionStyle = IosWebViewOptionsTransitionStyle.fromValue(map["transitionStyle"]);
|
|
|
|
options.spinner = map["spinner"];
|
|
|
|
return options;
|
2019-10-27 03:35:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-31 02:20:07 +00:00
|
|
|
class AndroidChromeCustomTabsOptions implements ChromeSafariBrowserOptions, AndroidOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool addShareButton;
|
|
|
|
bool showTitle;
|
|
|
|
String toolbarBackgroundColor;
|
|
|
|
bool enableUrlBarHiding;
|
|
|
|
bool instantAppsEnabled;
|
|
|
|
|
|
|
|
AndroidChromeCustomTabsOptions({this.addShareButton = true, this.showTitle = true, this.toolbarBackgroundColor = "", this.enableUrlBarHiding = false, this.instantAppsEnabled = false});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"addShareButton": addShareButton,
|
|
|
|
"showTitle": showTitle,
|
|
|
|
"toolbarBackgroundColor": toolbarBackgroundColor,
|
|
|
|
"enableUrlBarHiding": enableUrlBarHiding,
|
2019-11-04 00:39:23 +00:00
|
|
|
"instantAppsEnabled": instantAppsEnabled
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static AndroidChromeCustomTabsOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
AndroidChromeCustomTabsOptions options = new AndroidChromeCustomTabsOptions();
|
|
|
|
options.addShareButton = map["addShareButton"];
|
|
|
|
options.showTitle = map["showTitle"];
|
|
|
|
options.toolbarBackgroundColor = map["toolbarBackgroundColor"];
|
|
|
|
options.enableUrlBarHiding = map["enableUrlBarHiding"];
|
|
|
|
options.instantAppsEnabled = map["instantAppsEnabled"];
|
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
class IosSafariOptions implements ChromeSafariBrowserOptions, IosOptions {
|
2019-10-26 20:11:23 +00:00
|
|
|
bool entersReaderIfAvailable;
|
|
|
|
bool barCollapsingEnabled;
|
2019-11-04 00:39:23 +00:00
|
|
|
IosSafariOptionsDismissButtonStyle dismissButtonStyle;
|
2019-10-26 20:11:23 +00:00
|
|
|
String preferredBarTintColor;
|
|
|
|
String preferredControlTintColor;
|
2019-11-04 00:39:23 +00:00
|
|
|
IosWebViewOptionsPresentationStyle presentationStyle;
|
|
|
|
IosWebViewOptionsTransitionStyle transitionStyle;
|
2019-10-26 20:11:23 +00:00
|
|
|
|
2019-11-04 00:39:23 +00:00
|
|
|
IosSafariOptions({this.entersReaderIfAvailable = false, this.barCollapsingEnabled = false, this.dismissButtonStyle = IosSafariOptionsDismissButtonStyle.DONE,
|
|
|
|
this.preferredBarTintColor = "", this.preferredControlTintColor = "", this.presentationStyle = IosWebViewOptionsPresentationStyle.FULL_SCREEN,
|
|
|
|
this.transitionStyle = IosWebViewOptionsTransitionStyle.COVER_VERTICAL});
|
2019-10-26 20:11:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
"entersReaderIfAvailable": entersReaderIfAvailable,
|
|
|
|
"barCollapsingEnabled": barCollapsingEnabled,
|
2019-10-29 14:27:50 +00:00
|
|
|
"dismissButtonStyle": dismissButtonStyle.toValue(),
|
2019-10-26 20:11:23 +00:00
|
|
|
"preferredBarTintColor": preferredBarTintColor,
|
|
|
|
"preferredControlTintColor": preferredControlTintColor,
|
2019-10-29 14:27:50 +00:00
|
|
|
"presentationStyle": presentationStyle.toValue(),
|
2019-11-04 00:39:23 +00:00
|
|
|
"transitionStyle": transitionStyle.toValue()
|
2019-10-26 20:11:23 +00:00
|
|
|
};
|
|
|
|
}
|
2019-11-04 00:39:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
static IosSafariOptions fromMap(Map<String, dynamic> map) {
|
|
|
|
IosSafariOptions options = new IosSafariOptions();
|
|
|
|
options.entersReaderIfAvailable = map["entersReaderIfAvailable"];
|
|
|
|
options.barCollapsingEnabled = map["barCollapsingEnabled"];
|
|
|
|
options.dismissButtonStyle = IosSafariOptionsDismissButtonStyle.fromValue(map["dismissButtonStyle"]);
|
|
|
|
options.preferredBarTintColor = map["preferredBarTintColor"];
|
|
|
|
options.preferredControlTintColor = map["preferredControlTintColor"];
|
|
|
|
options.presentationStyle = IosWebViewOptionsPresentationStyle.fromValue(map["presentationStyle"]);
|
|
|
|
options.transitionStyle = IosWebViewOptionsTransitionStyle.fromValue(map["transitionStyle"]);
|
|
|
|
return options;
|
|
|
|
}
|
2019-10-26 20:11:23 +00:00
|
|
|
}
|