Skip to content

Commit

Permalink
convert to swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
0ber committed Sep 17, 2018
1 parent 44b4b8b commit 976aef7
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ open class RAMBounceAnimation: RAMItemAnimation {
textLabel.textColor = defaultTextColor

if let iconImage = icon.image {
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImageRenderingMode.alwaysOriginal :
UIImageRenderingMode.alwaysTemplate
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImage.RenderingMode.alwaysOriginal :
UIImage.RenderingMode.alwaysTemplate
let renderImage = iconImage.withRenderingMode(renderMode)
icon.image = renderImage
icon.tintColor = defaultIconColor
Expand Down Expand Up @@ -77,7 +77,7 @@ open class RAMBounceAnimation: RAMItemAnimation {
let bounceAnimation = CAKeyframeAnimation(keyPath: Constants.AnimationKeys.Scale)
bounceAnimation.values = [1.0, 1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
bounceAnimation.duration = TimeInterval(duration)
bounceAnimation.calculationMode = kCAAnimationCubic
bounceAnimation.calculationMode = CAAnimationCalculationMode.cubic

icon.layer.add(bounceAnimation, forKey: nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ open class RAMFrameItemAnimation: RAMItemAnimation {

@nonobjc func playFrameAnimation(_ icon: UIImageView, images: Array<CGImage>) {
let frameAnimation = CAKeyframeAnimation(keyPath: Constants.AnimationKeys.KeyFrame)
frameAnimation.calculationMode = kCAAnimationDiscrete
frameAnimation.calculationMode = CAAnimationCalculationMode.discrete
frameAnimation.duration = TimeInterval(duration)
frameAnimation.values = images
frameAnimation.repeatCount = 1
frameAnimation.isRemovedOnCompletion = false
frameAnimation.fillMode = kCAFillModeForwards
frameAnimation.fillMode = CAMediaTimingFillMode.forwards
icon.layer.add(frameAnimation, forKey: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ open class RAMFumeAnimation: RAMItemAnimation {
textLabel.textColor = defaultTextColor

if let iconImage = icon.image {
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImageRenderingMode.alwaysOriginal :
UIImageRenderingMode.alwaysTemplate
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImage.RenderingMode.alwaysOriginal :
UIImage.RenderingMode.alwaysTemplate
let renderImage = iconImage.withRenderingMode(renderMode)
icon.image = renderImage
icon.tintColor = defaultIconColor
Expand Down Expand Up @@ -98,12 +98,12 @@ open class RAMFumeAnimation: RAMItemAnimation {
func playLabelAnimation(_ textLabel: UILabel) {

let yPositionAnimation = createAnimation(Constants.AnimationKeys.PositionY, values: [textLabel.center.y as AnyObject, (textLabel.center.y - 60.0) as AnyObject], duration: duration)
yPositionAnimation.fillMode = kCAFillModeRemoved
yPositionAnimation.fillMode = CAMediaTimingFillMode.removed
yPositionAnimation.isRemovedOnCompletion = true
textLabel.layer.add(yPositionAnimation, forKey: nil)

let scaleAnimation = createAnimation(Constants.AnimationKeys.Scale, values: [1.0 as AnyObject, 2.0 as AnyObject], duration: duration)
scaleAnimation.fillMode = kCAFillModeRemoved
scaleAnimation.fillMode = CAMediaTimingFillMode.removed
scaleAnimation.isRemovedOnCompletion = true
textLabel.layer.add(scaleAnimation, forKey: nil)

Expand All @@ -116,8 +116,8 @@ open class RAMFumeAnimation: RAMItemAnimation {
let animation = CAKeyframeAnimation(keyPath: keyPath)
animation.values = values
animation.duration = TimeInterval(duration)
animation.calculationMode = kCAAnimationCubic
animation.fillMode = kCAFillModeForwards
animation.calculationMode = CAAnimationCalculationMode.cubic
animation.fillMode = CAMediaTimingFillMode.forwards
animation.isRemovedOnCompletion = false
return animation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ open class RAMRotationAnimation: RAMItemAnimation {
textLabel.textColor = defaultTextColor

if let iconImage = icon.image {
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImageRenderingMode.alwaysOriginal :
UIImageRenderingMode.alwaysTemplate
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImage.RenderingMode.alwaysOriginal :
UIImage.RenderingMode.alwaysTemplate
let renderImage = iconImage.withRenderingMode(renderMode)
icon.image = renderImage
icon.tintColor = defaultIconColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import UIKit
open class RAMTransitionItemAnimations: RAMItemAnimation {

/// Options for animating. Default TransitionNone
open var transitionOptions: UIViewAnimationOptions!
open var transitionOptions: UIView.AnimationOptions!

override init() {
super.init()

transitionOptions = UIViewAnimationOptions()
transitionOptions = UIView.AnimationOptions()
}

/**
Expand Down Expand Up @@ -60,8 +60,8 @@ open class RAMTransitionItemAnimations: RAMItemAnimation {
open override func deselectAnimation(_ icon: UIImageView, textLabel: UILabel, defaultTextColor: UIColor, defaultIconColor: UIColor) {

if let iconImage = icon.image {
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImageRenderingMode.alwaysOriginal :
UIImageRenderingMode.alwaysTemplate
let renderMode = defaultIconColor.cgColor.alpha == 0 ? UIImage.RenderingMode.alwaysOriginal :
UIImage.RenderingMode.alwaysTemplate
let renderImage = iconImage.withRenderingMode(renderMode)
icon.image = renderImage
icon.tintColor = defaultIconColor
Expand Down Expand Up @@ -97,7 +97,7 @@ open class RAMFlipLeftTransitionItemAnimations: RAMTransitionItemAnimations {
public override init() {
super.init()

transitionOptions = UIViewAnimationOptions.transitionFlipFromLeft
transitionOptions = UIView.AnimationOptions.transitionFlipFromLeft
}
}

Expand All @@ -106,7 +106,7 @@ open class RAMFlipRightTransitionItemAnimations: RAMTransitionItemAnimations {
public override init() {
super.init()

transitionOptions = UIViewAnimationOptions.transitionFlipFromRight
transitionOptions = UIView.AnimationOptions.transitionFlipFromRight
}
}

Expand All @@ -115,7 +115,7 @@ open class RAMFlipTopTransitionItemAnimations: RAMTransitionItemAnimations {
public override init() {
super.init()

transitionOptions = UIViewAnimationOptions.transitionFlipFromTop
transitionOptions = UIView.AnimationOptions.transitionFlipFromTop
}
}

Expand All @@ -124,6 +124,6 @@ open class RAMFlipBottomTransitionItemAnimations: RAMTransitionItemAnimations {
public override init() {
super.init()

transitionOptions = UIViewAnimationOptions.transitionFlipFromBottom
transitionOptions = UIView.AnimationOptions.transitionFlipFromBottom
}
}
40 changes: 20 additions & 20 deletions RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ open class RAMAnimatedTabBarController: UITabBarController {
}
container.tag = index

let renderMode = item.iconColor.cgColor.alpha == 0 ? UIImageRenderingMode.alwaysOriginal :
UIImageRenderingMode.alwaysTemplate
let renderMode = item.iconColor.cgColor.alpha == 0 ? UIImage.RenderingMode.alwaysOriginal :
UIImage.RenderingMode.alwaysTemplate

let iconImage = item.image ?? item.iconView?.icon.image
let icon = UIImageView(image: iconImage?.withRenderingMode(renderMode))
Expand Down Expand Up @@ -347,43 +347,43 @@ open class RAMAnimatedTabBarController: UITabBarController {
createConstraints(view, container: container, width: size.width, height: size.height, yOffset: yOffset)
}

fileprivate func createConstraints(_ view: UIView, container: UIView, width: CGFloat? = nil, height: CGFloat? = nil, yOffset: CGFloat, heightRelation: NSLayoutRelation = .equal) {
fileprivate func createConstraints(_ view: UIView, container: UIView, width: CGFloat? = nil, height: CGFloat? = nil, yOffset: CGFloat, heightRelation: NSLayoutConstraint.Relation = .equal) {

let constX = NSLayoutConstraint(item: view,
attribute: NSLayoutAttribute.centerX,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.centerX,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: container,
attribute: NSLayoutAttribute.centerX,
attribute: NSLayoutConstraint.Attribute.centerX,
multiplier: 1,
constant: 0)
container.addConstraint(constX)

let constY = NSLayoutConstraint(item: view,
attribute: NSLayoutAttribute.centerY,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.centerY,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: container,
attribute: NSLayoutAttribute.centerY,
attribute: NSLayoutConstraint.Attribute.centerY,
multiplier: 1,
constant: yOffset)
container.addConstraint(constY)

if let width = width {
let constW = NSLayoutConstraint(item: view,
attribute: NSLayoutAttribute.width,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.width,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: nil,
attribute: NSLayoutAttribute.notAnAttribute,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: width)
view.addConstraint(constW)
}

if let height = height {
let constH = NSLayoutConstraint(item: view,
attribute: NSLayoutAttribute.height,
attribute: NSLayoutConstraint.Attribute.height,
relatedBy: heightRelation,
toItem: nil,
attribute: NSLayoutAttribute.notAnAttribute,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: height)
view.addConstraint(constH)
Expand Down Expand Up @@ -411,12 +411,12 @@ open class RAMAnimatedTabBarController: UITabBarController {

if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft{
constranints = NSLayoutConstraint.constraints(withVisualFormat: formatString,
options: NSLayoutFormatOptions.directionLeftToRight,
options: NSLayoutConstraint.FormatOptions.directionLeftToRight,
metrics: nil,
views: (containersDict as [String: AnyObject]))
} else {
constranints = NSLayoutConstraint.constraints(withVisualFormat: formatString,
options: NSLayoutFormatOptions.directionRightToLeft,
options: NSLayoutConstraint.FormatOptions.directionRightToLeft,
metrics: nil,
views: (containersDict as [String: AnyObject]))
}
Expand All @@ -440,10 +440,10 @@ open class RAMAnimatedTabBarController: UITabBarController {
viewContainer.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true

let constH = NSLayoutConstraint(item: viewContainer,
attribute: NSLayoutAttribute.height,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.height,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: nil,
attribute: NSLayoutAttribute.notAnAttribute,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: 49)
viewContainer.addConstraint(constH)
Expand All @@ -464,7 +464,7 @@ open class RAMAnimatedTabBarController: UITabBarController {

if items[currentIndex].isEnabled == false { return }

let controller = childViewControllers[currentIndex]
let controller = children[currentIndex]

if let shouldSelect = delegate?.tabBarController?(self, shouldSelect: controller)
, !shouldSelect {
Expand Down
24 changes: 12 additions & 12 deletions RAMAnimatedTabBarController/RAMBadge/RAMBadge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ open class RAMBadge: UILabel {
internal func createSizeConstraints(_ size: CGSize) {
let widthConstraint = NSLayoutConstraint(
item: self,
attribute: NSLayoutAttribute.width,
relatedBy: NSLayoutRelation.greaterThanOrEqual,
attribute: NSLayoutConstraint.Attribute.width,
relatedBy: NSLayoutConstraint.Relation.greaterThanOrEqual,
toItem: nil,
attribute: NSLayoutAttribute.notAnAttribute,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: size.width)
addConstraint(widthConstraint)

let heightConstraint = NSLayoutConstraint(
item: self,
attribute: NSLayoutAttribute.height,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.height,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: nil,
attribute: NSLayoutAttribute.notAnAttribute,
attribute: NSLayoutConstraint.Attribute.notAnAttribute,
multiplier: 1,
constant: size.height)
addConstraint(heightConstraint)
Expand All @@ -93,20 +93,20 @@ open class RAMBadge: UILabel {

// create constraints
let top = NSLayoutConstraint(item: self,
attribute: NSLayoutAttribute.top,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.top,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: onView,
attribute: NSLayoutAttribute.top,
attribute: NSLayoutConstraint.Attribute.top,
multiplier: 1,
constant: 3)
onView.addConstraint(top)
topConstraint = top

let centerX = NSLayoutConstraint(item: self,
attribute: NSLayoutAttribute.centerX,
relatedBy: NSLayoutRelation.equal,
attribute: NSLayoutConstraint.Attribute.centerX,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: onView,
attribute: NSLayoutAttribute.centerX,
attribute: NSLayoutConstraint.Attribute.centerX,
multiplier: 1,
constant: 10)
onView.addConstraint(centerX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,18 @@
TargetAttributes = {
5A1F33B82126AA3D004B8735 = {
CreatedOnToolsVersion = 9.4;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
TestTargetID = CE4146711A1B923D0037F03C;
};
84D4B79C1DB0D35500EE38C6 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0910;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
CE4146711A1B923D0037F03C = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -510,7 +511,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.AnimatedTabBarTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Animated Tab Bar.app/Animated Tab Bar";
};
Expand All @@ -535,7 +536,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.AnimatedTabBarTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Animated Tab Bar.app/Animated Tab Bar";
};
Expand Down Expand Up @@ -564,8 +565,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -594,8 +594,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.RAMAnimatedTabBarController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -721,7 +720,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "Animated Tab Bar";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -740,7 +739,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "Animated Tab Bar";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
}

0 comments on commit 976aef7

Please sign in to comment.