Skip to content

Commit

Permalink
Merge pull request #110 from Shopify/swift42
Browse files Browse the repository at this point in the history
Migrate to Swift 4.2
  • Loading branch information
krbarnes authored Sep 18, 2018
2 parents f19de34 + 495704d commit fe4bfea
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode9.3
osx_image: xcode10
xcode_project: FunctionalTableData.xcodeproj
xcode_schema: FunctionalTableDataTests
notifications:
Expand Down
17 changes: 9 additions & 8 deletions FunctionalTableData.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,17 @@
TargetAttributes = {
17E57FE5208A404700BFCC3D = {
CreatedOnToolsVersion = 9.3;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
4C7A26FB1F2FA0F800360E9B = {
CreatedOnToolsVersion = 8.3.3;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
4C7A27041F2FA0F800360E9B = {
CreatedOnToolsVersion = 8.3.3;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -534,7 +535,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.jadedpixel.FunctionalTableDataDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -555,7 +556,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.jadedpixel.FunctionalTableDataDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -751,7 +752,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -774,7 +775,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -787,7 +788,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.FunctionalTableDataTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -800,7 +801,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.FunctionalTableDataTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions FunctionalTableData/CellStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct CellStyle {
/// You use these constants when setting the value of the [accessoryType](apple-reference-documentation://hspQPOCGHb) property.
///
/// Supported by `UITableView` only.
public var accessoryType: UITableViewCellAccessoryType = .none
public var accessoryType: UITableViewCell.AccessoryType = .none
/// The view's selection color.
public var selectionColor: UIColor? = CellStyle.selectionColor
/// The view's background color.
Expand All @@ -52,7 +52,7 @@ public struct CellStyle {
bottomSeparator: Separator.Style? = nil,
separatorColor: UIColor? = nil,
highlight: Bool? = nil,
accessoryType: UITableViewCellAccessoryType = .none,
accessoryType: UITableViewCell.AccessoryType = .none,
selectionColor: UIColor? = CellStyle.selectionColor,
backgroundColor: UIColor? = nil,
backgroundView: UIView? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public class FunctionalCollectionData: NSObject {
/// - animated: `true` if you want to animate the selection, and `false` if the change should be immediate.
/// - scrollPosition: An option that specifies where the item should be positioned when scrolling finishes.
/// - triggerDelegate: `true` to trigger the `collection:didSelectItemAt:` delegate from `UICollectionView` or `false` to skip it. Skipping it is the default `UICollectionView` behavior.
public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionViewScrollPosition = [], triggerDelegate: Bool = false) {
public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionView.ScrollPosition = [], triggerDelegate: Bool = false) {
guard let aCollectionView = collectionView, let indexPath = indexPathFromKeyPath(keyPath) else { return }

aCollectionView.selectItem(at: indexPath, animated: animated, scrollPosition: scrollPosition)
Expand All @@ -363,7 +363,7 @@ public class FunctionalCollectionData: NSObject {
/// - keyPath: A key path identifying a row in the collection view.
/// - animated: `true` to animate to the new scroll position, or `false` to scroll immediately.
/// - scrollPosition: Specifies where the item specified by `keyPath` should be positioned once scrolling finishes.
public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionViewScrollPosition = [.bottom, .right]) {
public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionView.ScrollPosition = [.bottom, .right]) {
guard let aCollectionView = collectionView, let indexPath = indexPathFromKeyPath(keyPath) else { return }
aCollectionView.scrollToItem(at: indexPath, at: scrollPosition, animated: animated)
}
Expand Down
2 changes: 1 addition & 1 deletion FunctionalTableData/Separator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class Separator: UIView {
}

public override var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: thickness)
return CGSize(width: UIView.noIntrinsicMetric, height: thickness)
}

public func constrainToTopOfView(_ view: UIView, constant: CGFloat = 0) {
Expand Down
20 changes: 10 additions & 10 deletions FunctionalTableData/TableView/FunctionalTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class FunctionalTableData: NSObject {
guard let tableView = tableView else { return }
tableView.dataSource = self
tableView.delegate = self
tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension
tableView.tableFooterView = UIView(frame: .zero)
tableView.separatorStyle = .none
}
Expand Down Expand Up @@ -113,13 +113,13 @@ public class FunctionalTableData: NSObject {
/// The type of animation when rows and sections are inserted or deleted.
public struct TableAnimations {
public struct Actions {
let insert: UITableViewRowAnimation
let delete: UITableViewRowAnimation
let reload: UITableViewRowAnimation
let insert: UITableView.RowAnimation
let delete: UITableView.RowAnimation
let reload: UITableView.RowAnimation
public static let `default` = Actions(insert: .fade, delete: .fade, reload: .automatic)
public static let legacy = Actions(insert: .top, delete: .top, reload: .automatic)

public init(insert: UITableViewRowAnimation, delete: UITableViewRowAnimation, reload: UITableViewRowAnimation) {
public init(insert: UITableView.RowAnimation, delete: UITableView.RowAnimation, reload: UITableView.RowAnimation) {
self.insert = insert
self.delete = delete
self.reload = reload
Expand Down Expand Up @@ -425,7 +425,7 @@ public class FunctionalTableData: NSObject {
/// - keyPath: A key path identifying a row in the table view.
/// - animated: `true` if you want to animate the selection, and `false` if the change should be immediate.
/// - triggerDelegate: `true` to trigger the `tableView:didSelectRowAt:` delegate from `UITableView` or `false` to skip it. Skipping it is the default `UITableView` behavior.
public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableViewScrollPosition = .none, triggerDelegate: Bool = false) {
public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableView.ScrollPosition = .none, triggerDelegate: Bool = false) {
guard let aTableView = tableView, let indexPath = indexPathFromKeyPath(keyPath) else { return }
if tableView(aTableView, willSelectRowAt: indexPath) != nil {
aTableView.selectRow(at: indexPath, animated: animated, scrollPosition: scrollPosition)
Expand All @@ -441,7 +441,7 @@ public class FunctionalTableData: NSObject {
/// - keyPath: A key path identifying a row in the table view.
/// - animated: `true` to animate to the new scroll position, or `false` to scroll immediately.
/// - scrollPosition: Specifies where the item specified by `keyPath` should be positioned once scrolling finishes.
public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableViewScrollPosition = .bottom) {
public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableView.ScrollPosition = .bottom) {
guard let aTableView = tableView, let indexPath = indexPathFromKeyPath(keyPath) else { return }
aTableView.scrollToRow(at: indexPath, at: scrollPosition, animated: animated)
}
Expand Down Expand Up @@ -580,11 +580,11 @@ extension FunctionalTableData: UITableViewDelegate {
}

public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
guard indexPath.section < sections.count else { return UITableViewAutomaticDimension }
guard indexPath.section < sections.count else { return UITableView.automaticDimension }
if let indexKeyPath = sections[indexPath.section].sectionKeyPathForRow(indexPath.row), let height = heightAtIndexKeyPath[indexKeyPath] {
return height
} else {
return UITableViewAutomaticDimension
return UITableView.automaticDimension
}
}

Expand Down Expand Up @@ -715,7 +715,7 @@ extension FunctionalTableData: UITableViewDelegate {
// required
}

public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
let cellConfig = sections[indexPath]
return cellConfig?.actions.rowActions != nil ? .delete : .none
}
Expand Down
4 changes: 2 additions & 2 deletions FunctionalTableData/TableView/TableCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
public class TableCell<ViewType: UIView, Layout: TableItemLayout>: UITableViewCell {
public let view: ViewType
public var prepare: ((_ view: ViewType) -> Void)?
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
view = ViewType()
super.init(style: style, reuseIdentifier: reuseIdentifier)

Expand Down Expand Up @@ -50,7 +50,7 @@ public class TableCell<ViewType: UIView, Layout: TableItemLayout>: UITableViewCe
private extension UIAccessibilityElement {
var isEmpty: Bool {
return
accessibilityTraits == UIAccessibilityTraitStaticText &&
accessibilityTraits == UIAccessibilityTraits.staticText &&
(accessibilityLabel == nil || accessibilityLabel!.isEmpty) &&
(accessibilityValue == nil || accessibilityValue!.isEmpty) &&
(accessibilityHint == nil || accessibilityHint!.isEmpty)
Expand Down
2 changes: 1 addition & 1 deletion FunctionalTableDataDemo/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 {
return true
}

Expand Down

0 comments on commit fe4bfea

Please sign in to comment.