Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
a5a784dd
Commit
a5a784dd
authored
Nov 13, 2018
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init iOS inline webview implementation
parent
f02791f4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
589 additions
and
527 deletions
+589
-527
.idea/workspace.xml
.idea/workspace.xml
+50
-82
example/lib/main.dart
example/lib/main.dart
+443
-443
flutter_inappbrowser.iml
flutter_inappbrowser.iml
+0
-1
ios/Classes/FlutterWebViewController.swift
ios/Classes/FlutterWebViewController.swift
+51
-0
ios/Classes/FlutterWebViewFactory.swift
ios/Classes/FlutterWebViewFactory.swift
+28
-0
ios/Classes/SwiftFlutterPlugin.swift
ios/Classes/SwiftFlutterPlugin.swift
+3
-1
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+14
-0
No files found.
.idea/workspace.xml
View file @
a5a784dd
...
...
@@ -16,9 +16,10 @@
<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$/example/lib/main.dart"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/lib/main.dart"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/flutter_inappbrowser.iml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/flutter_inappbrowser.iml"
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/"
/>
...
...
@@ -38,8 +39,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=
"
3075
"
>
<caret
line=
"
722"
column=
"20"
lean-forward=
"true"
selection-start-line=
"722"
selection-start-column=
"20"
selection-end-line=
"722"
selection-end-column=
"20
"
/>
<state
relative-caret-position=
"
249
"
>
<caret
line=
"
698"
column=
"61"
selection-start-line=
"698"
selection-start-column=
"61"
selection-end-line=
"698"
selection-end-column=
"61
"
/>
<folding>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
</folding>
...
...
@@ -47,48 +48,19 @@
</provider>
</entry>
</file>
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"
fals
e"
>
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"
tru
e"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
3
00"
>
<caret
line=
"
20"
column=
"39"
lean-forward=
"true"
selection-start-line=
"20"
selection-start-column=
"39"
selection-end-line=
"20"
selection-end-column=
"39
"
/>
<state
relative-caret-position=
"
5
00"
>
<caret
line=
"
376"
column=
"38"
selection-start-line=
"376"
selection-start-column=
"38"
selection-end-line=
"376"
selection-end-column=
"38
"
/>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#16428#0"
expanded=
"true"
/>
<element
signature=
"e#12489#12509#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
</file>
<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=
"327"
>
<caret
line=
"601"
column=
"21"
selection-start-line=
"601"
selection-start-column=
"21"
selection-end-line=
"601"
selection-end-column=
"21"
/>
<folding>
<element
signature=
"e#0#39#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
</file>
<file
leaf-file-name=
"CHANGELOG.md"
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"45"
>
<caret
line=
"3"
column=
"21"
lean-forward=
"true"
selection-start-line=
"3"
selection-start-column=
"21"
selection-end-line=
"3"
selection-end-column=
"21"
/>
</state>
</provider>
</entry>
</file>
<file
leaf-file-name=
"pubspec.yaml"
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/pubspec.yaml"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"15"
>
<caret
line=
"1"
column=
"103"
selection-start-line=
"1"
selection-start-column=
"103"
selection-end-line=
"1"
selection-end-column=
"103"
/>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component
name=
"FileTemplateManagerImpl"
>
...
...
@@ -173,16 +145,15 @@
<option
value=
"$PROJECT_DIR$/example/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/README.md"
/>
<option
value=
"$PROJECT_DIR$/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
<option
value=
"$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
/>
<option
value=
"$PROJECT_DIR$/example/lib/main.dart"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
</list>
</option>
</component>
<component
name=
"ProjectFrameBounds"
>
<option
name=
"x"
value=
"56"
/>
<option
name=
"y"
value=
"23"
/>
<option
name=
"width"
value=
"1
863
"
/>
<option
name=
"width"
value=
"1
641
"
/>
<option
name=
"height"
value=
"1027"
/>
</component>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
...
...
@@ -191,8 +162,19 @@
<foldersAlwaysOnTop
value=
"true"
/>
</navigator>
<panes>
<pane
id=
"PackagesPane"
/>
<pane
id=
"AndroidView"
/>
<pane
id=
"PackagesPane"
/>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
>
<expand>
<path>
<item
name=
"Root"
type=
"cbb8eebc:String"
user=
"Root"
/>
<item
name=
"flutter_inappbrowser"
type=
"cbb8eebc:String"
user=
"flutter_inappbrowser"
/>
</path>
</expand>
<select
/>
</subPane>
</pane>
<pane
id=
"ProjectPane"
>
<subPane>
<expand>
...
...
@@ -210,17 +192,6 @@
</subPane>
<option
name=
"show-excluded-files"
value=
"false"
/>
</pane>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
>
<expand>
<path>
<item
name=
"Root"
type=
"cbb8eebc:String"
user=
"Root"
/>
<item
name=
"flutter_inappbrowser"
type=
"cbb8eebc:String"
user=
"flutter_inappbrowser"
/>
</path>
</expand>
<select
/>
</subPane>
</pane>
</panes>
</component>
<component
name=
"PropertiesComponent"
>
...
...
@@ -377,11 +348,11 @@
<servers
/>
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"56"
y=
"23"
width=
"1863"
height=
"1027"
extended-state=
"0"
/>
<editor
active=
"true"
/>
<frame
x=
"0"
y=
"23"
width=
"1641"
height=
"1027"
extended-state=
"0"
/>
<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"
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"
/>
...
...
@@ -390,20 +361,19 @@
<window_info
anchor=
"bottom"
id=
"Dart Analysis"
order=
"14"
weight=
"0.32745314"
/>
<window_info
anchor=
"bottom"
id=
"Run"
order=
"2"
sideWeight=
"0.49478307"
weight=
"0.29437706"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49533224"
visible=
"true
"
weight=
"0.24696803"
/>
<window_info
a
nchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49533224
"
weight=
"0.24696803"
/>
<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.49
724367"
visible=
"true"
weight=
"0.13179572
"
/>
<window_info
id=
"Structure"
order=
"1"
sideWeight=
"0.50275636"
side_tool=
"true"
weight=
"0.1910871
"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
sideWeight=
"0.49
63925"
visible=
"true"
weight=
"0.13445903
"
/>
<window_info
active=
"true"
id=
"Structure"
order=
"1"
sideWeight=
"0.5036075"
side_tool=
"true"
visible=
"true"
weight=
"0.13445903
"
/>
<window_info
anchor=
"right"
id=
"Device File Explorer"
order=
"5"
side_tool=
"true"
/>
<window_info
anchor=
"right"
id=
"Theme Preview"
order=
"7"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.34288865"
/>
<window_info
id=
"Favorites"
order=
"5"
side_tool=
"true"
/>
<window_info
anchor=
"right"
id=
"Flutter Inspector"
order=
"3"
weight=
"0.32938388"
/>
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"12"
weight=
"0.23594266"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Commander"
order=
"0"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Assistant"
order=
"8"
visible=
"true"
weight=
"0.3295129"
/>
...
...
@@ -659,13 +629,17 @@
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/
lib/flutter_inappbrowser.dart
"
>
<entry
file=
"file://$PROJECT_DIR$/
pubspec.yaml
"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"3075"
>
<caret
line=
"722"
column=
"20"
lean-forward=
"true"
selection-start-line=
"722"
selection-start-column=
"20"
selection-end-line=
"722"
selection-end-column=
"20"
/>
<folding>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
</folding>
<state
relative-caret-position=
"15"
>
<caret
line=
"1"
column=
"103"
selection-start-line=
"1"
selection-start-column=
"103"
selection-end-line=
"1"
selection-end-column=
"103"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state>
<caret
selection-end-line=
"3"
selection-end-column=
"21"
/>
</state>
</provider>
</entry>
...
...
@@ -673,33 +647,27 @@
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"327"
>
<caret
line=
"601"
column=
"21"
selection-start-line=
"601"
selection-start-column=
"21"
selection-end-line=
"601"
selection-end-column=
"21"
/>
<folding>
<element
signature=
"e#0#39#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/
example/lib/main
.dart"
>
<entry
file=
"file://$PROJECT_DIR$/
lib/flutter_inappbrowser
.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
300
"
>
<caret
line=
"
20"
column=
"39"
lean-forward=
"true"
selection-start-line=
"20"
selection-start-column=
"39"
selection-end-line=
"20"
selection-end-column=
"39
"
/>
<state
relative-caret-position=
"
249
"
>
<caret
line=
"
698"
column=
"61"
selection-start-line=
"698"
selection-start-column=
"61"
selection-end-line=
"698"
selection-end-column=
"61
"
/>
<folding>
<element
signature=
"e#
0#20
#0"
expanded=
"true"
/>
<element
signature=
"e#
814#831
#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=
"15"
>
<caret
line=
"1"
column=
"103"
selection-start-line=
"1"
selection-start-column=
"103"
selection-end-line=
"1"
selection-end-column=
"103"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"45"
>
<caret
line=
"3"
column=
"21"
lean-forward=
"true"
selection-start-line=
"3"
selection-start-column=
"21"
selection-end-line=
"3"
selection-end-column=
"21"
/>
<state
relative-caret-position=
"500"
>
<caret
line=
"376"
column=
"38"
selection-start-line=
"376"
selection-start-column=
"38"
selection-end-line=
"376"
selection-end-column=
"38"
/>
<folding>
<element
signature=
"e#0#16428#0"
expanded=
"true"
/>
<element
signature=
"e#12489#12509#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
...
...
example/lib/main.dart
View file @
a5a784dd
import
'dart:async'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
class
MyInAppBrowser
extends
InAppBrowser
{
@override
Future
onBrowserCreated
()
async
{
print
(
"
\n\n
Browser Ready!
\n\n
"
);
}
@override
Future
onLoadStart
(
String
url
)
async
{
print
(
"
\n\n
Started
$url
\n\n
"
);
// print("\n\n ${await this.isHidden()} \n\n");
// print(await this.webViewController.canGoBack());
// print(await this.webViewController.canGoForward());
}
@override
Future
onLoadStop
(
String
url
)
async
{
print
(
"
\n\n
Stopped
$url
\n\n
"
);
// print(base64.encode(await this.webViewController.getFavicon()));
// WebHistory history = await this.webViewController.getCopyBackForwardList();
// print(history.list.length);
// print(history.currentIndex);
// print(history.list[history.currentIndex].url);
// for(WebHistoryItem item in history.list) {
// print(item.title);
//import 'dart:async';
//import 'dart:convert';
//import 'package:flutter/material.dart';
//import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
//
//class MyInAppBrowser extends InAppBrowser {
// @override
// Future onBrowserCreated() async {
// print("\n\nBrowser Ready!\n\n");
// }
//
// print(await this.webViewController.canGoBackOrForward(1));
// if (await this.webViewController.canGoBackOrForward(-2)) {
// this.webViewController.goTo(history.list[0]);
// @override
// Future onLoadStart(String url) async {
// print("\n\nStarted $url\n\n");
//// print("\n\n ${await this.isHidden()} \n\n");
//// print(await this.webViewController.canGoBack());
//// print(await this.webViewController.canGoForward());
// }
// await this.webViewController.goBackOrForward(-1);
// print(await this.webViewController.canGoBack());
// print(await this.webViewController.canGoForward());
// var screenshot = await this.webViewController.takeScreenshot();
// await this.webViewController.injectScriptCode("""
// document.body.innerHTML = '<img style="max-width: 100%; width: 100%" src="data:image/png;base64,${base64.encode(screenshot)}" />';
// """);
// var options = await this.getOptions();
// if (options["javaScriptEnabled"]) {
// await this.setOptions({
// //"progressBar": true,
// //"useOnLoadResource": true,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title A",
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": true,
// "javaScriptEnabled": false,
// "toolbarTop": true,
// "toolbarBottom": false
// });
//
// @override
// Future onLoadStop(String url) async {
// print("\n\nStopped $url\n\n");
//
//// print(base64.encode(await this.webViewController.getFavicon()));
//// WebHistory history = await this.webViewController.getCopyBackForwardList();
//// print(history.list.length);
//// print(history.currentIndex);
//// print(history.list[history.currentIndex].url);
//// for(WebHistoryItem item in history.list) {
//// print(item.title);
//// }
//
////
//// print(await this.webViewController.canGoBackOrForward(1));
//// if (await this.webViewController.canGoBackOrForward(-2)) {
//// this.webViewController.goTo(history.list[0]);
//// }
//
//// await this.webViewController.goBackOrForward(-1);
//
//// print(await this.webViewController.canGoBack());
//// print(await this.webViewController.canGoForward());
//
//// var screenshot = await this.webViewController.takeScreenshot();
//// await this.webViewController.injectScriptCode("""
//// document.body.innerHTML = '<img style="max-width: 100%; width: 100%" src="data:image/png;base64,${base64.encode(screenshot)}" />';
//// """);
//
//// var options = await this.getOptions();
//// if (options["javaScriptEnabled"]) {
//// await this.setOptions({
//// //"progressBar": true,
//// //"useOnLoadResource": true,
//// //"hidden": true,
//// //"toolbarTopFixedTitle": "Fixed title A",
//// //"useShouldOverrideUrlLoading": true
//// //"hideUrlBar": true,
//// "javaScriptEnabled": false,
//// "toolbarTop": true,
//// "toolbarBottom": false
//// });
//// }
//// else {
//// await this.setOptions({
//// //"progressBar": false,
//// //"useOnLoadResource": false,
//// //"hidden": true,
//// //"toolbarTopFixedTitle": "Fixed title B",
//// //"useShouldOverrideUrlLoading": true
//// //"hideUrlBar": false,
//// "javaScriptEnabled": true,
//// "toolbarTop": false,
//// "toolbarBottom": true
//// });
//// }
//
//// print("\n\n ${await this.isHidden()} \n\n");
////
//// await this.webViewController.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest', 1, 5,'string', {'key': 5}, [4,6,8]);");
//// await this.webViewController.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest2', false, null, undefined);");
//// await this.webViewController.injectScriptCode("setTimeout(function(){window.flutter_inappbrowser.callHandler('handlerTest', 'anotherString');}, 1000);");
//
//// await this.webViewController.injectScriptCode("console.log({'testObject': 5});");
//// await this.webViewController.injectScriptCode("console.warn('testWarn',null);");
//// await this.webViewController.injectScriptCode("console.log('testObjectStringify', JSON.stringify({'asd': 5}));");
//// await this.webViewController.injectScriptCode("console.info('testInfo', 6);");
//// await this.webViewController.injectScriptCode("console.error('testError', false);");
//// await this.webViewController.injectScriptCode("console.debug('testDebug', true);");
////
//// print(await this.webViewController.injectScriptCode("document.cookie"));
////
//// print("");
//// print(await CookieManager.getCookies(url));
//// print("");
//// print(await CookieManager.getCookie(url, "my_cookie2"));
//// print("");
//// await CookieManager.deleteCookie(url, "my_cookie2");
//// await CookieManager.deleteCookie(url, "_gid", domain: ".googleblog.com");
//// print("");
//// print(await CookieManager.getCookies(url));
//// print("");
//// await CookieManager.deleteCookies(url);
//// print("");
//// print(await CookieManager.getCookies(url));
//// print("");
//// await CookieManager.deleteAllCookies();
//// print("");
//// print(await CookieManager.getCookies(url));
//// print("");
////
//// print(await this.webViewController.injectScriptCode("null"));
//// print(await this.webViewController.injectScriptCode("undefined"));
//// print(await this.webViewController.injectScriptCode("3"));
//// print(await this.webViewController.injectScriptCode("""
//// function asd (a,b) {
//// return a+b;
//// };
//// asd(3,5);
//// """));
//// print(await this.webViewController.injectScriptCode("""
//// ["3",56,"sdf"];
//// """));
//// print(await this.webViewController.injectScriptCode("""
//// var x = {"as":4, "dfdfg": 6};
//// x;
//// """));
////
//// await this.webViewController.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
//// this.webViewController.injectScriptCode("""
//// \$( "body" ).html( "Next Step..." )
//// """);
////
//// // add custom css
//// this.webViewController.injectStyleCode("""
//// body {
//// background-color: #3c3c3c !important;
//// }
//// """);
//// this.webViewController.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");
// }
// else {
// await this.setOptions({
// //"progressBar": false,
// //"useOnLoadResource": false,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title B",
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": false,
// "javaScriptEnabled": true,
// "toolbarTop": false,
// "toolbarBottom": true
// });
//
// @override
// Future onScrollChanged(int x, int y) async {
//// print(x.toString() + " " + y.toString());
// }
// print("\n\n ${await this.isHidden()} \n\n");
//
// await this.webViewController.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest', 1, 5,'string', {'key': 5}, [4,6,8]);");
// await this.webViewController.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest2', false, null, undefined);");
// await this.webViewController.injectScriptCode("setTimeout(function(){window.flutter_inappbrowser.callHandler('handlerTest', 'anotherString');}, 1000);");
// await this.webViewController.injectScriptCode("console.log({'testObject': 5});");
// await this.webViewController.injectScriptCode("console.warn('testWarn',null);");
// await this.webViewController.injectScriptCode("console.log('testObjectStringify', JSON.stringify({'asd': 5}));");
// await this.webViewController.injectScriptCode("console.info('testInfo', 6);");
// await this.webViewController.injectScriptCode("console.error('testError', false);");
// await this.webViewController.injectScriptCode("console.debug('testDebug', true);");
//
// print(await this.webViewController.injectScriptCode("document.cookie"));
//
// print("");
// print(await CookieManager.getCookies(url));
// print("");
// print(await CookieManager.getCookie(url, "my_cookie2"));
// print("");
// await CookieManager.deleteCookie(url, "my_cookie2");
// await CookieManager.deleteCookie(url, "_gid", domain: ".googleblog.com");
// print("");
// print(await CookieManager.getCookies(url));
// print("");
// await CookieManager.deleteCookies(url);
// print("");
// print(await CookieManager.getCookies(url));
// print("");
// await CookieManager.deleteAllCookies();
// print("");
// print(await CookieManager.getCookies(url));
// print("");
//
// print(await this.webViewController.injectScriptCode("null"));
// print(await this.webViewController.injectScriptCode("undefined"));
// print(await this.webViewController.injectScriptCode("3"));
// print(await this.webViewController.injectScriptCode("""
// function asd (a,b) {
// return a+b;
// };
// asd(3,5);
// """));
// print(await this.webViewController.injectScriptCode("""
// ["3",56,"sdf"];
// """));
// print(await this.webViewController.injectScriptCode("""
// var x = {"as":4, "dfdfg": 6};
// x;
// """));
//
// await this.webViewController.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
// this.webViewController.injectScriptCode("""
// \$( "body" ).html( "Next Step..." )
// """);
//
// // add custom css
// this.webViewController.injectStyleCode("""
// body {
// background-color: #3c3c3c !important;
// @override
// void onLoadError(String url, int code, String message) {
// print("\n\nCan't load $url.. Error: $message\n\n");
// }
// """);
// this.webViewController.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");
}
@override
Future
onScrollChanged
(
int
x
,
int
y
)
async
{
// print(x.toString() + " " + y.toString());
}
@override
void
onLoadError
(
String
url
,
int
code
,
String
message
)
{
print
(
"
\n\n
Can't load
$url
.. Error:
$message
\n\n
"
);
}
@override
void
onProgressChanged
(
int
progress
)
{
// print("Progress: $progress");
}
@override
void
onExit
()
{
print
(
"
\n\n
Browser closed!
\n\n
"
);
}
@override
void
shouldOverrideUrlLoading
(
String
url
)
{
print
(
"
\n\n
override
$url
\n\n
"
);
this
.
webViewController
.
loadUrl
(
url
);
// var postData = "username=my_username&password=my_password";
// inAppBrowserFallback.webViewController.postUrl("http://localhost:8080", utf8.encode(postData));
// var htmlData = """
//<!doctype html>
//<html lang="en">
//<head>
// <meta charset="UTF-8">
// <meta name="viewport"
// content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
// <meta http-equiv="X-UA-Compatible" content="ie=edge">
// <title>Document</title>
// <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
// <link rel="stylesheet" href="http://localhost:8080/assets/css/style.css">
// <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
//</head>
//<body>
//<div class="container">
// <div class="container">
// <img src="http://localhost:8080/assets/images/dart.svg" alt="dart logo">
// <div class="row">
// <div class="col-sm">
// One of three columns
// </div>
// <div class="col-sm">
// One of three columns
// </div>
// <div class="col-sm">
// One of three columns
// </div>
// </div>
// </div>
// <script>
// console.log("hello");
// </script>
//</div>
//</body>
//</html>
// """;
// inAppBrowserFallback.webViewController.loadData(htmlData);
}
@override
void
onLoadResource
(
WebResourceResponse
response
,
WebResourceRequest
request
)
{
print
(
"Started at: "
+
response
.
startTime
.
toString
()
+
"ms ---> duration: "
+
response
.
duration
.
toString
()
+
"ms "
+
response
.
url
);
// if (response.headers["content-length"] != null)
// print(response.headers["content-length"] + " length");
}
@override
void
onConsoleMessage
(
ConsoleMessage
consoleMessage
)
{
print
(
consoleMessage
.
message
);
// print("""
// console output:
// sourceURL: ${consoleMessage.sourceURL}
// lineNumber: ${consoleMessage.lineNumber}
// message: ${consoleMessage.message}
// messageLevel: ${consoleMessage.messageLevel}
// """);
}
}
MyInAppBrowser
inAppBrowserFallback
=
new
MyInAppBrowser
();
class
MyChromeSafariBrowser
extends
ChromeSafariBrowser
{
MyChromeSafariBrowser
(
browserFallback
)
:
super
(
browserFallback
);
@override
void
onOpened
()
{
print
(
"ChromeSafari browser opened"
);
}
@override
void
onLoaded
()
{
print
(
"ChromeSafari browser loaded"
);
}
@override
void
onClosed
()
{
print
(
"ChromeSafari browser closed"
);
}
}
// adding a webview fallback
MyChromeSafariBrowser
chromeSafariBrowser
=
new
MyChromeSafariBrowser
(
inAppBrowserFallback
);
InAppLocalhostServer
localhostServer
=
new
InAppLocalhostServer
();
Future
main
(
)
async
{
// await localhostServer.start();
runApp
(
new
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
new
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@override
void
initState
()
{
super
.
initState
();
// int indexTest = inAppBrowserFallback.webViewController.addJavaScriptHandler("handlerTest",
// (arguments) async {
// print("handlerTest arguments");
// print(arguments);
// });
// int indexTest2 = inAppBrowserFallback.webViewController.addJavaScriptHandler("test2", (arguments) async {
// print("handlerTest2 arguments");
// print(arguments);
// inAppBrowserFallback.webViewController.removeJavaScriptHandler("test", indexTest);
// });
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
MaterialApp
(
home:
new
Scaffold
(
appBar:
new
AppBar
(
title:
const
Text
(
'Flutter InAppBrowser Plugin example app'
),
),
body:
new
Center
(
child:
new
RaisedButton
(
onPressed:
()
async
{
// await chromeSafariBrowser.open("https://flutter.io/");
//
// await InAppBrowser.openWithSystemBrowser("https://flutter.io/");
// @override
// void onProgressChanged(int progress) {
//// print("Progress: $progress");
// }
//
// await inAppBrowserFallback.open(url: "http://localhost:8080/assets/index.html", options: {
// "useOnLoadResource": true,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title",
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": true,
// //"toolbarTop": false,
// "toolbarBottom": false
// });
// @override
// void onExit() {
// print("\n\nBrowser closed!\n\n");
// }
//
// await inAppBrowserFallback.openFile("assets/index.html", options: {
// "useOnLoadResource": true,
// //"hidden": true,
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": true,
// //"toolbarTop": false,
// //"toolbarBottom": false
// });
// @override
// void shouldOverrideUrlLoading(String url) {
// print("\n\n override $url\n\n");
// this.webViewController.loadUrl(url);
//
// await CookieManager.setCookie("https://flutter.io/", "my_cookie2", "cookieValue2", domain: "flutter.io", expiresDate: 1540838864611);
// await CookieManager.setCookie("https://flutter.io/", "my_cookie", "cookieValue", domain: "flutter.io", expiresDate: 1540838864611);
// await inAppBrowserFallback.openData("<html><head><title>Data example</title></head><body><p>This is a \"p\" tag</p></body></html>", options: {});
await
inAppBrowserFallback
.
open
(
url:
"https://flutter.io/"
,
options:
{
//"useOnLoadResource": true,
//"hidden": true,
//"toolbarTopFixedTitle": "Fixed title",
"useShouldOverrideUrlLoading"
:
true
,
//"hideUrlBar": true,
//"toolbarTop": false,
//"toolbarBottom": false
});
},
child:
Text
(
"Open InAppBrowser"
)
),
),
),
);
}
}
// Inline WebView Example
//// var postData = "username=my_username&password=my_password";
//// inAppBrowserFallback.webViewController.postUrl("http://localhost:8080", utf8.encode(postData));
//
//import 'dart:async';
//import 'package:flutter/material.dart';
//import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
//// var htmlData = """
////<!doctype html>
////<html lang="en">
////<head>
//// <meta charset="UTF-8">
//// <meta name="viewport"
//// content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
//// <meta http-equiv="X-UA-Compatible" content="ie=edge">
//// <title>Document</title>
//// <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
//// <link rel="stylesheet" href="http://localhost:8080/assets/css/style.css">
//// <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
////</head>
////<body>
////<div class="container">
//// <div class="container">
//// <img src="http://localhost:8080/assets/images/dart.svg" alt="dart logo">
//// <div class="row">
//// <div class="col-sm">
//// One of three columns
//// </div>
//// <div class="col-sm">
//// One of three columns
//// </div>
//// <div class="col-sm">
//// One of three columns
//// </div>
//// </div>
//// </div>
//// <script>
//// console.log("hello");
//// </script>
////</div>
////</body>
////</html>
//// """;
//// inAppBrowserFallback.webViewController.loadData(htmlData);
// }
//
// @override
// void onLoadResource(
// WebResourceResponse response, WebResourceRequest request) {
// print("Started at: " +
// response.startTime.toString() +
// "ms ---> duration: " +
// response.duration.toString() +
// "ms " +
// response.url);
//// if (response.headers["content-length"] != null)
//// print(response.headers["content-length"] + " length");
// }
//
// @override
// void onConsoleMessage(ConsoleMessage consoleMessage) {
// print(consoleMessage.message);
//// print("""
//// console output:
//// sourceURL: ${consoleMessage.sourceURL}
//// lineNumber: ${consoleMessage.lineNumber}
//// message: ${consoleMessage.message}
//// messageLevel: ${consoleMessage.messageLevel}
//// """);
// }
//}
//
//MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser();
//
//class MyChromeSafariBrowser extends ChromeSafariBrowser {
// MyChromeSafariBrowser(browserFallback) : super(browserFallback);
//
// @override
// void onOpened() {
// print("ChromeSafari browser opened");
// }
//
// @override
// void onLoaded() {
// print("ChromeSafari browser loaded");
// }
//
// @override
// void onClosed() {
// print("ChromeSafari browser closed");
// }
//}
//
//// adding a webview fallback
//MyChromeSafariBrowser chromeSafariBrowser =
// new MyChromeSafariBrowser(inAppBrowserFallback);
//InAppLocalhostServer localhostServer = new InAppLocalhostServer();
//
//Future main() async {
//// await localhostServer.start();
// runApp(new MyApp());
//}
//
...
...
@@ -358,118 +269,207 @@ class _MyAppState extends State<MyApp> {
//}
//
//class _MyAppState extends State<MyApp> {
//
// InAppWebViewController webView;
// String url = "";
// double progress = 0;
//
// @override
// void initState() {
// super.initState();
// }
//
// @override
// void dispose() {
// super.dispose();
//// int indexTest = inAppBrowserFallback.webViewController.addJavaScriptHandler("handlerTest",
//// (arguments) async {
//// print("handlerTest arguments");
//// print(arguments);
//// });
//// int indexTest2 = inAppBrowserFallback.webViewController.addJavaScriptHandler("test2", (arguments) async {
//// print("handlerTest2 arguments");
//// print(arguments);
//// inAppBrowserFallback.webViewController.removeJavaScriptHandler("test", indexTest);
//// });
// }
//
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: Scaffold(
// appBar: AppBar(
// title: const Text('Inline WebView example app'),
// ),
// body: Container(
// child: Column(
// children: <Widget>[
// Container(
// padding: EdgeInsets.all(20.0),
// child: Text("CURRENT URL\n${ (url.length > 50) ? url.substring(0, 50) + "..." : url }"),
// return new MaterialApp(
// home: new Scaffold(
// appBar: new AppBar(
// title: const Text('Flutter InAppBrowser Plugin example app'),
// ),
// (progress != 1.0) ? LinearProgressIndicator(value: progress) : null,
// Expanded(
// child: Container(
// margin: const EdgeInsets.all(10.0),
// decoration: BoxDecoration(
// border: Border.all(color: Colors.blueAccent)
// ),
// child: InAppWebView(
// initialUrl: "https://flutter.io/",
// //initialData: InAppWebViewInitialData("<html><head><title>Data example</title></head><body><p>This is a \"p\" tag</p></body></html>"),
// initialHeaders: {
// body: new Center(
// child: new RaisedButton(
// onPressed: () async {
//// await chromeSafariBrowser.open("https://flutter.io/");
////
//// await InAppBrowser.openWithSystemBrowser("https://flutter.io/");
////
//// await inAppBrowserFallback.open(url: "http://localhost:8080/assets/index.html", options: {
//// "useOnLoadResource": true,
//// //"hidden": true,
//// //"toolbarTopFixedTitle": "Fixed title",
//// //"useShouldOverrideUrlLoading": true
//// //"hideUrlBar": true,
//// //"toolbarTop": false,
//// "toolbarBottom": false
//// });
////
//// await inAppBrowserFallback.openFile("assets/index.html", options: {
//// "useOnLoadResource": true,
//// //"hidden": true,
//// //"useShouldOverrideUrlLoading": true
//// //"hideUrlBar": true,
//// //"toolbarTop": false,
//// //"toolbarBottom": false
//// });
////
//// await CookieManager.setCookie("https://flutter.io/", "my_cookie2", "cookieValue2", domain: "flutter.io", expiresDate: 1540838864611);
//// await CookieManager.setCookie("https://flutter.io/", "my_cookie", "cookieValue", domain: "flutter.io", expiresDate: 1540838864611);
//
// },
// initialOptions: {
//// await inAppBrowserFallback.openData("<html><head><title>Data example</title></head><body><p>This is a \"p\" tag</p></body></html>", options: {});
//
// },
// onWebViewCreated: (InAppWebViewController controller) {
// webView = controller;
// },
// onLoadStart: (InAppWebViewController controller, String url) {
// print("started $url");
// setState(() {
// this.url = url;
// });
// },
// onProgressChanged: (InAppWebViewController controller, int progress) {
// setState(() {
// this.progress = progress/100;
// await inAppBrowserFallback.open(url: "https://flutter.io/", options: {
// //"useOnLoadResource": true,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title",
// "useShouldOverrideUrlLoading": true,
// //"hideUrlBar": true,
// //"toolbarTop": false,
// //"toolbarBottom": false
// });
//
// },
// child: Text("Open InAppBrowser")
// ),
// ),
// ),
// ButtonBar(
// alignment: MainAxisAlignment.center,
// children: <Widget>[
// RaisedButton(
// child: Icon(Icons.arrow_back),
// onPressed: () {
// if (webView != null) {
// webView.goBack();
// }
// },
// ),
// RaisedButton(
// child: Icon(Icons.arrow_forward),
// onPressed: () {
// if (webView != null) {
// webView.goForward();
// }
// },
// ),
// RaisedButton(
// child: Icon(Icons.refresh),
// onPressed: () {
// if (webView != null) {
// webView.reload();
// }
// },
// ),
// ],
// ),
// ].where((Object o) => o != null).toList(),
// ),
// ),
// bottomNavigationBar: BottomNavigationBar(
// currentIndex: 0,
// items: [
// BottomNavigationBarItem(
// icon: Icon(Icons.home),
// title: Text('Home'),
// ),
// BottomNavigationBarItem(
// icon: Icon(Icons.mail),
// title: Text('Item 2'),
// ),
// BottomNavigationBarItem(
// icon: Icon(Icons.person),
// title: Text('Item 3')
// )
// ],
// ),
// ),
// );
// }
//}
// Inline WebView Example
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
Future
main
(
)
async
{
runApp
(
new
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
new
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
InAppWebViewController
webView
;
String
url
=
""
;
double
progress
=
0
;
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Inline WebView example app'
),
),
body:
Container
(
child:
Column
(
children:
<
Widget
>[
Container
(
padding:
EdgeInsets
.
all
(
20.0
),
child:
Text
(
"CURRENT URL
\n
${ (url.length > 50) ? url.substring(0, 50) + "..." : url }
"
),
),
(
progress
!=
1.0
)
?
LinearProgressIndicator
(
value:
progress
)
:
null
,
Expanded
(
child:
Container
(
margin:
const
EdgeInsets
.
all
(
10.0
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Colors
.
blueAccent
)
),
child:
InAppWebView
(
initialUrl:
"https://flutter.io/"
,
//initialData: InAppWebViewInitialData("<html><head><title>Data example</title></head><body><p>This is a \"p\" tag</p></body></html>"),
initialHeaders:
{
},
initialOptions:
{
},
onWebViewCreated:
(
InAppWebViewController
controller
)
{
webView
=
controller
;
},
onLoadStart:
(
InAppWebViewController
controller
,
String
url
)
{
print
(
"started
$url
"
);
setState
(()
{
this
.
url
=
url
;
});
},
onProgressChanged:
(
InAppWebViewController
controller
,
int
progress
)
{
setState
(()
{
this
.
progress
=
progress
/
100
;
});
},
),
),
),
ButtonBar
(
alignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
RaisedButton
(
child:
Icon
(
Icons
.
arrow_back
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
goBack
();
}
},
),
RaisedButton
(
child:
Icon
(
Icons
.
arrow_forward
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
goForward
();
}
},
),
RaisedButton
(
child:
Icon
(
Icons
.
refresh
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
reload
();
}
},
),
],
),
].
where
((
Object
o
)
=>
o
!=
null
).
toList
(),
),
),
bottomNavigationBar:
BottomNavigationBar
(
currentIndex:
0
,
items:
[
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
home
),
title:
Text
(
'Home'
),
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
mail
),
title:
Text
(
'Item 2'
),
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
person
),
title:
Text
(
'Item 3'
)
)
],
),
),
);
}
}
flutter_inappbrowser.iml
View file @
a5a784dd
...
...
@@ -20,7 +20,6 @@
<excludeFolder
url=
"file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/.dart_tool"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/.pub"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/build"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/ios/Flutter/flutter_assets/packages"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/example/ios/Flutter/flutter_assets/packages"
/>
</content>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
...
...
ios/Classes/FlutterWebViewController.swift
0 → 100644
View file @
a5a784dd
//
// FlutterWebViewController.swift
// flutter_inappbrowser
//
// Created by Lorenzo on 13/11/18.
//
import
Foundation
public
class
FlutterWebViewController
:
NSObject
,
FlutterPlatformView
{
private
weak
var
registrar
:
FlutterPluginRegistrar
?
private
var
webView
:
InAppWebView
?
private
var
viewId
:
Int64
=
0
private
var
channel
:
FlutterMethodChannel
?
init
(
registrar
:
FlutterPluginRegistrar
,
withFrame
frame
:
CGRect
,
viewIdentifier
viewId
:
Int64
,
arguments
args
:
NSDictionary
)
{
super
.
init
()
self
.
registrar
=
registrar
self
.
viewId
=
viewId
webView
=
InAppWebView
(
frame
:
frame
)
let
channelName
=
String
(
format
:
"com.pichillilorenzo/flutter_inappwebview_%lld"
,
viewId
)
self
.
channel
=
FlutterMethodChannel
(
name
:
channelName
,
binaryMessenger
:
registrar
.
messenger
())
self
.
channel
?
.
setMethodCallHandler
(
self
.
handle
)
var
initialUrl
=
(
args
[
"initialUrl"
]
as?
String
)
!
let
initialFile
=
args
[
"initialFile"
]
as?
String
let
initialData
=
args
[
"initialData"
]
as?
[
String
:
String
]
let
initialHeaders
=
(
args
[
"initialHeaders"
]
as?
[
String
:
String
])
!
let
initialOptions
=
(
args
[
"initialOptions"
]
as?
[
String
:
Any
])
!
webView
!.
load
(
URLRequest
(
url
:
URL
(
string
:
initialUrl
)
!
))
}
public
func
view
()
->
UIView
{
return
webView
!
}
public
func
handle
(
_
call
:
FlutterMethodCall
,
result
:
@escaping
FlutterResult
)
{
let
arguments
=
call
.
arguments
as?
NSDictionary
switch
call
.
method
{
//case "open":
//self.open(uuid: uuid, arguments: arguments!, result: result)
//break
default
:
result
(
FlutterMethodNotImplemented
)
break
}
}
}
ios/Classes/FlutterWebViewFactory.swift
0 → 100644
View file @
a5a784dd
//
// FlutterWebViewFactory.swift
// flutter_inappbrowser
//
// Created by Lorenzo on 13/11/18.
//
import
Flutter
import
Foundation
public
class
FlutterWebViewFactory
:
NSObject
,
FlutterPlatformViewFactory
{
private
weak
var
registrar
:
FlutterPluginRegistrar
?
init
(
registrar
:
FlutterPluginRegistrar
?)
{
super
.
init
()
self
.
registrar
=
registrar
}
public
func
createArgsCodec
()
->
FlutterMessageCodec
&
NSObjectProtocol
{
return
FlutterStandardMessageCodec
.
sharedInstance
()
}
public
func
create
(
withFrame
frame
:
CGRect
,
viewIdentifier
viewId
:
Int64
,
arguments
args
:
Any
?)
->
FlutterPlatformView
{
let
arguments
=
args
as?
NSDictionary
let
webviewController
=
FlutterWebViewController
(
registrar
:
registrar
!
,
withFrame
:
frame
,
viewIdentifier
:
viewId
,
arguments
:
arguments
!
)
return
webviewController
}
}
ios/Classes/SwiftFlutterPlugin.swift
View file @
a5a784dd
...
...
@@ -36,12 +36,12 @@ extension Dictionary where Key: ExpressibleByStringLiteral {
public
class
SwiftFlutterPlugin
:
NSObject
,
FlutterPlugin
{
static
var
registrar
:
FlutterPluginRegistrar
?
var
channel
:
FlutterMethodChannel
var
webViewControllers
:
[
String
:
InAppBrowserWebViewController
?]
=
[:]
var
safariViewControllers
:
[
String
:
Any
?]
=
[:]
var
tmpWindow
:
UIWindow
?
var
channel
:
FlutterMethodChannel
private
var
previousStatusBarStyle
=
-
1
public
init
(
with
registrar
:
FlutterPluginRegistrar
)
{
...
...
@@ -56,6 +56,8 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
let
instance
=
SwiftFlutterPlugin
(
with
:
registrar
)
registrar
.
addMethodCallDelegate
(
instance
,
channel
:
channel
)
registrar
.
register
(
FlutterWebViewFactory
(
registrar
:
registrar
)
as
FlutterPlatformViewFactory
,
withId
:
"com.pichillilorenzo/flutter_inappwebview"
)
if
#available(iOS 11.0, *)
{
MyCookieManager
(
registrar
:
registrar
)
}
else
{
...
...
lib/flutter_inappbrowser.dart
View file @
a5a784dd
...
...
@@ -694,6 +694,20 @@ class _InAppWebViewState extends State<InAppWebView> {
creationParamsCodec:
const
StandardMessageCodec
(),
),
);
}
else
if
(
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
return
UiKitView
(
viewType:
'com.pichillilorenzo/flutter_inappwebview'
,
onPlatformViewCreated:
_onPlatformViewCreated
,
gestureRecognizers:
widget
.
gestureRecognizers
,
creationParams:
<
String
,
dynamic
>{
'initialUrl'
:
widget
.
initialUrl
,
'initialFile'
:
widget
.
initialFile
,
'initialData'
:
widget
.
initialData
?.
toMap
(),
'initialHeaders'
:
widget
.
initialHeaders
,
'initialOptions'
:
widget
.
initialOptions
},
creationParamsCodec:
const
StandardMessageCodec
(),
);
}
return
Text
(
'
$defaultTargetPlatform
is not yet supported by the flutter_inappbrowser plugin'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment