added and class, added method for and
This commit is contained in:
parent
456be7d7f7
commit
ab7b1b68ad
|
@ -15,7 +15,18 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||
|
@ -35,8 +46,8 @@
|
|||
<file leaf-file-name="flutter_inappbrowser.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="428">
|
||||
<caret line="1154" column="46" selection-start-line="1154" selection-start-column="46" selection-end-line="1154" selection-end-column="46" />
|
||||
<state relative-caret-position="561">
|
||||
<caret line="1037" column="43" selection-start-line="1037" selection-start-column="21" selection-end-line="1037" selection-end-column="43" />
|
||||
<folding>
|
||||
<element signature="e#814#831#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -47,17 +58,13 @@
|
|||
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-4">
|
||||
<caret line="1114" selection-start-line="1114" selection-end-line="1114" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="10" selection-start-line="16" selection-start-column="10" selection-end-line="16" selection-end-column="10" />
|
||||
<state relative-caret-position="351">
|
||||
<caret line="48" column="126" selection-start-line="48" selection-start-column="126" selection-end-line="48" selection-end-column="126" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
<element signature="e#0#39#0" expanded="true" />
|
||||
<element signature="e#0#39#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -65,8 +72,8 @@
|
|||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="136">
|
||||
<caret line="293" column="25" selection-start-line="292" selection-start-column="24" selection-end-line="293" selection-end-column="25" />
|
||||
<state>
|
||||
<caret line="234" selection-start-line="234" selection-end-line="234" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -74,6 +81,15 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
|
@ -85,7 +101,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>_controller</find>
|
||||
<find>canGoBack</find>
|
||||
<find>getOp</find>
|
||||
<find>onLoadError</find>
|
||||
|
@ -115,6 +130,7 @@
|
|||
<find>WebView</find>
|
||||
<find>print</find>
|
||||
<find>throw</find>
|
||||
<find>InAppWeb</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>activity.getPreferences(0)</replace>
|
||||
|
@ -157,17 +173,17 @@
|
|||
<option value="$PROJECT_DIR$/example/ios/Flutter/Generated.xcconfig" />
|
||||
<option value="$PROJECT_DIR$/example/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="2040" />
|
||||
<option name="x" value="56" />
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1623" />
|
||||
<option name="width" value="1863" />
|
||||
<option name="height" value="1027" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
|
@ -362,12 +378,12 @@
|
|||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="2040" y="23" width="1623" height="1027" extended-state="0" />
|
||||
<frame x="56" y="23" width="1863" height="1027" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Messages" order="12" weight="0.23594266" />
|
||||
<window_info active="true" anchor="bottom" id="Messages" order="12" visible="true" weight="0.23594266" />
|
||||
<window_info anchor="right" id="Palette	" order="9" />
|
||||
<window_info id="Image Layers" order="7" />
|
||||
<window_info id="Build Variants" order="3" side_tool="true" />
|
||||
|
@ -376,13 +392,13 @@
|
|||
<window_info anchor="bottom" id="Dart Analysis" order="14" weight="0.3276414" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49644473" weight="0.34068358" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.49560633" visible="true" weight="0.30650496" />
|
||||
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49560633" weight="0.20066153" />
|
||||
<window_info anchor="right" id="Flutter Outline" order="6" weight="0.32922077" />
|
||||
<window_info anchor="bottom" id="Logcat" order="11" />
|
||||
<window_info id="Captures" order="4" weight="0.32936507" />
|
||||
<window_info id="Capture Tool" order="6" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.49724367" visible="true" weight="0.15180266" />
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.49724367" visible="true" weight="0.13179572" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.50275636" side_tool="true" weight="0.1910871" />
|
||||
<window_info anchor="right" id="Device File Explorer" order="5" side_tool="true" />
|
||||
<window_info anchor="right" id="Theme Preview" order="7" />
|
||||
|
@ -635,13 +651,6 @@
|
|||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="32" selection-start-line="7" selection-start-column="32" selection-end-line="7" selection-end-column="32" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
|
@ -651,22 +660,34 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="10" selection-start-line="16" selection-start-column="10" selection-end-line="16" selection-end-column="10" />
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" selection-start-line="6" selection-end-line="6" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-4">
|
||||
<caret line="1114" selection-start-line="1114" selection-end-line="1114" />
|
||||
<state relative-caret-position="351">
|
||||
<caret line="48" column="126" selection-start-line="48" selection-start-column="126" selection-end-line="48" selection-end-column="126" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
<element signature="e#0#39#0" expanded="true" />
|
||||
<element signature="e#0#39#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="75">
|
||||
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="428">
|
||||
<caret line="1154" column="46" selection-start-line="1154" selection-start-column="46" selection-end-line="1154" selection-end-column="46" />
|
||||
<state relative-caret-position="561">
|
||||
<caret line="1037" column="43" selection-start-line="1037" selection-start-column="21" selection-end-line="1037" selection-end-column="43" />
|
||||
<folding>
|
||||
<element signature="e#814#831#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -675,8 +696,8 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="136">
|
||||
<caret line="293" column="25" selection-start-line="292" selection-start-column="24" selection-end-line="293" selection-end-column="25" />
|
||||
<state>
|
||||
<caret line="234" selection-start-line="234" selection-end-line="234" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
## 0.5.4
|
||||
|
||||
- added `WebHistory` and `WebHistoryItem` class
|
||||
- added `getCopyBackForwardList` method for `InAppWebView` and `InAppBrowser`
|
||||
|
||||
## 0.5.3
|
||||
|
||||
- added `CookieManager` class
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Flutter InAppBrowser Plugin [![Share on Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Flutter%20InAppBrowser%20plugin!&url=https://github.com/pichillilorenzo/flutter_inappbrowser&hashtags=flutter,flutterio,dart,dartlang,webview) [![Share on Facebook](https://img.shields.io/badge/share-facebook-blue.svg?longCache=true&style=flat&colorB=%234267b2)](https://www.facebook.com/sharer/sharer.php?u=https%3A//github.com/pichillilorenzo/flutter_inappbrowser)
|
||||
|
||||
[![Pub](https://img.shields.io/pub/v/flutter_inappbrowser.svg)](https://pub.dartlang.org/packages/flutter_inappbrowser)
|
||||
[![Awesome Flutter](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://stackoverflow.com/questions/tagged/flutter?sort=votes)
|
||||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE)
|
||||
|
||||
[![Donate to this project using Paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/LorenzoPichilli)
|
||||
|
@ -9,6 +10,10 @@
|
|||
A Flutter plugin that allows you to add an inline webview or open an in-app browser window.
|
||||
This plugin is inspired by the popular [cordova-plugin-inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)!
|
||||
|
||||
### Requirements
|
||||
- Dart sdk: ">=2.1.0-dev.7.1 <3.0.0"
|
||||
- Flutter: ">=0.10.1 <2.0.0"
|
||||
|
||||
### IMPORTANT Note for iOS
|
||||
To be able to use this plugin on iOS, you need to create the Flutter App with `flutter create -i swift` (see [flutter/flutter#13422 (comment)](https://github.com/flutter/flutter/issues/13422#issuecomment-392133780)), otherwise, you will get this message:
|
||||
```
|
||||
|
@ -29,7 +34,7 @@ First, add `flutter_inappbrowser` as a [dependency in your pubspec.yaml file](ht
|
|||
|
||||
## Usage
|
||||
Classes:
|
||||
- [InAppWebView](#inappwebview-class): Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. [**Available only for Android** ([AndroidView](https://docs.flutter.io/flutter/widgets/AndroidView-class.html)) at this moment].
|
||||
- [InAppWebView](#inappwebview-class): Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. [**Available only for Android** ([AndroidView](https://docs.flutter.io/flutter/widgets/AndroidView-class.html)) at this moment. For iOS, it will be available as soon as the Flutter team will release the corresponding dart class.].
|
||||
- [InAppBrowser](#inappbrowser-class): In-App Browser using native WebView.
|
||||
- [ChromeSafariBrowser](#chromesafaribrowser-class): In-App Browser using [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android / [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
|
||||
- [InAppLocalhostServer](#inapplocalhostserver-class): This class allows you to create a simple server on `http://localhost:[port]/`. The default `port` value is `8080`.
|
||||
|
@ -42,6 +47,7 @@ Flutter Widget for adding an **inline native WebView** integrated in the flutter
|
|||
So, if you want use it, you can but you will have some limitation such as the inability to use the keyboard!
|
||||
|
||||
**Available only for Android** ([AndroidView](https://docs.flutter.io/flutter/widgets/AndroidView-class.html)) at this moment.
|
||||
For iOS, it will be available as soon as the Flutter team will release the corresponding dart class.
|
||||
|
||||
Use `InAppWebViewController` to control the WebView instance.
|
||||
Example:
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
@ -186,6 +185,9 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
|
|||
case "getOptions":
|
||||
result.success((webView != null) ? webView.getOptions() : null);
|
||||
break;
|
||||
case "getCopyBackForwardList":
|
||||
result.success((webView != null) ? webView.getCopyBackForwardList() : null);
|
||||
break;
|
||||
case "dispose":
|
||||
dispose();
|
||||
result.success(true);
|
||||
|
@ -201,6 +203,7 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
|
|||
webView.setWebChromeClient(new WebChromeClient());
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
webView.destroy();
|
||||
webView = null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -381,4 +381,11 @@ public class InAppBrowserActivity extends AppCompatActivity {
|
|||
else
|
||||
result.success("");
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getCopyBackForwardList() {
|
||||
if (webView != null)
|
||||
return webView.getCopyBackForwardList();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -265,6 +265,9 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
|||
case "getOptions":
|
||||
result.success(getOptions(uuid));
|
||||
break;
|
||||
case "getCopyBackForwardList":
|
||||
result.success(getCopyBackForwardList(uuid));
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
}
|
||||
|
@ -556,4 +559,11 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getCopyBackForwardList(String uuid) {
|
||||
InAppBrowserActivity inAppBrowserActivity = webViewActivities.get(uuid);
|
||||
if (inAppBrowserActivity != null)
|
||||
return inAppBrowserActivity.getCopyBackForwardList();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import android.util.JsonToken;
|
|||
import android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebBackForwardList;
|
||||
import android.webkit.WebHistoryItem;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
|
@ -22,7 +24,9 @@ import com.pichillilorenzo.flutter_inappbrowser.Util;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
|
@ -394,4 +398,31 @@ public class InAppWebView extends WebView {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getCopyBackForwardList() {
|
||||
WebBackForwardList currentList = copyBackForwardList();
|
||||
int currentSize = currentList.getSize();
|
||||
int currentIndex = currentList.getCurrentIndex();
|
||||
|
||||
List<HashMap<String, String>> history = new ArrayList<HashMap<String, String>>();
|
||||
|
||||
for(int i = 0; i < currentSize; i++) {
|
||||
WebHistoryItem historyItem = currentList.getItemAtIndex(i);
|
||||
HashMap<String, String> historyItemMap = new HashMap<>();
|
||||
|
||||
historyItemMap.put("originalUrl", historyItem.getOriginalUrl());
|
||||
historyItemMap.put("title", historyItem.getTitle());
|
||||
historyItemMap.put("url", historyItem.getUrl());
|
||||
|
||||
history.add(historyItemMap);
|
||||
}
|
||||
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
|
||||
result.put("history", history);
|
||||
result.put("currentIndex", currentIndex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ class MyInAppBrowser extends InAppBrowser {
|
|||
Future onLoadStop(String url) async {
|
||||
print("\n\nStopped $url\n\n");
|
||||
|
||||
WebHistory history = await this.webViewController.getCopyBackForwardList();
|
||||
print(history.list.length);
|
||||
print(history.list[history.currentIndex].url);
|
||||
for(WebHistoryItem item in history.list) {
|
||||
print(item.title);
|
||||
}
|
||||
// print(await this.webViewController.canGoBack());
|
||||
// print(await this.webViewController.canGoForward());
|
||||
|
||||
|
|
|
@ -925,4 +925,30 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
|
|||
self.navigationDelegate?.onProgressChanged(uuid: self.uuid, webView: self.webView, progress: progress)
|
||||
}
|
||||
}
|
||||
|
||||
func getCopyBackForwardList() -> [String: Any] {
|
||||
let currentList = self.webView.backForwardList
|
||||
let currentIndex = currentList.backList.count
|
||||
var completeList = currentList.backList
|
||||
if currentList.currentItem != nil {
|
||||
completeList.append(currentList.currentItem!)
|
||||
}
|
||||
completeList.append(contentsOf: currentList.forwardList)
|
||||
|
||||
var history: [[String: String]] = []
|
||||
|
||||
for historyItem in completeList {
|
||||
var historyItemMap: [String: String] = [:]
|
||||
historyItemMap["originalUrl"] = historyItem.initialURL.absoluteString
|
||||
historyItemMap["title"] = historyItem.title
|
||||
historyItemMap["url"] = historyItem.url.absoluteString
|
||||
history.append(historyItemMap)
|
||||
}
|
||||
|
||||
var result: [String: Any] = [:]
|
||||
result["history"] = history
|
||||
result["currentIndex"] = currentIndex
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,9 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
|||
case "getOptions":
|
||||
result(self.getOptions(uuid: uuid))
|
||||
break
|
||||
case "getCopyBackForwardList":
|
||||
result(self.getCopyBackForwardList(uuid: uuid));
|
||||
break;
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
break
|
||||
|
@ -708,4 +711,11 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
|||
return nil
|
||||
}
|
||||
|
||||
func getCopyBackForwardList(uuid: String) -> [String: Any]? {
|
||||
if let webViewController = self.webViewControllers[uuid] {
|
||||
return webViewController!.getCopyBackForwardList()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -658,6 +658,7 @@ class InAppWebViewController {
|
|||
String _inAppBrowserUuid;
|
||||
InAppBrowser _inAppBrowser;
|
||||
|
||||
|
||||
InAppWebViewController(int id, InAppWebView widget) {
|
||||
_id = id;
|
||||
_channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id');
|
||||
|
@ -1030,12 +1031,59 @@ class InAppWebViewController {
|
|||
return options;
|
||||
}
|
||||
|
||||
///Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack.
|
||||
///This contains only a snapshot of the current state.
|
||||
///Multiple calls to this method may return different objects.
|
||||
///The object returned from this method will not be updated to reflect any new state.
|
||||
Future<WebHistory> getCopyBackForwardList() async {
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
if (_inAppBrowserUuid != null) {
|
||||
_inAppBrowser._throwIsNotOpened();
|
||||
args.putIfAbsent('uuid', () => _inAppBrowserUuid);
|
||||
}
|
||||
Map<dynamic, dynamic> result = await _channel.invokeMethod('getCopyBackForwardList', args);
|
||||
result = result.cast<String, dynamic>();
|
||||
|
||||
List<dynamic> historyListMap = result["history"];
|
||||
historyListMap = historyListMap.cast<LinkedHashMap<dynamic, dynamic>>();
|
||||
|
||||
int currentIndex = result["currentIndex"];
|
||||
|
||||
List<WebHistoryItem> historyList = List();
|
||||
for(LinkedHashMap<dynamic, dynamic> historyItem in historyListMap) {
|
||||
historyList.add(WebHistoryItem(historyItem["originalUrl"], historyItem["title"], historyItem["url"]));
|
||||
}
|
||||
return WebHistory(historyList, currentIndex);
|
||||
}
|
||||
|
||||
Future<void> _dispose() async {
|
||||
await _channel.invokeMethod('dispose');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///WebHistory class.
|
||||
///
|
||||
///This class contains a snapshot of the current back/forward list for a WebView.
|
||||
class WebHistory {
|
||||
List<WebHistoryItem> _list;
|
||||
List<WebHistoryItem> get list => _list;
|
||||
int currentIndex;
|
||||
|
||||
WebHistory(this._list, this.currentIndex);
|
||||
}
|
||||
|
||||
///WebHistoryItem class.
|
||||
///
|
||||
///A convenience class for accessing fields in an entry in the back/forward list of a WebView. Each WebHistoryItem is a snapshot of the requested history item.
|
||||
class WebHistoryItem {
|
||||
String originalUrl;
|
||||
String title;
|
||||
String url;
|
||||
|
||||
WebHistoryItem(this.originalUrl, this.title, this.url);
|
||||
}
|
||||
|
||||
///InAppLocalhostServer class.
|
||||
///
|
||||
///This class allows you to create a simple server on `http://localhost:[port]/` in order to be able to load your assets file on a server. The default [port] value is `8080`.
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
name: flutter_inappbrowser
|
||||
description: A Flutter plugin that allows you to add an inline webview or open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
|
||||
version: 0.5.3
|
||||
version: 0.5.4
|
||||
author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
|
||||
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser
|
||||
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
sdk: ">=2.1.0-dev.7.1 <3.0.0"
|
||||
flutter: ">=0.10.1 <2.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
|
Loading…
Reference in New Issue