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
303a8d2e
Commit
303a8d2e
authored
Oct 24, 2019
by
Lorenzo Pichilli
Committed by
GitHub
Oct 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #162 from fattiger00/master
migrating to swift 5.0
parents
4b14e44e
29e4474c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
20 deletions
+26
-20
example/ios/Runner.xcodeproj/project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+4
-3
example/ios/Runner/AppDelegate.swift
example/ios/Runner/AppDelegate.swift
+1
-1
ios/Classes/InAppBrowserWebViewController.swift
ios/Classes/InAppBrowserWebViewController.swift
+7
-7
ios/Classes/InAppWebView.swift
ios/Classes/InAppWebView.swift
+1
-1
ios/Classes/SafariViewController.swift
ios/Classes/SafariViewController.swift
+1
-1
ios/Classes/SwiftFlutterPlugin.swift
ios/Classes/SwiftFlutterPlugin.swift
+12
-7
No files found.
example/ios/Runner.xcodeproj/project.pbxproj
View file @
303a8d2e
...
...
@@ -179,7 +179,7 @@
97C146ED1CF9000F007C117D
=
{
CreatedOnToolsVersion
=
7.3.1
;
DevelopmentTeam
=
PFP8UV45Y6
;
LastSwiftMigration
=
091
0
;
LastSwiftMigration
=
110
0
;
};
};
};
...
...
@@ -188,6 +188,7 @@
developmentRegion
=
English
;
hasScannedForEncodings
=
0
;
knownRegions
=
(
English
,
en
,
Base
,
);
...
...
@@ -447,7 +448,7 @@
SWIFT_OBJC_BRIDGING_HEADER
=
"Runner/Runner-Bridging-Header.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_SWIFT3_OBJC_INFERENCE
=
Default
;
SWIFT_VERSION
=
4
.0
;
SWIFT_VERSION
=
5
.0
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
name
=
Debug
;
...
...
@@ -475,7 +476,7 @@
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"Runner/Runner-Bridging-Header.h"
;
SWIFT_SWIFT3_OBJC_INFERENCE
=
Default
;
SWIFT_VERSION
=
4
.0
;
SWIFT_VERSION
=
5
.0
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
name
=
Release
;
...
...
example/ios/Runner/AppDelegate.swift
View file @
303a8d2e
...
...
@@ -5,7 +5,7 @@ import Flutter
@objc
class
AppDelegate
:
FlutterAppDelegate
{
override
func
application
(
_
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
UIApplicationLaunchOptionsKey
:
Any
]?
didFinishLaunchingWithOptions
launchOptions
:
[
UIApplication
.
LaunchOptionsKey
:
Any
]?
)
->
Bool
{
GeneratedPluginRegistrant
.
register
(
with
:
self
)
return
super
.
application
(
application
,
didFinishLaunchingWithOptions
:
launchOptions
)
...
...
ios/Classes/InAppBrowserWebViewController.swift
View file @
303a8d2e
...
...
@@ -172,8 +172,8 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
func
prepareConstraints
()
{
containerWebView_BottomFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
containerWebView
,
attribute
:
NSLayout
Attribute
.
bottom
,
relatedBy
:
NSLayoutRelation
.
equal
,
toItem
:
self
.
view
,
attribute
:
NSLayout
Attribute
.
bottom
,
multiplier
:
1
,
constant
:
0
)
containerWebView_TopFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
containerWebView
,
attribute
:
NSLayout
Attribute
.
top
,
relatedBy
:
NSLayoutRelation
.
equal
,
toItem
:
self
.
view
,
attribute
:
NSLayout
Attribute
.
top
,
multiplier
:
1
,
constant
:
0
)
containerWebView_BottomFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
containerWebView
,
attribute
:
NSLayout
Constraint
.
Attribute
.
bottom
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
self
.
view
,
attribute
:
NSLayoutConstraint
.
Attribute
.
bottom
,
multiplier
:
1
,
constant
:
0
)
containerWebView_TopFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
containerWebView
,
attribute
:
NSLayout
Constraint
.
Attribute
.
top
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
self
.
view
,
attribute
:
NSLayoutConstraint
.
Attribute
.
top
,
multiplier
:
1
,
constant
:
0
)
webView
.
translatesAutoresizingMaskIntoConstraints
=
false
let
height
=
NSLayoutConstraint
(
item
:
webView
,
attribute
:
.
height
,
relatedBy
:
.
equal
,
toItem
:
containerWebView
,
attribute
:
.
height
,
multiplier
:
1
,
constant
:
0
)
...
...
@@ -183,8 +183,8 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
let
bottomContraint
=
NSLayoutConstraint
(
item
:
webView
,
attribute
:
.
bottomMargin
,
relatedBy
:
.
equal
,
toItem
:
containerWebView
,
attribute
:
.
bottomMargin
,
multiplier
:
1
,
constant
:
0
)
containerWebView
.
addConstraints
([
height
,
width
,
leftConstraint
,
rightConstraint
,
bottomContraint
])
webView_BottomFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
webView
,
attribute
:
NSLayout
Attribute
.
bottom
,
relatedBy
:
NSLayoutRelation
.
equal
,
toItem
:
self
.
containerWebView
,
attribute
:
NSLayout
Attribute
.
bottom
,
multiplier
:
1
,
constant
:
0
)
webView_TopFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
webView
,
attribute
:
NSLayout
Attribute
.
top
,
relatedBy
:
NSLayoutRelation
.
equal
,
toItem
:
self
.
containerWebView
,
attribute
:
NSLayout
Attribute
.
top
,
multiplier
:
1
,
constant
:
0
)
webView_BottomFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
webView
,
attribute
:
NSLayout
Constraint
.
Attribute
.
bottom
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
self
.
containerWebView
,
attribute
:
NSLayoutConstraint
.
Attribute
.
bottom
,
multiplier
:
1
,
constant
:
0
)
webView_TopFullScreenConstraint
=
NSLayoutConstraint
(
item
:
self
.
webView
,
attribute
:
NSLayout
Constraint
.
Attribute
.
top
,
relatedBy
:
NSLayoutConstraint
.
Relation
.
equal
,
toItem
:
self
.
containerWebView
,
attribute
:
NSLayoutConstraint
.
Attribute
.
top
,
multiplier
:
1
,
constant
:
0
)
}
func
prepareWebView
()
{
...
...
@@ -254,7 +254,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
func
setWebViewFrame
(
_
frame
:
CGRect
)
{
print
(
"Setting the WebView's frame to
\(
NS
StringFromCGRect
(
frame
)
)
"
)
print
(
"Setting the WebView's frame to
\(
NS
Coder
.
string
(
for
:
frame
)
)
"
)
webView
.
frame
=
frame
}
...
...
@@ -274,13 +274,13 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
if
(
weakSelf
?
.
responds
(
to
:
#selector(
getter: self.presentingViewController
)
))
!
{
weakSelf
?
.
presentingViewController
?
.
dismiss
(
animated
:
true
,
completion
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
})
}
else
{
weakSelf
?
.
parent
?
.
dismiss
(
animated
:
true
,
completion
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
})
}
...
...
ios/Classes/InAppWebView.swift
View file @
303a8d2e
...
...
@@ -240,7 +240,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
takeSnapshot
(
with
:
nil
,
completionHandler
:
{(
image
,
error
)
->
Void
in
var
imageData
:
Data
?
=
nil
if
let
screenshot
=
image
{
imageData
=
UIImagePNGRepresentation
(
screenshot
)
!
imageData
=
screenshot
.
pngData
(
)
!
}
completionHandler
(
imageData
)
})
...
...
ios/Classes/SafariViewController.swift
View file @
303a8d2e
...
...
@@ -43,7 +43,7 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
dismiss
(
animated
:
true
)
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
.
milliseconds
(
400
),
execute
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
if
(
self
.
statusDelegate
!=
nil
)
{
...
...
ios/Classes/SwiftFlutterPlugin.swift
View file @
303a8d2e
...
...
@@ -350,7 +350,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
let
tmpController
=
UIViewController
()
let
baseWindowLevel
=
UIApplication
.
shared
.
keyWindow
?
.
windowLevel
self
.
tmpWindow
?
.
rootViewController
=
tmpController
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
Level
(
baseWindowLevel
!
+
1
)
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
baseWindowLevel
!.
rawValue
+
1
)
self
.
tmpWindow
?
.
makeKeyAndVisible
()
let
browserOptions
:
InAppBrowserOptions
...
...
@@ -435,7 +435,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
// UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: self.previousStatusBarStyle)!
// }
webViewController
.
presentingViewController
?
.
dismiss
(
animated
:
false
,
completion
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
})
}
...
...
@@ -466,7 +466,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
let
tmpController
=
UIViewController
()
let
baseWindowLevel
=
UIApplication
.
shared
.
keyWindow
?
.
windowLevel
self
.
tmpWindow
?
.
rootViewController
=
tmpController
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
Level
(
baseWindowLevel
!
+
1
)
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
baseWindowLevel
!.
rawValue
+
1
)
self
.
tmpWindow
?
.
makeKeyAndVisible
()
let
browserOptions
:
InAppBrowserOptions
...
...
@@ -499,7 +499,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
webViewController
.
webView
.
loadData
(
data
:
data
,
mimeType
:
mimeType
,
encoding
:
encoding
,
baseUrl
:
baseUrl
)
})
webViewController
.
presentingViewController
?
.
dismiss
(
animated
:
false
,
completion
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
})
}
...
...
@@ -518,7 +518,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
}
else
{
if
#available(iOS 10.0, *)
{
UIApplication
.
shared
.
open
(
url
,
options
:
[:]
,
completionHandler
:
nil
)
UIApplication
.
shared
.
open
(
url
,
options
:
convertToUIApplicationOpenExternalURLOptionsKeyDictionary
([:])
,
completionHandler
:
nil
)
}
else
{
UIApplication
.
shared
.
openURL
(
url
)
}
...
...
@@ -536,7 +536,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
DispatchQueue
.
main
.
async
(
execute
:
{()
->
Void
in
if
webViewController
!=
nil
{
let
baseWindowLevel
=
UIApplication
.
shared
.
keyWindow
?
.
windowLevel
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
Level
(
baseWindowLevel
!
+
1
)
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
baseWindowLevel
!.
rawValue
+
1
)
self
.
tmpWindow
?
.
makeKeyAndVisible
()
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
self
.
tmpWindow
?
.
rootViewController
?
.
present
(
webViewController
!
,
animated
:
true
,
completion
:
nil
)
...
...
@@ -558,7 +558,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
DispatchQueue
.
main
.
async
(
execute
:
{()
->
Void
in
if
webViewController
!=
nil
{
webViewController
?
.
presentingViewController
?
.
dismiss
(
animated
:
true
,
completion
:
{()
->
Void
in
self
.
tmpWindow
?
.
windowLevel
=
0.0
self
.
tmpWindow
?
.
windowLevel
=
UIWindow
.
Level
(
rawValue
:
0.0
)
UIApplication
.
shared
.
delegate
?
.
window
??
.
makeKeyAndVisible
()
if
self
.
previousStatusBarStyle
!=
-
1
{
UIApplication
.
shared
.
statusBarStyle
=
UIStatusBarStyle
(
rawValue
:
self
.
previousStatusBarStyle
)
!
...
...
@@ -749,3 +749,8 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate
func
convertToUIApplicationOpenExternalURLOptionsKeyDictionary
(
_
input
:
[
String
:
Any
])
->
[
UIApplication
.
OpenExternalURLOptionsKey
:
Any
]
{
return
Dictionary
(
uniqueKeysWithValues
:
input
.
map
{
key
,
value
in
(
UIApplication
.
OpenExternalURLOptionsKey
(
rawValue
:
key
),
value
)})
}
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