Skip to content

Commit 3fb0947

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 8f97ff4 + 4f27e8b commit 3fb0947

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+775
-757
lines changed

Examples/SampleApp/SampleApp/ActionBar/ActionBarManager.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ import Foundation
22
import TableViewKit
33

44
class ActionBarManager: ActionBarDelegate {
5-
5+
66
let manager: TableViewManager
7-
7+
88
init(manager: TableViewManager) {
99
self.manager = manager
1010
}
11-
11+
1212
public func actionBar(_ actionBar: ActionBar, direction: Direction) {
1313
guard let indexPath = indexPathForResponder(forDirection: direction) else { return }
14-
14+
1515
manager.tableView.scrollToRow(at: indexPath, at: .top, animated: true)
1616
manager.tableView.cellForRow(at: indexPath)?.becomeFirstResponder()
1717
}
18-
18+
1919
public func actionBar(_ actionBar: ActionBar, doneButtonPressed doneButtonItem: UIBarButtonItem) { }
20-
20+
2121
fileprivate func indexPathForResponder(forDirection direction: Direction) -> IndexPath? {
22-
22+
2323
func isFirstResponder(item: Item) -> Bool {
2424
if isResponder(item: item),
2525
let indexPath = item.indexPath(in: manager),
@@ -28,26 +28,26 @@ class ActionBarManager: ActionBarDelegate {
2828
}
2929
return false
3030
}
31-
31+
3232
func isResponder(item: Item) -> Bool {
3333
return (item as? UIResponder)?.canBecomeFirstResponder ?? false
3434
}
35-
35+
3636
let array = manager.sections.flatMap { $0.items }
3737
guard let currentItem = array.first(where: isFirstResponder),
3838
let index = array.index(of: currentItem)
3939
else { return nil }
40-
40+
4141
let item: Item?
42-
42+
4343
switch direction {
4444
case .next:
4545
item = array.suffix(from: index).dropFirst().first(where: isResponder)
4646
case .previous:
4747
item = array.prefix(upTo: index).reversed().first(where: isResponder)
4848
}
49-
49+
5050
return item?.indexPath(in: manager)
51-
51+
5252
}
5353
}

Examples/SampleApp/SampleApp/AppDelegate.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
77

88
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: Any]?) -> Bool {
99
// Override point for customization after application launch.
10-
10+
1111
return true
1212
}
1313

@@ -33,6 +33,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3333
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
3434
}
3535

36-
3736
}
38-

Examples/SampleApp/SampleApp/CustomCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import UIKit
22
import TableViewKit
33

44
class CustomCell: TableViewCell {
5-
5+
66
override func awakeFromNib() {
77
super.awakeFromNib()
88
}
9-
}
9+
}

Examples/SampleApp/SampleApp/CustomHeader.swift

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,28 @@ import UIKit
22
import TableViewKit
33

44
public class CustomHeaderFooterView: UITableViewHeaderFooterView {
5-
5+
66
@IBOutlet weak var label: UILabel!
77
}
88

9-
109
public class CustomHeaderDrawer: HeaderFooterDrawer {
11-
10+
1211
public static let nib = UINib(nibName: String(describing: CustomHeaderFooterView.self), bundle: nil)
1312
static public var type = HeaderFooterType.nib(CustomHeaderDrawer.nib, CustomHeaderFooterView.self)
14-
15-
static public func draw(_ view: UITableViewHeaderFooterView, with item: Any) {
16-
let item = item as! CustomHeaderItem
17-
let view = view as! CustomHeaderFooterView
13+
14+
static public func draw(_ view: CustomHeaderFooterView, with item: CustomHeaderItem) {
1815
view.label.text = item.title
1916
}
2017
}
2118

22-
2319
public class CustomHeaderItem: HeaderFooter {
24-
20+
public static var drawer = AnyHeaderFooterDrawer(CustomHeaderDrawer.self)
21+
2522
public var title: String?
2623
public var height: Height? = .dynamic(44.0)
27-
28-
public var drawer: HeaderFooterDrawer.Type = CustomHeaderDrawer.self
29-
24+
3025
public init() { }
31-
26+
3227
public convenience init(title: String) {
3328
self.init()
3429
self.title = title

Examples/SampleApp/SampleApp/CustomItem.swift

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,35 @@ import UIKit
33
import TableViewKit
44

55
public class CustomDrawer: CellDrawer {
6-
7-
static public var type = CellType.class(UITableViewCell.self)
8-
9-
static public func draw(_ cell: UITableViewCell, with item: Any) {
10-
let item = item as! CustomItem
6+
7+
public static var type = CellType.class(UITableViewCell.self)
8+
9+
public static func draw(_ cell: UITableViewCell, with item: CustomItem) {
1110
cell.accessoryType = item.accessoryType
1211
cell.accessoryView = item.accessoryView
1312
cell.textLabel?.text = item.title
1413
}
1514
}
1615

17-
1816
public class CustomItem: Selectable, Item {
19-
17+
public static var drawer = AnyCellDrawer(CustomDrawer.self)
18+
2019
public var title: String?
21-
22-
public var onSelection: (Selectable) -> () = { _ in }
23-
20+
21+
public var onSelection: (Selectable) -> Void = { _ in }
22+
2423
public var cellStyle: UITableViewCellStyle = .default
2524
public var accessoryType: UITableViewCellAccessoryType = .none
2625
public var accessoryView: UIView?
2726
public var cellHeight: CGFloat? = UITableViewAutomaticDimension
28-
29-
public var drawer: CellDrawer.Type = CustomDrawer.self
30-
27+
3128
public init() { }
32-
29+
3330
public convenience init(title: String) {
3431
self.init()
3532
self.title = title
3633
}
37-
34+
3835
public func didSelect() {
3936
onSelection(self)
4037
}

0 commit comments

Comments
 (0)