Skip to content

Commit

Permalink
Merge milestone_0.4.0 into master for release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
meismyles committed Mar 31, 2017
2 parents 1a4a834 + 8bd3c69 commit a855d16
Show file tree
Hide file tree
Showing 35 changed files with 80 additions and 39 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions Example/SwiftWebVCExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class ViewController: UIViewController {
}

@IBAction func presentModalWithLightBlackTheme() {
let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .lightBlack)
let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .lightBlack, dismissButtonStyle: .cross)
self.present(webVC, animated: true, completion: nil)
}

@IBAction func presentModalWithDarkTheme() {
let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .dark)
let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .dark, dismissButtonStyle: .arrow)
self.present(webVC, animated: true, completion: nil)
}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ Starting in iOS 6 Apple uses `UIActivity` to let you show additional sharing met
SwiftWebVC is a Swift implementation of [Sam Vermette's SVWebViewController](https://github.com/samvermette/SVWebViewController/). Code transcription, updates and changes were carried out by Myles Ringle. The original SVWebViewController was brought to you by [Sam Vermette](http://samvermette.com) and [contributors to the project](https://github.com/samvermette/SVWebViewController/contributors).

If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by [creating new issues](https://github.com/meismyles/SwiftWebVC/issues/new). If you're using SwiftWebVC in your project, attribution is always appreciated.

Thanks to [Icons8](https://icons8.com/) for the images.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "SwiftWebVCActivityChrome.png",
"scale" : "1x"
},
{
Expand All @@ -11,6 +12,7 @@
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...edia.xcassets/SwiftWebVCActivityChrome.imageset/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "SwiftWebVCActivitySafari.png",
"scale" : "1x"
},
{
Expand All @@ -11,6 +12,7 @@
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...edia.xcassets/SwiftWebVCActivitySafari.imageset/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Binary file modified SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Binary file modified ...WebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...VC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "SwiftWebVCActivityChrome-iPad.png",
"filename" : "SwiftWebVCDismissAlt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "SwiftWebVCActivityChrome-iPad@2x.png",
"filename" : "SwiftWebVCDismissAlt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
Expand Down
Binary file modified SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/[email protected]
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 11 additions & 7 deletions SwiftWebVC/SwiftModalWebVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@ public class SwiftModalWebVC: UINavigationController {
public enum SwiftModalWebVCTheme {
case lightBlue, lightBlack, dark
}
public enum SwiftModalWebVCDismissButtonStyle {
case arrow, cross
}

weak var webViewDelegate: UIWebViewDelegate? = nil

public convenience init(urlString: String) {
self.init(pageURL: URL(string: urlString)!)
}

public convenience init(urlString: String, theme: SwiftModalWebVCTheme) {
self.init(pageURL: URL(string: urlString)!, theme: theme)
public convenience init(urlString: String, theme: SwiftModalWebVCTheme, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle) {
self.init(pageURL: URL(string: urlString)!, theme: theme, dismissButtonStyle: dismissButtonStyle)
}

public convenience init(pageURL: URL) {
self.init(request: URLRequest(url: pageURL))
}

public convenience init(pageURL: URL, theme: SwiftModalWebVCTheme) {
self.init(request: URLRequest(url: pageURL), theme: theme)
public convenience init(pageURL: URL, theme: SwiftModalWebVCTheme, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle) {
self.init(request: URLRequest(url: pageURL), theme: theme, dismissButtonStyle: dismissButtonStyle)
}

public init(request: URLRequest, theme: SwiftModalWebVCTheme = .lightBlue) {
public init(request: URLRequest, theme: SwiftModalWebVCTheme = .lightBlue, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle = .arrow) {
let webViewController = SwiftWebVC(aRequest: request)
webViewController.storedStatusColor = UINavigationBar.appearance().barStyle

let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCDismiss"),

let dismissButtonImageName = (dismissButtonStyle == .arrow) ? "SwiftWebVCDismiss" : "SwiftWebVCDismissAlt"
let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: dismissButtonImageName),
style: UIBarButtonItemStyle.plain,
target: webViewController,
action: #selector(SwiftWebVC.doneButtonTapped))
Expand Down
54 changes: 54 additions & 0 deletions SwiftWebVC/SwiftWebVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,59 @@ extension SwiftWebVC: WKNavigationDelegate {
updateToolbarItems()
}

public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {


let url = navigationAction.request.url

let hostAddress = navigationAction.request.url?.host

if (navigationAction.targetFrame == nil) {
if UIApplication.shared.canOpenURL(url!) {
UIApplication.shared.openURL(url!)
}
}
decisionHandler(.allow)

// To connnect app store
if hostAddress == "itunes.apple.com" {
if UIApplication.shared.canOpenURL(navigationAction.request.url!) {
UIApplication.shared.openURL(navigationAction.request.url!)
decisionHandler(.cancel)
return
}
}

let url_elements = url!.absoluteString.components(separatedBy: ":")

switch url_elements[0] {
case "tel":
openCustomApp(urlScheme: "telprompt://", additional_info: url_elements[1])
decisionHandler(.cancel)

case "sms":
openCustomApp(urlScheme: "sms://", additional_info: url_elements[1])
decisionHandler(.cancel)

case "mailto":
openCustomApp(urlScheme: "mailto://", additional_info: url_elements[1])
decisionHandler(.cancel)

default:
print("Default")
}

decisionHandler(.allow)

}

func openCustomApp(urlScheme: String, additional_info:String){

if let requestUrl: URL = URL(string:"\(urlScheme)"+"\(additional_info)") {
let application:UIApplication = UIApplication.shared
if application.canOpenURL(requestUrl) {
application.openURL(requestUrl)
}
}
}
}
7 changes: 1 addition & 6 deletions SwiftWebVC/SwiftWebVCActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ class SwiftWebVCActivity: UIActivity {

override var activityImage : UIImage {
if let type = activityType?.rawValue {
if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
return SwiftWebVC.bundledImage(named: "\(type)-iPad")!
}
else {
return SwiftWebVC.bundledImage(named: "\(type)")!
}
return SwiftWebVC.bundledImage(named: "\(type)")!
}
else{
assert(false, "Unknow type")
Expand Down

0 comments on commit a855d16

Please sign in to comment.