Skip to content

Commit

Permalink
converted 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 27d2bc7 commit 3335c26
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion FoldingCell/FoldingCell-Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
return true
}
}
2 changes: 1 addition & 1 deletion FoldingCell/FoldingCell-Demo/MainTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MainTableViewController: UITableViewController {
private func setup() {
cellHeights = Array(repeating: Const.closeCellHeight, count: Const.rowsCount)
tableView.estimatedRowHeight = Const.closeCellHeight
tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension
tableView.backgroundColor = UIColor(patternImage: #imageLiteral(resourceName: "background"))
if #available(iOS 10.0, *) {
tableView.refreshControl = UIRefreshControl()
Expand Down
19 changes: 9 additions & 10 deletions FoldingCell/FoldingCell.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,19 @@
TargetAttributes = {
5A0E1C2C21414940006A0374 = {
CreatedOnToolsVersion = 9.4;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
TestTargetID = 9D57F31B1EDC7A6F0004599F;
};
8499D8841D0054A8004B5B37 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = LEAZS7L33U;
LastSwiftMigration = 0830;
LastSwiftMigration = 1000;
};
9D57F31B1EDC7A6F0004599F = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 34MUF9YXTA;
LastSwiftMigration = 0920;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
9DAA51531EDDBAD700DFC539 = {
Expand Down Expand Up @@ -508,7 +509,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests;
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)/FoldingCell-Demo.app/FoldingCell-Demo";
};
Expand All @@ -531,7 +532,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoldingCell-Demo.app/FoldingCell-Demo";
};
Expand Down Expand Up @@ -660,7 +661,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -687,7 +688,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCell;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -712,8 +713,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -734,8 +734,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "ramotion.com.FoldingCell-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
24 changes: 17 additions & 7 deletions FoldingCell/FoldingCell/FoldingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ open class FoldingCell: UITableViewCell {
foregroundView.layer.transform = foregroundView.transform3d()

createAnimationView()
contentView.bringSubview(toFront: foregroundView)
contentView.bringSubviewToFront(foregroundView)
}

func createAnimationItemView() -> [RotatedView] {
Expand Down Expand Up @@ -309,7 +309,7 @@ open class FoldingCell: UITableViewCell {
let durations = durationSequence(.open)

var delay: TimeInterval = 0
var timing = kCAMediaTimingFunctionEaseIn
var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
var from: CGFloat = 0.0
var to: CGFloat = -CGFloat.pi / 2
var hidden = true
Expand All @@ -326,7 +326,7 @@ open class FoldingCell: UITableViewCell {

from = from == 0.0 ? CGFloat.pi / 2 : 0.0
to = to == 0.0 ? -CGFloat.pi / 2 : 0.0
timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn
timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
hidden = !hidden
delay += durations[index]
}
Expand Down Expand Up @@ -360,7 +360,7 @@ open class FoldingCell: UITableViewCell {
var durations: [TimeInterval] = durationSequence(.close).reversed()

var delay: TimeInterval = 0
var timing = kCAMediaTimingFunctionEaseIn
var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
var from: CGFloat = 0.0
var to: CGFloat = CGFloat.pi / 2
var hidden = true
Expand All @@ -376,7 +376,7 @@ open class FoldingCell: UITableViewCell {

to = to == 0.0 ? CGFloat.pi / 2 : 0.0
from = from == 0.0 ? -CGFloat.pi / 2 : 0.0
timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn
timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
hidden = !hidden
delay += durations[index]
}
Expand Down Expand Up @@ -454,12 +454,12 @@ extension RotatedView: CAAnimationDelegate {
func foldingAnimation(_ timing: String, from: CGFloat, to: CGFloat, duration: TimeInterval, delay: TimeInterval, hidden: Bool) {

let rotateAnimation = CABasicAnimation(keyPath: Const.transformRotationX)
rotateAnimation.timingFunction = CAMediaTimingFunction(name: timing)
rotateAnimation.timingFunction = CAMediaTimingFunction(name: convertToCAMediaTimingFunctionName(timing))
rotateAnimation.fromValue = from
rotateAnimation.toValue = to
rotateAnimation.duration = duration
rotateAnimation.delegate = self
rotateAnimation.fillMode = kCAFillModeForwards
rotateAnimation.fillMode = CAMediaTimingFillMode.forwards
rotateAnimation.isRemovedOnCompletion = false
rotateAnimation.beginTime = CACurrentMediaTime() + delay

Expand Down Expand Up @@ -499,3 +499,13 @@ private extension UIView {
return image
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromCAMediaTimingFunctionName(_ input: CAMediaTimingFunctionName) -> String {
return input.rawValue
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToCAMediaTimingFunctionName(_ input: String) -> CAMediaTimingFunctionName {
return CAMediaTimingFunctionName(rawValue: input)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FoldingCellDemoTests: XCTestCase {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MainTableViewController") as! MainTableViewController
_ = vc.view
foldingCell = vc.tableView.dequeueReusableCell(withIdentifier: "FoldingCell", for: IndexPath(row: 0, section: 0)) as! FoldingCell
foldingCell = vc.tableView.dequeueReusableCell(withIdentifier: "FoldingCell", for: IndexPath(row: 0, section: 0)) as? FoldingCell
}

override func tearDown() {
Expand Down

0 comments on commit 3335c26

Please sign in to comment.