Skip to content

Commit

Permalink
Converted to Swift 3 beta 6
Browse files Browse the repository at this point in the history
  • Loading branch information
jernejstrasner committed Aug 20, 2016
1 parent 6d5d2c0 commit c26e3fc
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 142 deletions.
16 changes: 8 additions & 8 deletions Example/CustomTableViewCell.swift
Expand Up @@ -5,10 +5,10 @@ final class CustomTableViewCell: UITableViewCell, CellType {

// MARK: - Properties

private lazy var centeredLabel: UILabel = {
fileprivate lazy var centeredLabel: UILabel = {
let label = UILabel()
label.textAlignment = .Center
label.textColor = .whiteColor()
label.textAlignment = .center
label.textColor = .white
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
Expand All @@ -18,14 +18,14 @@ final class CustomTableViewCell: UITableViewCell, CellType {

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .grayColor()
contentView.backgroundColor = .gray

contentView.addSubview(centeredLabel)

let views = ["centeredLabel": centeredLabel]
var constraints: [NSLayoutConstraint] = NSLayoutConstraint.constraintsWithVisualFormat("|-[centeredLabel]-|", options: [], metrics: nil, views: views)
constraints += NSLayoutConstraint.constraintsWithVisualFormat("V:|-[centeredLabel]-|", options: [], metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(constraints)
var constraints: [NSLayoutConstraint] = NSLayoutConstraint.constraints(withVisualFormat: "|-[centeredLabel]-|", options: [], metrics: nil, views: views)
constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-[centeredLabel]-|", options: [], metrics: nil, views: views)
NSLayoutConstraint.activate(constraints)
}

required init?(coder aDecoder: NSCoder) {
Expand All @@ -35,7 +35,7 @@ final class CustomTableViewCell: UITableViewCell, CellType {

// MARK: - CellType

func configure(row row: Row) {
func configure(row: Row) {
centeredLabel.text = row.text
}
}
6 changes: 3 additions & 3 deletions Example/NibTableViewCell.swift
Expand Up @@ -5,16 +5,16 @@ final class NibTableViewCell: UITableViewCell, CellType {

// MARK: - Properties

@IBOutlet weak private var centeredLabel: UILabel!
@IBOutlet weak fileprivate var centeredLabel: UILabel!


// MARK: - CellType

static func nib() -> UINib? {
return UINib(nibName: String(self), bundle: nil)
return UINib(nibName: String(describing: self), bundle: nil)
}

func configure(row row: Row) {
func configure(row: Row) {
centeredLabel.text = row.text
}
}
32 changes: 16 additions & 16 deletions Example/ViewController.swift
Expand Up @@ -5,17 +5,17 @@ class ViewController: TableViewController {

// MARK: - Properties

private let customAccessory: UIView = {
fileprivate let customAccessory: UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: 32, height: 32))
view.backgroundColor = .redColor()
view.backgroundColor = .red
return view
}()


// MARK: - Initializers

convenience init() {
self.init(style: .Grouped)
self.init(style: .grouped)
}


Expand All @@ -31,22 +31,22 @@ class ViewController: TableViewController {
dataSource.sections = [
Section(header: "Styles", rows: [
Row(text: "Value 1", detailText: "Detail", cellClass: Value1Cell.self),
Row(text: "Value 1", detailText: "with an image", cellClass: Value1Cell.self, image: UIImage(named: "Settings")),
Row(text: "Value 1", detailText: "with an image", image: UIImage(named: "Settings"), cellClass: Value1Cell.self),
Row(text: "Value 2", detailText: "Detail", cellClass: Value2Cell.self),
Row(text: "Subtitle", detailText: "Detail", cellClass: SubtitleCell.self),
Row(text: "Button", detailText: "Detail", cellClass: ButtonCell.self, selection: { [unowned self] in
Row(text: "Button", detailText: "Detail", selection: { [unowned self] in
self.showAlert(title: "Row Selection")
}),
}, cellClass: ButtonCell.self),
Row(text: "Custom from nib", cellClass: NibTableViewCell.self)
], footer: "This is a section footer."),
Section(header: "Accessories", rows: [
Row(text: "None"),
Row(text: "Disclosure Indicator", accessory: .DisclosureIndicator),
Row(text: "Detail Disclosure Button", accessory: .DetailDisclosureButton({ [unowned self] in
Row(text: "Disclosure Indicator", accessory: .disclosureIndicator),
Row(text: "Detail Disclosure Button", accessory: .detailDisclosureButton({ [unowned self] in
self.showAlert(title: "Detail Disclosure Button")
})),
Row(text: "Checkmark", accessory: .Checkmark),
Row(text: "Detail Button", accessory: .DetailButton({ [unowned self] in
Row(text: "Checkmark", accessory: .checkmark),
Row(text: "Detail Button", accessory: .detailButton({ [unowned self] in
self.showAlert(title: "Detail Button")
})),
Row(text: "Custom View", accessory: .View(customAccessory))
Expand All @@ -62,10 +62,10 @@ class ViewController: TableViewController {
]),
Section(header: "Editing", rows: [
Row(text: "Swipe this row", editActions: [
Row.EditAction(title: "Warn", backgroundColor: .orangeColor(), selection: { [unowned self] in
Row.EditAction(title: "Warn", backgroundColor: .orange, selection: { [unowned self] in
self.showAlert(title: "Warned.")
}),
Row.EditAction(title: "Delete", style: .Destructive, selection: { [unowned self] in
Row.EditAction(title: "Delete", style: .destructive, selection: { [unowned self] in
self.showAlert(title: "Deleted.")
})
])
Expand All @@ -76,9 +76,9 @@ class ViewController: TableViewController {

// MARK: - Private

private func showAlert(title title: String? = nil, message: String? = "You tapped it. Good work.", button: String = "Thanks") {
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: button, style: .Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
fileprivate func showAlert(title: String? = nil, message: String? = "You tapped it. Good work.", button: String = "Thanks") {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: button, style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
}
}
4 changes: 2 additions & 2 deletions Example/WindowController.swift
Expand Up @@ -2,15 +2,15 @@ import UIKit

@UIApplicationMain class WindowController: UIResponder {
var window: UIWindow? = {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UINavigationController(rootViewController: ViewController())
return window
}()
}


extension WindowController: UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
window?.makeKeyAndVisible()
return true
}
Expand Down
15 changes: 14 additions & 1 deletion Static.xcodeproj/project.pbxproj
Expand Up @@ -268,17 +268,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = Venmo;
TargetAttributes = {
21826AA91B3F51A100AA9641 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
21826AB31B3F51A100AA9641 = {
CreatedOnToolsVersion = 7.0;
};
36748D4E1B5034EC0046F207 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -407,8 +409,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -455,8 +459,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -476,6 +482,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -488,6 +495,7 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -499,6 +507,7 @@
PRODUCT_NAME = Static;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -507,6 +516,7 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -517,6 +527,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.venmo.static;
PRODUCT_NAME = Static;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -549,6 +560,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.venmo.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -561,6 +573,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.venmo.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Static.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 4 additions & 4 deletions Static/ButtonCell.swift
@@ -1,11 +1,11 @@
import UIKit

public class ButtonCell: UITableViewCell, CellType {
open class ButtonCell: UITableViewCell, CellType {

// MARK: - Initializers

public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .Default, reuseIdentifier: reuseIdentifier)
super.init(style: .default, reuseIdentifier: reuseIdentifier)
initialize()
}

Expand All @@ -17,15 +17,15 @@ public class ButtonCell: UITableViewCell, CellType {

// MARK: - UIView

public override func tintColorDidChange() {
open override func tintColorDidChange() {
super.tintColorDidChange()
textLabel?.textColor = tintColor
}


// MARK: - Private

private func initialize() {
fileprivate func initialize() {
tintColorDidChange()
}
}
4 changes: 2 additions & 2 deletions Static/CellType.swift
Expand Up @@ -4,7 +4,7 @@ public protocol CellType: class {
static func description() -> String
static func nib() -> UINib?

func configure(row row: Row)
func configure(row: Row)
}

extension CellType {
Expand All @@ -14,7 +14,7 @@ extension CellType {
}

extension CellType where Self: UITableViewCell {
public func configure(row row: Row) {
public func configure(row: Row) {
textLabel?.text = row.text
detailTextLabel?.text = row.detailText
imageView?.image = row.image
Expand Down

0 comments on commit c26e3fc

Please sign in to comment.