Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Example/SwiftWebVCExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
da,
Expand Down Expand Up @@ -302,7 +303,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -353,7 +354,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -366,25 +367,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 0.5.0.0;
INFOPLIST_FILE = SwiftWebVCExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = com.swiftweb.SwiftWebVCExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
00FFF8691E09977500015C59 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 0.5.0.0;
INFOPLIST_FILE = SwiftWebVCExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = com.swiftweb.SwiftWebVCExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
6 changes: 1 addition & 5 deletions Example/SwiftWebVCExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand All @@ -40,7 +39,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

4 changes: 2 additions & 2 deletions Example/SwiftWebVCExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.4.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>0.4.2.0</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
14 changes: 8 additions & 6 deletions Example/SwiftWebVCExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UIKit

class ViewController: UIViewController {

fileprivate let testUrlString = "https://www.google.com"

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Expand All @@ -22,24 +24,24 @@ class ViewController: UIViewController {

// MARK: Push
@IBAction func push() {
let webVC = SwiftWebVC(urlString: "https://www.google.com")
let webVC = SwiftWebVC(urlString: testUrlString)
webVC.delegate = self
self.navigationController?.pushViewController(webVC, animated: true)
}

// MARK: Modal
@IBAction func presentModalWithDefaultTheme() {
let webVC = SwiftModalWebVC(urlString: "www.google.com")
let webVC = SwiftModalWebVC(urlString: testUrlString)
self.present(webVC, animated: true, completion: nil)
}

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

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

Expand All @@ -48,10 +50,10 @@ class ViewController: UIViewController {
extension ViewController: SwiftWebVCDelegate {

func didStartLoading() {
print("Started loading.")
debugPrint("Started loading.")
}

func didFinishLoading(success: Bool) {
print("Finished loading. Success: \(success).")
debugPrint("Finished loading. Success: \(success).")
}
}
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SwiftWebVC is a simple inline browser for your Swift iOS app.
* Full landscape orientation support
* Back, forward, stop/refresh and share buttons
* Open in Safari and Chrome UIActivities
* Navbar title set to the currently visible web page
* Navbar title set to the currently visible web page or address bar for navigation
* Talks with `setNetworkActivityIndicatorVisible`
* 3 different themes to choose from when presented modally

Expand Down Expand Up @@ -68,13 +68,17 @@ self.present(webVC, animated: true, completion: nil)

### Options

The address bar can be replaced with the site title by passing a flag in to the constructor:
```swift
let webVC = SwiftWebVC(urlString: "http://google.com", showAddressBar: false)
```
The share button can be disabled by passing a flag in to the constructor to specify this:
```swift
let webVC = SwiftWebVC(urlString: "http://google.com", sharingEnabled: false)
```
The same principal applies for the modal implementation also:
```swift
let webVC = SwiftModalWebVC(urlString: "http://google.com", sharingEnabled: false)
let webVC = SwiftModalWebVC(urlString: "http://google.com", sharingEnabled: false, showAddressBar: true)
```

#### Modal Options Only
Expand All @@ -85,8 +89,6 @@ let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .lightBlack)
let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .dark)
```



## Delegate (Start/Finish Loading Callbacks)

SwiftWebVC also includes a delegate protocol that allows you to implement `didStartLoading` and `didFinishLoading` functions to determine when loading starts and finishes.
Expand Down
4 changes: 2 additions & 2 deletions SwiftWebVC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'SwiftWebVC'
s.version = '0.4.2'
s.version = '0.5.0'
s.summary = 'SwiftWebVC is a simple inline browser for your Swift iOS app.'

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -38,7 +38,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/meismyles/SwiftWebVC.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'

s.source_files = 'SwiftWebVC/**/*.swift'

Expand Down
49 changes: 39 additions & 10 deletions SwiftWebVC/SwiftModalWebVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,63 @@ public class SwiftModalWebVC: UINavigationController {

weak var webViewDelegate: UIWebViewDelegate? = nil

public convenience init(urlString: String, sharingEnabled: Bool = true) {
public convenience init(urlString: String,
sharingEnabled: Bool = true,
showAddressBar: Bool = true) {
var urlString = urlString
if !urlString.hasPrefix("https://") && !urlString.hasPrefix("http://") {
urlString = "https://"+urlString
}
self.init(pageURL: URL(string: urlString)!, sharingEnabled: sharingEnabled)
self.init(pageURL: URL(string: urlString)!,
sharingEnabled: sharingEnabled,
showAddressBar: showAddressBar)
}

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

public convenience init(pageURL: URL, sharingEnabled: Bool = true) {
self.init(request: URLRequest(url: pageURL), sharingEnabled: sharingEnabled)
public convenience init(pageURL: URL,
sharingEnabled: Bool = true,
showAddressBar: Bool = true) {
self.init(request: URLRequest(url: pageURL),
sharingEnabled: sharingEnabled,
showAddressBar: showAddressBar)
}

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

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

let dismissButtonImageName = (dismissButtonStyle == .arrow) ? "SwiftWebVCDismiss" : "SwiftWebVCDismissAlt"
let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: dismissButtonImageName),
style: UIBarButtonItemStyle.plain,
style: UIBarButtonItem.Style.plain,
target: webViewController,
action: #selector(SwiftWebVC.doneButtonTapped))

Expand Down
Loading