Skip to content

Add 'show', 'hide', and 'reloadUrl' functions #86

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

Merged
merged 5 commits into from
Jun 26, 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ packages
pubspec.lock

example/ios/Podfile.lock
**/Flutter/App.framework/
**/Flutter/Flutter.framework/
**/Flutter/Generated.xcconfig/
**/Flutter/flutter_assets/

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,12 @@ Future<Map<String, dynamic>> getCookies();
```dart
Future<Null> resize(Rect rect);
```
```dart
Future<Null> show();
```
```dart
Future<Null> hide();
```
```dart
Future<Null> reloadUrl(String url);
```
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ version '1.0-SNAPSHOT'

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.1.2'
}
}

Expand All @@ -21,7 +22,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
buildToolsVersion '27.0.3'

defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
case "forward":
forward(call, result);
break;
case "hide":
hide(call, result);
break;
case "show":
show(call, result);
break;
case "reloadUrl":
reloadUrl(call, result);
break;
default:
result.notImplemented();
break;
Expand Down Expand Up @@ -145,6 +154,20 @@ private void reload(MethodCall call, MethodChannel.Result result) {
webViewManager.reload(call, result);
}
}
private void reloadUrl(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
String url = call.argument("url");
webViewManager.openUrl(false,
false,
false,
false,
"",
url,
false,
false
);
}
}
private void eval(MethodCall call, final MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.eval(call, result);
Expand All @@ -158,6 +181,16 @@ private void resize(MethodCall call, final MethodChannel.Result result) {
}
result.success(null);
}
private void hide(MethodCall call, final MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.hide(call, result);
}
}
private void show(MethodCall call, final MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.show(call, result);
}
}

private int dp2px(Context context, float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,14 @@ boolean canGoBack() {
boolean canGoForward() {
return webView.canGoForward();
}
void hide(MethodCall call, MethodChannel.Result result) {
if (webView != null) {
webView.setVisibility(View.INVISIBLE);
}
}
void show(MethodCall call, MethodChannel.Result result) {
if (webView != null) {
webView.setVisibility(View.VISIBLE);
}
}
}
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.3'

lintOptions {
disable 'InvalidPackage'
Expand Down
10 changes: 9 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.1.1'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}

Expand Down
Loading