Commit 651cb656 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

added disableVerticalScroll and disableHorizontalScroll webview options, updated example

parent fed2da63
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- Added `onLoadResourceCustomScheme` event and `resourceCustomSchemes` option to set custom schemes that WebView must handle to load resources - Added `onLoadResourceCustomScheme` event and `resourceCustomSchemes` option to set custom schemes that WebView must handle to load resources
- Added `onTargetBlank` event and `useOnTargetBlank` option to manage links with `target="_blank"` - Added `onTargetBlank` event and `useOnTargetBlank` option to manage links with `target="_blank"`
- Added `ContentBlocker`, `ContentBlockerTrigger` and `ContentBlockerAction` classes and the `contentBlockers` option that allows to define a set of rules to use to block content in the WebView - Added `ContentBlocker`, `ContentBlockerTrigger` and `ContentBlockerAction` classes and the `contentBlockers` option that allows to define a set of rules to use to block content in the WebView
- Added new WebView options: `minimumFontSize`, `debuggingEnabled`, `preferredContentMode`, `applicationNameForUserAgent`, `incognito`, `cacheEnabled` - Added new WebView options: `minimumFontSize`, `debuggingEnabled`, `preferredContentMode`, `applicationNameForUserAgent`, `incognito`, `cacheEnabled`, `disableVerticalScroll`, `disableHorizontalScroll`
- Added new Android WebView options: `allowContentAccess`, `allowFileAccess`, `allowFileAccessFromFileURLs`, `allowUniversalAccessFromFileURLs`, `appCachePath`, `blockNetworkImage`, `blockNetworkLoads`, `cacheMode`, `cursiveFontFamily`, `defaultFixedFontSize`, `defaultFontSize`, `defaultTextEncodingName`, `disabledActionModeMenuItems`, `fantasyFontFamily`, `fixedFontFamily`, `forceDark`, `geolocationEnabled`, `layoutAlgorithm`, `loadWithOverviewMode`, `loadsImagesAutomatically`, `minimumLogicalFontSize`, `needInitialFocus`, `offscreenPreRaster`, `sansSerifFontFamily`, `serifFontFamily`, `standardFontFamily`, `saveFormData`, `thirdPartyCookiesEnabled`, `hardwareAcceleration` - Added new Android WebView options: `allowContentAccess`, `allowFileAccess`, `allowFileAccessFromFileURLs`, `allowUniversalAccessFromFileURLs`, `appCachePath`, `blockNetworkImage`, `blockNetworkLoads`, `cacheMode`, `cursiveFontFamily`, `defaultFixedFontSize`, `defaultFontSize`, `defaultTextEncodingName`, `disabledActionModeMenuItems`, `fantasyFontFamily`, `fixedFontFamily`, `forceDark`, `geolocationEnabled`, `layoutAlgorithm`, `loadWithOverviewMode`, `loadsImagesAutomatically`, `minimumLogicalFontSize`, `needInitialFocus`, `offscreenPreRaster`, `sansSerifFontFamily`, `serifFontFamily`, `standardFontFamily`, `saveFormData`, `thirdPartyCookiesEnabled`, `hardwareAcceleration`
- Added new iOS WebView options: `isFraudulentWebsiteWarningEnabled`, `selectionGranularity`, `dataDetectorTypes`, `sharedCookiesEnabled` - Added new iOS WebView options: `isFraudulentWebsiteWarningEnabled`, `selectionGranularity`, `dataDetectorTypes`, `sharedCookiesEnabled`
- Added `onGeolocationPermissionsShowPrompt` event and `GeolocationPermissionShowPromptResponse` class (available only for Android) - Added `onGeolocationPermissionsShowPrompt` event and `GeolocationPermissionShowPromptResponse` class (available only for Android)
......
...@@ -10,6 +10,7 @@ import android.util.AttributeSet; ...@@ -10,6 +10,7 @@ import android.util.AttributeSet;
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonToken; import android.util.JsonToken;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.DownloadListener; import android.webkit.DownloadListener;
...@@ -677,6 +678,50 @@ final public class InAppWebView extends InputAwareWebView { ...@@ -677,6 +678,50 @@ final public class InAppWebView extends InputAwareWebView {
getChannel().invokeMethod("onFindResultReceived", obj); getChannel().invokeMethod("onFindResultReceived", obj);
} }
}); });
setVerticalScrollBarEnabled(!options.disableVerticalScroll);
setHorizontalScrollBarEnabled(!options.disableHorizontalScroll);
setOnTouchListener(new View.OnTouchListener() {
float m_downX;
float m_downY;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getPointerCount() > 1) {
//Multi touch detected
return true;
}
if (options.disableHorizontalScroll && options.disableVerticalScroll) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
else if (options.disableHorizontalScroll || options.disableVerticalScroll) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
// save the x
m_downX = event.getX();
// save the y
m_downY = event.getY();
break;
}
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
if (options.disableHorizontalScroll) {
// set x so that it doesn't move
event.setLocation(m_downX, event.getY());
} else {
// set y so that it doesn't move
event.setLocation(event.getX(), m_downY);
}
break;
}
}
}
return false;
}
});
} }
public void setIncognito(boolean enabled) { public void setIncognito(boolean enabled) {
...@@ -1093,6 +1138,12 @@ final public class InAppWebView extends InputAwareWebView { ...@@ -1093,6 +1138,12 @@ final public class InAppWebView extends InputAwareWebView {
} }
} }
if (newOptionsMap.get("disableVerticalScroll") != null && options.disableVerticalScroll != newOptions.disableVerticalScroll)
setVerticalScrollBarEnabled(!newOptions.disableVerticalScroll);
if (newOptionsMap.get("disableHorizontalScroll") != null && options.disableHorizontalScroll != newOptions.disableHorizontalScroll)
setHorizontalScrollBarEnabled(!newOptions.disableHorizontalScroll);
options = newOptions; options = newOptions;
} }
......
...@@ -39,6 +39,8 @@ public class InAppWebViewOptions extends Options { ...@@ -39,6 +39,8 @@ public class InAppWebViewOptions extends Options {
public Boolean incognito = false; public Boolean incognito = false;
public Boolean cacheEnabled = true; public Boolean cacheEnabled = true;
public Boolean transparentBackground = false; public Boolean transparentBackground = false;
public Boolean disableVerticalScroll = false;
public Boolean disableHorizontalScroll = false;
public Integer textZoom = 100; public Integer textZoom = 100;
public Boolean clearSessionCache = false; public Boolean clearSessionCache = false;
......
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);
@override
void onOpened() {
print("ChromeSafari browser opened");
}
@override
void onLoaded() {
print("ChromeSafari browser loaded");
}
@override
void onClosed() {
print("ChromeSafari browser closed");
}
}
class ChromeSafariBrowserExampleScreen extends StatefulWidget {
final ChromeSafariBrowser browser =
new MyChromeSafariBrowser(new InAppBrowser());
@override
_ChromeSafariBrowserExampleScreenState createState() =>
new _ChromeSafariBrowserExampleScreenState();
}
class _ChromeSafariBrowserExampleScreenState
extends State<ChromeSafariBrowserExampleScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"ChromeSafariBrowser",
)),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('flutter_inappbrowser example'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('InAppBrowser'),
onTap: () {
Navigator.popAndPushNamed(context, '/InAppBrowser');
},
),
ListTile(
title: Text('ChromeSafariBrowser'),
onTap: () {
Navigator.popAndPushNamed(context, '/ChromeSafariBrowser');
},
),
ListTile(
title: Text('InAppWebView'),
onTap: () {
Navigator.popAndPushNamed(context, '/');
},
),
],
),
),
body: Center(
child: RaisedButton(
onPressed: () async {
await widget.browser.open(
url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions(
androidChromeCustomTabsOptions:
AndroidChromeCustomTabsOptions(
addShareButton: false),
iosSafariOptions:
IosSafariOptions(barCollapsingEnabled: true)));
},
child: Text("Open Chrome Safari Browser")),
));
}
}
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);
@override
void onOpened() {
print("ChromeSafari browser opened");
}
@override
void onLoaded() {
print("ChromeSafari browser loaded");
}
@override
void onClosed() {
print("ChromeSafari browser closed");
}
}
class ChromeSafariExampleScreen extends StatefulWidget {
final ChromeSafariBrowser browser = new MyChromeSafariBrowser(new InAppBrowser());
@override
_ChromeSafariExampleScreenState createState() => new _ChromeSafariExampleScreenState();
}
class _ChromeSafariExampleScreenState extends State<ChromeSafariExampleScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return new Center(
child: new RaisedButton(
onPressed: () async {
await widget.browser.open(url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions(
androidChromeCustomTabsOptions: AndroidChromeCustomTabsOptions(addShareButton: false),
iosSafariOptions: IosSafariOptions(barCollapsingEnabled: true)
)
);
},
child: Text("Open Chrome Safari Browser")),
);
}
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInAppBrowser extends InAppBrowser {
@override
Future onBrowserCreated() async {
print("\n\nBrowser Ready!\n\n");
}
@override
Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n");
}
@override
Future onLoadStop(String url) async {
print("\n\nStopped $url\n\n");
}
@override
Future onScrollChanged(int x, int y) async {
print("Scrolled: x:$x y:$y");
}
@override
void onLoadError(String url, int code, String message) {
print("Can't load $url.. Error: $message");
}
@override
void onProgressChanged(int progress) {
print("Progress: $progress");
}
@override
void onExit() {
print("\n\nBrowser closed!\n\n");
}
@override
void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n");
this.webViewController.loadUrl(url: url);
}
@override
void onLoadResource(LoadedResource response) {
print("Started at: " +
response.startTime.toString() +
"ms ---> duration: " +
response.duration.toString() +
"ms " +
response.url);
}
@override
void onConsoleMessage(ConsoleMessage consoleMessage) {
print("""
console output:
message: ${consoleMessage.message}
messageLevel: ${consoleMessage.messageLevel.toValue()}
""");
}
@override
void onDownloadStart(String url) {
print("Download of " + url);
}
@override
Future<CustomSchemeResponse> onLoadResourceCustomScheme(
String scheme, String url) async {
print("custom scheme: " + scheme);
return null;
}
@override
Future<GeolocationPermissionShowPromptResponse>
onGeolocationPermissionsShowPrompt(String origin) async {
print("request Geolocation permission API");
return null;
}
@override
Future<JsAlertResponse> onJsAlert(String message) async {
return new JsAlertResponse(handledByClient: false, message: "coma iam");
}
@override
Future<JsConfirmResponse> onJsConfirm(String message) {
return null;
}
@override
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
return null;
}
}
class InAppBrowserExampleScreen extends StatefulWidget {
final MyInAppBrowser browser = new MyInAppBrowser();
@override
_InAppBrowserExampleScreenState createState() =>
new _InAppBrowserExampleScreenState();
}
class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"InAppBrowser",
)),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('flutter_inappbrowser example'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('InAppBrowser'),
onTap: () {
Navigator.popAndPushNamed(context, '/InAppBrowser');
},
),
ListTile(
title: Text('ChromeSafariBrowser'),
onTap: () {
Navigator.popAndPushNamed(context, '/ChromeSafariBrowser');
},
),
ListTile(
title: Text('InAppWebView'),
onTap: () {
Navigator.popAndPushNamed(context, '/');
},
),
],
),
),
body: Center(
child: RaisedButton(
onPressed: () {
widget.browser.openFile(
assetFilePath: "assets/index.html",
//url: "https://www.google.com/",
options: InAppBrowserClassOptions(
inAppWebViewWidgetOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useOnLoadResource: true,
))));
},
child: Text("Open Webview Browser")),
));
}
}
This diff is collapsed.
This diff is collapsed.
...@@ -3,9 +3,9 @@ import 'dart:async'; ...@@ -3,9 +3,9 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
import 'package:flutter_inappbrowser_example/chrome_safari_example.screen.dart'; import 'package:flutter_inappbrowser_example/chrome_safari_browser_example.screen.dart';
import 'package:flutter_inappbrowser_example/inline_example.screen.dart'; import 'package:flutter_inappbrowser_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappbrowser_example/webview_example.screen.dart'; import 'package:flutter_inappbrowser_example/in_app_browser_example.screen.dart';
import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
...@@ -39,32 +39,12 @@ class _MyAppState extends State<MyApp> { ...@@ -39,32 +39,12 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
home: DefaultTabController( initialRoute: '/',
length: 3, routes: {
child: Scaffold( '/': (context) => InAppWebViewExampleScreen(),
appBar: AppBar( '/InAppBrowser': (context) => InAppBrowserExampleScreen(),
title: Text('Tabs Demo'), '/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(),
), }
body: TabBarView(
children: [
WebviewExampleScreen(),
ChromeSafariExampleScreen(),
InlineExampleScreen(),
],
),
bottomNavigationBar: Container(
color: Theme.of(context).primaryColor,
child: TabBar(
indicatorColor: Colors.white,
tabs: [
Tab(text: "Webview"),
Tab(text: "Chrome/Safari"),
Tab(
text: "Inline",
),
],
),
))),
); );
} }
} }
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInAppBrowser extends InAppBrowser {
@override
Future onBrowserCreated() async {
print("\n\nBrowser Ready!\n\n");
}
@override
Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n");
}
@override
Future onLoadStop(String url) async {
print("\n\nStopped $url\n\n");
}
@override
Future onScrollChanged(int x, int y) async {
print("Scrolled: x:$x y:$y");
}
@override
void onLoadError(String url, int code, String message) {
print("Can't load $url.. Error: $message");
}
@override
void onProgressChanged(int progress) {
print("Progress: $progress");
}
@override
void onExit() {
print("\n\nBrowser closed!\n\n");
}
@override
void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n");
this.webViewController.loadUrl(url: url);
}
@override
void onLoadResource(LoadedResource response) {
print("Started at: " +
response.startTime.toString() +
"ms ---> duration: " +
response.duration.toString() +
"ms " +
response.url);
}
@override
void onConsoleMessage(ConsoleMessage consoleMessage) {
print("""
console output:
message: ${consoleMessage.message}
messageLevel: ${consoleMessage.messageLevel.toValue()}
""");
}
@override
void onDownloadStart(String url) {
print("Download of " + url);
}
@override
Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) async {
print("custom scheme: " + scheme);
return null;
}
@override
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt(String origin) async {
print("request Geolocation permission API");
return null;
}
@override
Future<JsAlertResponse> onJsAlert(String message) async {
return new JsAlertResponse(handledByClient: false, message: "coma iam");
}
@override
Future<JsConfirmResponse> onJsConfirm(String message) {
return null;
}
@override
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
return null;
}
}
class WebviewExampleScreen extends StatefulWidget {
final MyInAppBrowser browser = new MyInAppBrowser();
static BuildContext context;
@override
_WebviewExampleScreenState createState() => new _WebviewExampleScreenState();
}
class _WebviewExampleScreenState extends State<WebviewExampleScreen> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
WebviewExampleScreen.context = context;
return new Center(
child: new RaisedButton(
onPressed: () {
widget.browser.openFile(
assetFilePath: "assets/index.html",
//url: "https://www.google.com/",
options: InAppBrowserClassOptions(
inAppWebViewWidgetOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useOnLoadResource: true,
)
)
)
);
},
child: Text("Open Webview Browser")),
);
}
}
...@@ -687,6 +687,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi ...@@ -687,6 +687,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
var currentURL: URL? var currentURL: URL?
var startPageTime: Int64 = 0 var startPageTime: Int64 = 0
static var credentialsProposed: [URLCredential] = [] static var credentialsProposed: [URLCredential] = []
var lastScrollX: CGFloat = 0
var lastScrollY: CGFloat = 0
init(frame: CGRect, configuration: WKWebViewConfiguration, IABController: InAppBrowserWebViewController?, IAWController: FlutterWebViewController?) { init(frame: CGRect, configuration: WKWebViewConfiguration, IABController: InAppBrowserWebViewController?, IAWController: FlutterWebViewController?) {
...@@ -843,6 +845,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi ...@@ -843,6 +845,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
scrollView.showsVerticalScrollIndicator = (options?.verticalScrollBarEnabled)! scrollView.showsVerticalScrollIndicator = (options?.verticalScrollBarEnabled)!
scrollView.showsHorizontalScrollIndicator = (options?.horizontalScrollBarEnabled)! scrollView.showsHorizontalScrollIndicator = (options?.horizontalScrollBarEnabled)!
scrollView.showsVerticalScrollIndicator = !(options?.disableVerticalScroll)!
scrollView.showsHorizontalScrollIndicator = !(options?.disableHorizontalScroll)!
// options.debuggingEnabled is always enabled for iOS. // options.debuggingEnabled is always enabled for iOS.
...@@ -1137,6 +1141,13 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi ...@@ -1137,6 +1141,13 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
scrollView.showsHorizontalScrollIndicator = newOptions.horizontalScrollBarEnabled scrollView.showsHorizontalScrollIndicator = newOptions.horizontalScrollBarEnabled
} }
if newOptionsMap["disableVerticalScroll"] != nil && options?.disableVerticalScroll != newOptions.disableVerticalScroll {
scrollView.showsVerticalScrollIndicator = !newOptions.disableVerticalScroll
}
if newOptionsMap["disableHorizontalScroll"] != nil && options?.disableHorizontalScroll != newOptions.disableHorizontalScroll {
scrollView.showsHorizontalScrollIndicator = !newOptions.disableHorizontalScroll
}
if #available(iOS 9.0, *) { if #available(iOS 9.0, *) {
if newOptionsMap["allowsLinkPreview"] != nil && options?.allowsLinkPreview != newOptions.allowsLinkPreview { if newOptionsMap["allowsLinkPreview"] != nil && options?.allowsLinkPreview != newOptions.allowsLinkPreview {
allowsLinkPreview = newOptions.allowsLinkPreview allowsLinkPreview = newOptions.allowsLinkPreview
...@@ -1785,12 +1796,29 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi ...@@ -1785,12 +1796,29 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
} }
public func scrollViewDidScroll(_ scrollView: UIScrollView) { public func scrollViewDidScroll(_ scrollView: UIScrollView) {
let disableVerticalScroll = options?.disableVerticalScroll ?? false
let disableHorizontalScroll = options?.disableHorizontalScroll ?? false
if disableVerticalScroll && disableHorizontalScroll {
scrollView.contentOffset = CGPoint(x: lastScrollX, y: lastScrollY);
}
else if disableVerticalScroll {
if (scrollView.contentOffset.y >= 0 || scrollView.contentOffset.y < 0) {
scrollView.contentOffset = CGPoint(x: scrollView.contentOffset.x, y: lastScrollY);
}
}
else if disableHorizontalScroll {
if (scrollView.contentOffset.x >= 0 || scrollView.contentOffset.x < 0) {
scrollView.contentOffset = CGPoint(x: lastScrollX, y: scrollView.contentOffset.y);
}
}
if navigationDelegate != nil { if navigationDelegate != nil {
let x = Int(scrollView.contentOffset.x / scrollView.contentScaleFactor) let x = Int(scrollView.contentOffset.x / scrollView.contentScaleFactor)
let y = Int(scrollView.contentOffset.y / scrollView.contentScaleFactor) let y = Int(scrollView.contentOffset.y / scrollView.contentScaleFactor)
onScrollChanged(x: x, y: y) onScrollChanged(x: x, y: y)
} }
setNeedsLayout() setNeedsLayout()
lastScrollX = scrollView.contentOffset.x
lastScrollY = scrollView.contentOffset.y
} }
public func onLoadStart(url: String) { public func onLoadStart(url: String) {
......
...@@ -32,6 +32,8 @@ public class InAppWebViewOptions: Options { ...@@ -32,6 +32,8 @@ public class InAppWebViewOptions: Options {
var incognito = false var incognito = false
var cacheEnabled = true var cacheEnabled = true
var transparentBackground = false var transparentBackground = false
var disableVerticalScroll = false
var disableHorizontalScroll = false
var disallowOverScroll = false var disallowOverScroll = false
var enableViewportScale = false var enableViewportScale = false
......
...@@ -101,12 +101,17 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti ...@@ -101,12 +101,17 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
bool cacheEnabled; bool cacheEnabled;
///Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`. ///Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
bool transparentBackground; bool transparentBackground;
///Set to `true` to disable vertical scroll. The default value is `false`.
bool disableVerticalScroll;
///Set to `true` to disable horizontal scroll. The default value is `false`.
bool disableHorizontalScroll;
InAppWebViewOptions({this.useShouldOverrideUrlLoading = false, this.useOnLoadResource = false, this.useOnDownloadStart = false, this.useOnTargetBlank = false, InAppWebViewOptions({this.useShouldOverrideUrlLoading = false, this.useOnLoadResource = false, this.useOnDownloadStart = false, this.useOnTargetBlank = false,
this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", this.javaScriptEnabled = true, this.debuggingEnabled = false, this.javaScriptCanOpenWindowsAutomatically = false, this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", this.javaScriptEnabled = true, this.debuggingEnabled = false, this.javaScriptCanOpenWindowsAutomatically = false,
this.mediaPlaybackRequiresUserGesture = true, this.minimumFontSize, this.verticalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true, this.mediaPlaybackRequiresUserGesture = true, this.minimumFontSize, this.verticalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true,
this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = InAppWebViewUserPreferredContentMode.RECOMMENDED, this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = InAppWebViewUserPreferredContentMode.RECOMMENDED,
this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptFetchRequest = false, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false}) { this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptFetchRequest = false, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false,
this.disableVerticalScroll = false, this.disableHorizontalScroll = false}) {
if (this.minimumFontSize == null) if (this.minimumFontSize == null)
this.minimumFontSize = Platform.isAndroid ? 8 : 0; this.minimumFontSize = Platform.isAndroid ? 8 : 0;
assert(!this.resourceCustomSchemes.contains("http") && !this.resourceCustomSchemes.contains("https")); assert(!this.resourceCustomSchemes.contains("http") && !this.resourceCustomSchemes.contains("https"));
...@@ -140,7 +145,9 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti ...@@ -140,7 +145,9 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
"useShouldInterceptFetchRequest": useShouldInterceptFetchRequest, "useShouldInterceptFetchRequest": useShouldInterceptFetchRequest,
"incognito": incognito, "incognito": incognito,
"cacheEnabled": cacheEnabled, "cacheEnabled": cacheEnabled,
"transparentBackground": transparentBackground "transparentBackground": transparentBackground,
"disableVerticalScroll": disableVerticalScroll,
"disableHorizontalScroll": disableHorizontalScroll
}; };
} }
...@@ -178,6 +185,8 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti ...@@ -178,6 +185,8 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
options.incognito = map["incognito"]; options.incognito = map["incognito"];
options.cacheEnabled = map["cacheEnabled"]; options.cacheEnabled = map["cacheEnabled"];
options.transparentBackground = map["transparentBackground"]; options.transparentBackground = map["transparentBackground"];
options.disableVerticalScroll = map["disableVerticalScroll"];
options.disableHorizontalScroll = map["disableHorizontalScroll"];
return options; return options;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment