Skip to content

Commit

Permalink
Merge pull request #143 from peter9teufel/stop_loading
Browse files Browse the repository at this point in the history
stopLoading() MethodCall
  • Loading branch information
lejard-h authored Aug 5, 2018
2 parents 00e6dc9 + 3244f39 commit ee2b353
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
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 @@ -301,4 +301,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 @@ -196,6 +199,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 @@ -172,6 +172,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

0 comments on commit ee2b353

Please sign in to comment.