Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.19+6

* iOS now can open iframe links and target _blank links.
* Allow zoom and hide the zoom in and zoom out buttons.

## 0.3.19+5

* On iOS, always keep contentInsets of the WebView to be 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
// Allow local storage.
webView.getSettings().setDomStorageEnabled(true);

// Allow zoom and hide the zoom in and zoom out buttons.
webView.getSettings().setSupportZoom(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this setting be controllable by the app developer? any I'd suggest splitting these 2 features to separate PRs

webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);

methodChannel = new MethodChannel(messenger, "plugins.flutter.io/webview_" + id);
methodChannel.setMethodCallHandler(this);

Expand Down
19 changes: 19 additions & 0 deletions packages/webview_flutter/ios/Classes/FlutterWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ - (void)setFrame:(CGRect)frame {

@end

@interface FLTWebViewController () <WKUIDelegate>

@end

@implementation FLTWebViewController {
FLTWKWebView* _webView;
int64_t _viewId;
Expand Down Expand Up @@ -94,6 +98,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_webView = [[FLTWKWebView alloc] initWithFrame:frame configuration:configuration];
_navigationDelegate = [[FLTWKNavigationDelegate alloc] initWithChannel:_channel];
_webView.navigationDelegate = _navigationDelegate;
_webView.UIDelegate = self;
__weak __typeof__(self) weakSelf = self;
[_channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
[weakSelf onMethodCall:call result:result];
Expand Down Expand Up @@ -398,4 +403,18 @@ - (void)updateUserAgent:(NSString*)userAgent {
}
}

// Added to allow for all iframe links / ads to ask the navigationdelegate for rejection or
// acceptance
- (FLTWKWebView*)webView:(FLTWKWebView*)webView
createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
forNavigationAction:(WKNavigationAction*)navigationAction
windowFeatures:(WKWindowFeatures*)windowFeatures {
if (!navigationAction.targetFrame.isMainFrame) {
// ...
[webView loadRequest:navigationAction.request];
}

return nil;
}

@end
4 changes: 2 additions & 2 deletions packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webview_flutter
description: A Flutter plugin that provides a WebView widget on Android and iOS.
version: 0.3.19+5
version: 0.3.19+6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we should consider this a breaking change (as it will break any app relying on these links not being opened)

homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter

environment:
Expand All @@ -24,4 +24,4 @@ flutter:
package: io.flutter.plugins.webviewflutter
pluginClass: WebViewFlutterPlugin
ios:
pluginClass: FLTWebViewFlutterPlugin
pluginClass: FLTWebViewFlutterPlugin