Skip to content

Commit

Permalink
Work/swift4.2 (#227)
Browse files Browse the repository at this point in the history
* Swift 4.2 conversion

* Bump version number

* Update swift_version
  • Loading branch information
wtmoose authored Sep 19, 2018
1 parent 07597ba commit 241b968
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 236 deletions.
23 changes: 3 additions & 20 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@
remoteGlobalIDString = 86B48AEC1D5A41C900063E2B;
remoteInfo = SwiftMessages;
};
22FB324221193A3B005C13D9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 22FB323A21193A3B005C13D9 /* SwiftMessages.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 224FB6A121163FB90081D4DE;
remoteInfo = SwiftMessagesSegueExtras;
};
22FB324421193A3B005C13D9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 22FB323A21193A3B005C13D9 /* SwiftMessages.xcodeproj */;
Expand Down Expand Up @@ -120,7 +113,6 @@
isa = PBXGroup;
children = (
22FB324121193A3B005C13D9 /* SwiftMessages.framework */,
22FB324321193A3B005C13D9 /* SwiftMessagesSegueExtras.framework */,
22FB324521193A3B005C13D9 /* SwiftMessagesTests.xctest */,
);
name = Products;
Expand Down Expand Up @@ -209,7 +201,7 @@
86AEDCE11D5D1DB70030232E = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 38R82CD868;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -245,13 +237,6 @@
remoteRef = 22FB324021193A3B005C13D9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
22FB324321193A3B005C13D9 /* SwiftMessagesSegueExtras.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SwiftMessagesSegueExtras.framework;
remoteRef = 22FB324221193A3B005C13D9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
22FB324521193A3B005C13D9 /* SwiftMessagesTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
Expand Down Expand Up @@ -443,8 +428,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -459,8 +443,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
window?.tintColor = brandColor
UISwitch.appearance().onTintColor = brandColor
return true
Expand Down
4 changes: 2 additions & 2 deletions Demo/Demo/ExploreViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {

switch presentationContext.selectedSegmentIndex {
case 1:
config.presentationContext = .window(windowLevel: UIWindowLevelNormal)
config.presentationContext = .window(windowLevel: UIWindow.Level.normal)
case 2:
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
default:
break
}
Expand Down
12 changes: 6 additions & 6 deletions Demo/Demo/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ extension UILabel {
func configureBodyTextStyle() {
let bodyStyle = NSMutableParagraphStyle()
bodyStyle.lineSpacing = 5.0
attributedText = NSAttributedString(string: text ?? "", attributes: [NSAttributedStringKey.paragraphStyle : bodyStyle])
attributedText = NSAttributedString(string: text ?? "", attributes: [NSAttributedString.Key.paragraphStyle : bodyStyle])
}

func configureCodeStyle(on substring: String?) {
var attributes: [NSAttributedStringKey : Any] = [:]
var attributes: [NSAttributedString.Key : Any] = [:]
let codeFont = UIFont(name: "CourierNewPSMT", size: font.pointSize)!
attributes[NSAttributedStringKey.font] = codeFont
attributes[NSAttributedStringKey.backgroundColor] = UIColor(white: 0.96, alpha: 1)
attributes[NSAttributedString.Key.font] = codeFont
attributes[NSAttributedString.Key.backgroundColor] = UIColor(white: 0.96, alpha: 1)
attributedText = attributedText?.setAttributes(attributes: attributes, onSubstring: substring)
}
}

extension NSAttributedString {

public func setAttributes(attributes: [NSAttributedStringKey : Any], onSubstring substring: String?) -> NSAttributedString {
public func setAttributes(attributes: [NSAttributedString.Key : Any], onSubstring substring: String?) -> NSAttributedString {
let mutableSelf = NSMutableAttributedString(attributedString: self)
if let substring = substring {
var range = NSRange()
Expand All @@ -46,7 +46,7 @@ extension NSAttributedString {
return mutableSelf
}

private static func set(attributes newAttributes: [NSAttributedStringKey : Any], in range: NSRange, of mutableString: NSMutableAttributedString) {
private static func set(attributes newAttributes: [NSAttributedString.Key : Any], in range: NSRange, of mutableString: NSMutableAttributedString) {
if range.length > 0 {
var attributes = mutableString.attributes(at: range.location, effectiveRange: nil)
for (key, value) in newAttributes {
Expand Down
18 changes: 9 additions & 9 deletions Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
return UITableView.automaticDimension
}

/*
Expand All @@ -71,7 +71,7 @@ class ViewController: UITableViewController {
warning.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: iconText)
warning.button?.isHidden = true
var warningConfig = SwiftMessages.defaultConfig
warningConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
warningConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)

let success = MessageView.viewFromNib(layout: .cardView)
success.configureTheme(.success)
Expand All @@ -80,7 +80,7 @@ class ViewController: UITableViewController {
success.button?.isHidden = true
var successConfig = SwiftMessages.defaultConfig
successConfig.presentationStyle = .center
successConfig.presentationContext = .window(windowLevel: UIWindowLevelNormal)
successConfig.presentationContext = .window(windowLevel: UIWindow.Level.normal)

let info = MessageView.viewFromNib(layout: .messageView)
info.configureTheme(.info)
Expand All @@ -95,14 +95,14 @@ class ViewController: UITableViewController {
status.bodyLabel?.textColor = UIColor.white
status.configureContent(body: "A tiny line of text covering the status bar.")
var statusConfig = SwiftMessages.defaultConfig
statusConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
statusConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)

let status2 = MessageView.viewFromNib(layout: .statusLine)
status2.backgroundView.backgroundColor = UIColor.orange
status2.bodyLabel?.textColor = UIColor.white
status2.configureContent(body: "Switched to light status bar!")
var status2Config = SwiftMessages.defaultConfig
status2Config.presentationContext = .window(windowLevel: UIWindowLevelNormal)
status2Config.presentationContext = .window(windowLevel: UIWindow.Level.normal)
status2Config.preferredStatusBarStyle = .lightContent

SwiftMessages.show(view: error)
Expand All @@ -120,7 +120,7 @@ class ViewController: UITableViewController {
imageView.clipsToBounds = true
let messageView = BaseView(frame: .zero)
messageView.layoutMargins = .zero
messageView.preferredHeight = 120.0
messageView.backgroundHeight = 120.0
do {
let backgroundView = CornerRoundingView()
backgroundView.cornerRadius = 15
Expand All @@ -131,7 +131,7 @@ class ViewController: UITableViewController {
}
messageView.configureDropShadow()
var config = SwiftMessages.defaultConfig
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
SwiftMessages.show(config: config, view: messageView)
}

Expand All @@ -141,7 +141,7 @@ class ViewController: UITableViewController {
view.getTacosAction = { _ in SwiftMessages.hide() }
view.cancelAction = { SwiftMessages.hide() }
var config = SwiftMessages.defaultConfig
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
config.duration = .forever
config.presentationStyle = .bottom
config.dimMode = .gray(interactive: true)
Expand All @@ -160,7 +160,7 @@ class ViewController: UITableViewController {
config.presentationStyle = .center
config.duration = .forever
config.dimMode = .blur(style: .dark, alpha: 1, interactive: true)
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
config.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
SwiftMessages.show(config: config, view: messageView)
}
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ var config = SwiftMessages.Config()
// Slide up from the bottom.
config.presentationStyle = .bottom

// Display in a window at the specified window level: UIWindowLevelStatusBar
// displays over the status bar while UIWindowLevelNormal displays under.
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
// Display in a window at the specified window level: UIWindow.Level.statusBar
// displays over the status bar while UIWindow.Level.normal displays under.
config.presentationContext = .window(windowLevel: .statusBar)

// Disable the default auto-hiding behavior.
config.duration = .forever
Expand Down
4 changes: 2 additions & 2 deletions SwiftMessages.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |spec|
spec.name = 'SwiftMessages'
spec.version = '5.0.1'
spec.version = '5.0.2'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
spec.authors = { 'Timothy Moose' => '[email protected]' }
spec.summary = 'A very flexible message bar for iOS written in Swift.'
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => spec.version}
spec.platform = :ios, '9.0'
spec.swift_version = '4.1'
spec.swift_version = '4.2'
spec.ios.deployment_target = '9.0'
spec.framework = 'UIKit'
spec.requires_arc = true
Expand Down
8 changes: 3 additions & 5 deletions SwiftMessages.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
TargetAttributes = {
86B48AEB1D5A41C900063E2B = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
86B48AF41D5A41C900063E2B = {
Expand Down Expand Up @@ -679,8 +679,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -706,8 +705,7 @@
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.SwiftMessages;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions SwiftMessages/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class AnimationContext {

public protocol Animator: class {

/// Adopting classes should declare as `weak`.
var delegate: AnimationDelegate? { get set }

func show(context: AnimationContext, completion: @escaping AnimationCompletion)
Expand Down
2 changes: 1 addition & 1 deletion SwiftMessages/BaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable {

open override var intrinsicContentSize: CGSize {
if let preferredHeight = (self as InternalPreferredHeight).preferredHeight {
return CGSize(width: UIViewNoIntrinsicMetric, height: preferredHeight)
return CGSize(width: UIView.noIntrinsicMetric, height: preferredHeight)
}
return super.intrinsicContentSize
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftMessages/MarginAdjustable+Animation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public extension MarginAdjustable where Self: UIView {
app.statusBarOrientation == .portrait || app.statusBarOrientation == .portraitUpsideDown {
let frameInWindow = convert(bounds, to: window)
let top = max(0, 20 - frameInWindow.minY)
safeAreaInsets = UIEdgeInsetsMake(top, 0, 0, 0)
safeAreaInsets = UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)
} else {
safeAreaInsets = .zero
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftMessages/MaskingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MaskingView: PassthroughView {
view.frame = bounds
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
addSubview(view)
sendSubview(toBack: view)
sendSubviewToBack(view)
}
}
}
Expand Down
Loading

0 comments on commit 241b968

Please sign in to comment.