Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Update for Swift 4.2 #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion PanelKit Test Host/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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 Down
2 changes: 1 addition & 1 deletion PanelKit UI Test Host/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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 Down
40 changes: 15 additions & 25 deletions PanelKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -553,33 +553,33 @@
BE24AD021E4F6B11008892A2 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 6G5LMQ72D8;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
BEBE2F4B1E71FC0A00DEDF21 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 6G5LMQ72D8;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
TestTargetID = BEBE2F611E7208C800DEDF21;
};
BEBE2F611E7208C800DEDF21 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 6G5LMQ72D8;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
BEFCF7651E6759F800BC95ED = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 6G5LMQ72D8;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
TestTargetID = BEFCF7711E675D0600BC95ED;
};
BEFCF7711E675D0600BC95ED = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 6G5LMQ72D8;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -910,8 +910,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;
};
name = Debug;
};
Expand All @@ -932,8 +931,7 @@
PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.PanelKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -946,8 +944,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.PanelKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PanelKit Test Host.app/PanelKit Test Host";
};
name = Debug;
Expand All @@ -961,8 +958,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.PanelKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PanelKit Test Host.app/PanelKit Test Host";
};
name = Release;
Expand All @@ -978,8 +974,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-Test-Host";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -994,8 +989,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-Test-Host";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1008,8 +1002,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-UI-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_TARGET_NAME = "PanelKit UI Test Host";
};
name = Debug;
Expand All @@ -1023,8 +1016,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-UI-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_TARGET_NAME = "PanelKit UI Test Host";
};
name = Release;
Expand All @@ -1040,8 +1032,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-UI-Test-Host";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1056,8 +1047,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "be.silverfox.PanelKit-UI-Test-Host";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
8 changes: 4 additions & 4 deletions PanelKit/Controller/PanelViewController+Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension PanelViewController {
if animated {

let anim = CABasicAnimation(keyPath: #keyPath(CALayer.shadowOpacity))
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
anim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
anim.fromValue = shadowLayer.shadowOpacity
anim.toValue = 0.0
anim.duration = duration
Expand All @@ -42,7 +42,7 @@ extension PanelViewController {
if animated {

let anim = CABasicAnimation(keyPath: #keyPath(CALayer.shadowOpacity))
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
anim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
anim.fromValue = shadowLayer.shadowOpacity
anim.toValue = shadowOpacity
anim.duration = duration
Expand All @@ -61,7 +61,7 @@ extension PanelViewController {
if animated {

let anim = CABasicAnimation(keyPath: #keyPath(CALayer.cornerRadius))
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
anim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
anim.fromValue = panelNavigationController.view.layer.cornerRadius
anim.toValue = 0.0
anim.duration = duration
Expand All @@ -80,7 +80,7 @@ extension PanelViewController {
if animated {

let anim = CABasicAnimation(keyPath: #keyPath(CALayer.cornerRadius))
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
anim.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
anim.fromValue = panelNavigationController.view.layer.cornerRadius
anim.toValue = cornerRadius
anim.duration = duration
Expand Down
18 changes: 9 additions & 9 deletions PanelKit/Controller/PanelViewController+Keyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ extension PanelViewController {
return
}

let animationCurveRawNSN = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIViewAnimationOptions().rawValue
let animationCurve = UIViewAnimationOptions(rawValue: animationCurveRaw)
let animationCurveRawNSN = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIView.AnimationOptions().rawValue
let animationCurve = UIView.AnimationOptions(rawValue: animationCurveRaw)

let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Double ?? 0.3
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0.3

guard var keyboardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else {
guard var keyboardFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else {
return
}

Expand Down Expand Up @@ -108,11 +108,11 @@ extension PanelViewController {
return
}

let animationCurveRawNSN = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIViewAnimationOptions().rawValue
let animationCurve = UIViewAnimationOptions(rawValue: animationCurveRaw)
let animationCurveRawNSN = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIView.AnimationOptions().rawValue
let animationCurve = UIView.AnimationOptions(rawValue: animationCurveRaw)

let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Double ?? 0.3
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0.3

let currentFrame = viewToMove.frame

Expand Down
14 changes: 7 additions & 7 deletions PanelKit/Controller/PanelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ import UIKit
super.init(nibName: nil, bundle: nil)

self.view.addSubview(shadowView)
self.addChildViewController(panelNavigationController)
self.addChild(panelNavigationController)
self.view.addSubview(panelNavigationController.view)
panelNavigationController.didMove(toParentViewController: self)
panelNavigationController.didMove(toParent: self)

panelNavigationController.panelViewController = self

Expand Down Expand Up @@ -159,10 +159,10 @@ import UIKit
print("\(self) viewDidLoad")
}

NotificationCenter.default.addObserver(self, selector: #selector(willShowKeyboard(_ :)), name: .UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willShowKeyboard(_ :)), name: .UIKeyboardWillChangeFrame, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willShowKeyboard(_ :)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willShowKeyboard(_ :)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)

NotificationCenter.default.addObserver(self, selector: #selector(willHideKeyboard(_ :)), name: .UIKeyboardWillHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willHideKeyboard(_ :)), name: UIResponder.keyboardWillHideNotification, object: nil)

}

Expand Down Expand Up @@ -269,8 +269,8 @@ import UIKit
return
}

superview.bringSubview(toFront: self.resizeCornerHandle)
superview.bringSubview(toFront: viewToMove)
superview.bringSubviewToFront(self.resizeCornerHandle)
superview.bringSubviewToFront(viewToMove)

}

Expand Down
4 changes: 2 additions & 2 deletions PanelKit/Utils/BlockBarButtonItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class BlockBarButtonItem: UIBarButtonItem {

private var actionHandler: (() -> Void)?

convenience init(title: String?, style: UIBarButtonItemStyle, actionHandler: (() -> Void)?) {
convenience init(title: String?, style: UIBarButtonItem.Style, actionHandler: (() -> Void)?) {
self.init(title: title, style: style, target: nil, action: #selector(barButtonItemPressed))
self.target = self
self.actionHandler = actionHandler
}

convenience init(image: UIImage?, style: UIBarButtonItemStyle, actionHandler: (() -> Void)?) {
convenience init(image: UIImage?, style: UIBarButtonItem.Style, actionHandler: (() -> Void)?) {
self.init(image: image, style: style, target: nil, action: #selector(barButtonItemPressed))
self.target = self
self.actionHandler = actionHandler
Expand Down