Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stopLoading() MethodCall #143

Merged
merged 3 commits into from
Aug 5, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
break;
case "reloadUrl":
reloadUrl(call, result);
break;
case "stopLoading":
stopLoading(call, result);
break;
default:
result.notImplemented();
Expand Down Expand Up @@ -128,6 +131,12 @@ private FrameLayout.LayoutParams buildLayoutParams(MethodCall call) {
return params;
}

private void stopLoading(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null){
webViewManager.stopLoading(call, result);
}
}

private void close(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.close(call, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,10 @@ void show(MethodCall call, MethodChannel.Result result) {
webView.setVisibility(View.VISIBLE);
}
}

void stopLoading(MethodCall call, MethodChannel.Result result){
if (webView != null){
webView.stopLoading();
}
}
}
8 changes: 8 additions & 0 deletions ios/Classes/FlutterWebviewPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else if ([@"hide" isEqualToString:call.method]) {
[self hide];
result(nil);
} else if ([@"stopLoading" isEqualToString:call.method]) {
[self stopLoading];
result(nil);
} else {
result(FlutterMethodNotImplemented);
}
Expand Down Expand Up @@ -186,6 +189,11 @@ - (void)hide {
self.webview.hidden = true;
}
}
- (void)stopLoading {
if (self.webview != nil) {
[self.webview stopLoading];
}
}

#pragma mark -- WkWebView Delegate
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
Expand Down
3 changes: 3 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class FlutterWebviewPlugin {
await _channel.invokeMethod('reloadUrl', args);
}

// Stops current loading process
Future stopLoading() => _channel.invokeMethod("stopLoading");

/// adds the plugin as ActivityResultListener
/// Only needed and used on Android
Future registerAcitivityResultListener() =>
Expand Down