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
8b5a6347
Commit
8b5a6347
authored
6 years ago
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on iOS inline webview implementation
parent
a5a784dd
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
922 additions
and
72 deletions
+922
-72
.idea/workspace.xml
.idea/workspace.xml
+60
-33
example/ios/Runner/Info.plist
example/ios/Runner/Info.plist
+4
-0
flutter_inappbrowser.iml
flutter_inappbrowser.iml
+1
-0
ios/Classes/FlutterWebViewController.swift
ios/Classes/FlutterWebViewController.swift
+216
-10
ios/Classes/InAppBrowserWebViewController.swift
ios/Classes/InAppBrowserWebViewController.swift
+3
-2
ios/Classes/InAppWebView.swift
ios/Classes/InAppWebView.swift
+613
-2
ios/Classes/SwiftFlutterPlugin.swift
ios/Classes/SwiftFlutterPlugin.swift
+25
-25
No files found.
.idea/workspace.xml
View file @
8b5a6347
This diff is collapsed.
Click to expand it.
example/ios/Runner/Info.plist
View file @
8b5a6347
...
...
@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key></key>
<string></string>
<key>
NSAppTransportSecurity
</key>
<dict>
<key>
NSAllowsLocalNetworking
</key>
...
...
@@ -44,6 +46,8 @@
<string>
UIInterfaceOrientationLandscapeLeft
</string>
<string>
UIInterfaceOrientationLandscapeRight
</string>
</array>
<key>
io.flutter.embedded_views_preview
</key>
<true/>
<key>
UIViewControllerBasedStatusBarAppearance
</key>
<false/>
</dict>
...
...
This diff is collapsed.
Click to expand it.
flutter_inappbrowser.iml
View file @
8b5a6347
...
...
@@ -20,6 +20,7 @@
<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"
/>
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/FlutterWebViewController.swift
View file @
8b5a6347
This diff is collapsed.
Click to expand it.
ios/Classes/InAppBrowserWebViewController.swift
View file @
8b5a6347
...
...
@@ -130,9 +130,9 @@ func convertToDictionary(text: String) -> [String: Any]? {
//}
class
InAppWebView_IBWrapper
:
InAppWebView
{
required
convenience
init
?
(
coder
:
NSCoder
)
{
required
convenience
init
(
coder
:
NSCoder
)
{
let
config
=
WKWebViewConfiguration
()
self
.
init
(
frame
:
.
zero
,
configuration
:
config
)
self
.
init
(
frame
:
.
zero
,
configuration
:
config
,
IABController
:
nil
,
IAWController
:
nil
)
self
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
...
...
@@ -176,6 +176,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
self
.
webView
.
IABController
=
self
if
!
viewPrepared
{
prepareConstraints
()
prepareWebView
()
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/InAppWebView.swift
View file @
8b5a6347
This diff is collapsed.
Click to expand it.
ios/Classes/SwiftFlutterPlugin.swift
View file @
8b5a6347
...
...
@@ -36,7 +36,7 @@ extension Dictionary where Key: ExpressibleByStringLiteral {
public
class
SwiftFlutterPlugin
:
NSObject
,
FlutterPlugin
{
static
var
registrar
:
FlutterPluginRegistrar
?
var
channel
:
FlutterMethodChannel
static
var
channel
:
FlutterMethodChannel
?
var
webViewControllers
:
[
String
:
InAppBrowserWebViewController
?]
=
[:]
var
safariViewControllers
:
[
String
:
Any
?]
=
[:]
...
...
@@ -45,7 +45,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
private
var
previousStatusBarStyle
=
-
1
public
init
(
with
registrar
:
FlutterPluginRegistrar
)
{
channel
=
FlutterMethodChannel
(
name
:
"com.pichillilorenzo/flutter_inappbrowser"
,
binaryMessenger
:
registrar
.
messenger
())
SwiftFlutterPlugin
.
channel
=
FlutterMethodChannel
(
name
:
"com.pichillilorenzo/flutter_inappbrowser"
,
binaryMessenger
:
registrar
.
messenger
())
}
public
static
func
register
(
with
registrar
:
FlutterPluginRegistrar
)
{
...
...
@@ -220,14 +220,14 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
}
break
case
"setOptions"
:
let
optionsType
=
arguments
!
[
"optionsType"
]
as!
String
;
let
optionsType
=
arguments
!
[
"optionsType"
]
as!
String
switch
(
optionsType
){
case
"InAppBrowserOptions"
:
let
inAppBrowserOptions
=
InAppBrowserOptions
()
;
let
inAppBro
eserOptionsMap
=
arguments
!
[
"options"
]
as!
[
String
:
Any
];
inAppBrowserOptions
.
parse
(
options
:
inAppBro
eserOptionsMap
);
self
.
setOptions
(
uuid
:
uuid
,
options
:
inAppBrowserOptions
,
optionsMap
:
inAppBro
eserOptionsMap
);
break
;
let
inAppBrowserOptions
=
InAppBrowserOptions
()
let
inAppBro
wserOptionsMap
=
arguments
!
[
"options"
]
as!
[
String
:
Any
]
inAppBrowserOptions
.
parse
(
options
:
inAppBro
wserOptionsMap
)
self
.
setOptions
(
uuid
:
uuid
,
options
:
inAppBrowserOptions
,
optionsMap
:
inAppBro
wserOptionsMap
)
break
default
:
result
(
FlutterError
(
code
:
"InAppBrowserFlutterPlugin"
,
message
:
"Options "
+
optionsType
+
" not available."
,
details
:
nil
))
}
...
...
@@ -237,8 +237,8 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
result
(
self
.
getOptions
(
uuid
:
uuid
))
break
case
"getCopyBackForwardList"
:
result
(
self
.
getCopyBackForwardList
(
uuid
:
uuid
))
;
break
;
result
(
self
.
getCopyBackForwardList
(
uuid
:
uuid
))
break
default
:
result
(
FlutterMethodNotImplemented
)
break
...
...
@@ -279,7 +279,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
let
optionsFallback
=
(
arguments
[
"optionsFallback"
]
as?
[
String
:
Any
])
!
open
(
uuid
:
uuid
,
uuidFallback
:
uuidFallback
,
inAppBrowser
:
absoluteUrl
!
,
headers
:
headers
,
withOptions
:
safariOptions
,
useChromeSafariBrowser
:
true
,
withOptionsFallback
:
optionsFallback
,
result
:
result
)
;
open
(
uuid
:
uuid
,
uuidFallback
:
uuidFallback
,
inAppBrowser
:
absoluteUrl
!
,
headers
:
headers
,
withOptions
:
safariOptions
,
useChromeSafariBrowser
:
true
,
withOptionsFallback
:
optionsFallback
,
result
:
result
)
}
else
{
let
options
=
(
arguments
[
"options"
]
as?
[
String
:
Any
])
!
...
...
@@ -702,21 +702,21 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
func
onBrowserCreated
(
uuid
:
String
,
webView
:
WKWebView
)
{
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
channel
.
invokeMethod
(
"onBrowserCreated"
,
arguments
:
[
"uuid"
:
uuid
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onBrowserCreated"
,
arguments
:
[
"uuid"
:
uuid
])
}
}
func
onLoadStart
(
uuid
:
String
,
webView
:
WKWebView
)
{
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
let
url
:
String
=
webViewController
!.
currentURL
!.
absoluteString
channel
.
invokeMethod
(
"onLoadStart"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onLoadStart"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
])
}
}
func
onLoadStop
(
uuid
:
String
,
webView
:
WKWebView
)
{
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
let
url
:
String
=
webViewController
!.
currentURL
!.
absoluteString
channel
.
invokeMethod
(
"onLoadStop"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onLoadStop"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
])
}
}
...
...
@@ -724,13 +724,13 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
let
url
:
String
=
webViewController
!.
currentURL
!.
absoluteString
let
arguments
=
[
"uuid"
:
uuid
,
"url"
:
url
,
"code"
:
error
.
_code
,
"message"
:
error
.
localizedDescription
]
as
[
String
:
Any
]
channel
.
invokeMethod
(
"onLoadError"
,
arguments
:
arguments
)
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onLoadError"
,
arguments
:
arguments
)
}
}
func
onProgressChanged
(
uuid
:
String
,
webView
:
WKWebView
,
progress
:
Int
)
{
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
channel
.
invokeMethod
(
"onProgressChanged"
,
arguments
:
[
"uuid"
:
uuid
,
"progress"
:
progress
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onProgressChanged"
,
arguments
:
[
"uuid"
:
uuid
,
"progress"
:
progress
])
}
}
...
...
@@ -758,50 +758,50 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
"method"
:
request
!.
httpMethod
!
]
]
channel
.
invokeMethod
(
"onLoadResource"
,
arguments
:
arguments
)
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onLoadResource"
,
arguments
:
arguments
)
}
}
func
onScrollChanged
(
uuid
:
String
,
webView
:
WKWebView
,
x
:
Int
,
y
:
Int
)
{
if
let
webViewController
=
self
.
webViewControllers
[
uuid
]
{
channel
.
invokeMethod
(
"onScrollChanged"
,
arguments
:
[
"uuid"
:
uuid
,
"x"
:
x
,
"y"
:
y
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onScrollChanged"
,
arguments
:
[
"uuid"
:
uuid
,
"x"
:
x
,
"y"
:
y
])
}
}
func
onExit
(
uuid
:
String
)
{
channel
.
invokeMethod
(
"onExit"
,
arguments
:
[
"uuid"
:
uuid
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onExit"
,
arguments
:
[
"uuid"
:
uuid
])
}
func
shouldOverrideUrlLoading
(
uuid
:
String
,
webView
:
WKWebView
,
url
:
URL
)
{
if
self
.
webViewControllers
[
uuid
]
!=
nil
{
channel
.
invokeMethod
(
"shouldOverrideUrlLoading"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
.
absoluteString
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"shouldOverrideUrlLoading"
,
arguments
:
[
"uuid"
:
uuid
,
"url"
:
url
.
absoluteString
])
}
}
func
onConsoleMessage
(
uuid
:
String
,
sourceURL
:
String
,
lineNumber
:
Int
,
message
:
String
,
messageLevel
:
String
)
{
if
self
.
webViewControllers
[
uuid
]
!=
nil
{
channel
.
invokeMethod
(
"onConsoleMessage"
,
arguments
:
[
"uuid"
:
uuid
,
"sourceURL"
:
sourceURL
,
"lineNumber"
:
lineNumber
,
"message"
:
message
,
"messageLevel"
:
messageLevel
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onConsoleMessage"
,
arguments
:
[
"uuid"
:
uuid
,
"sourceURL"
:
sourceURL
,
"lineNumber"
:
lineNumber
,
"message"
:
message
,
"messageLevel"
:
messageLevel
])
}
}
func
onChromeSafariBrowserOpened
(
uuid
:
String
)
{
if
self
.
safariViewControllers
[
uuid
]
!=
nil
{
channel
.
invokeMethod
(
"onChromeSafariBrowserOpened"
,
arguments
:
[
"uuid"
:
uuid
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onChromeSafariBrowserOpened"
,
arguments
:
[
"uuid"
:
uuid
])
}
}
func
onChromeSafariBrowserLoaded
(
uuid
:
String
)
{
if
self
.
safariViewControllers
[
uuid
]
!=
nil
{
channel
.
invokeMethod
(
"onChromeSafariBrowserLoaded"
,
arguments
:
[
"uuid"
:
uuid
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onChromeSafariBrowserLoaded"
,
arguments
:
[
"uuid"
:
uuid
])
}
}
func
onChromeSafariBrowserClosed
(
uuid
:
String
)
{
channel
.
invokeMethod
(
"onChromeSafariBrowserClosed"
,
arguments
:
[
"uuid"
:
uuid
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onChromeSafariBrowserClosed"
,
arguments
:
[
"uuid"
:
uuid
])
}
func
onCallJsHandler
(
uuid
:
String
,
webView
:
WKWebView
,
handlerName
:
String
,
args
:
String
)
{
channel
.
invokeMethod
(
"onCallJsHandler"
,
arguments
:
[
"uuid"
:
uuid
,
"handlerName"
:
handlerName
,
"args"
:
args
])
SwiftFlutterPlugin
.
channel
!
.
invokeMethod
(
"onCallJsHandler"
,
arguments
:
[
"uuid"
:
uuid
,
"handlerName"
:
handlerName
,
"args"
:
args
])
}
func
safariExit
(
uuid
:
String
)
{
...
...
This diff is collapsed.
Click to expand it.
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