2 // StrengthenListItem.swift
5 // Created by Hori,Masaki on 2017/03/24.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 protocol StrengthenListItem {
13 var type: EquipmentType { get }
14 var cellType: StrengthenListCellType.Type { get }
17 protocol StrengthenListCellType {
19 static var cellIdentifier: NSUserInterfaceItemIdentifier { get }
20 static func estimateCellHeightForItem(item: StrengthenListItem, tableView: NSTableView) -> CGFloat
21 static func makeCellWithItem(item: StrengthenListItem, tableView: NSTableView, owner: AnyObject?) -> NSTableCellView
24 extension StrengthenListCellType {
26 static func makeCellWithItem(item: StrengthenListItem, tableView: NSTableView, owner: AnyObject?) -> NSTableCellView {
28 let v = tableView.makeView(withIdentifier: cellIdentifier, owner: nil)
30 return v as! NSTableCellView // swiftlint:disable:this force_cast
34 struct StrengthenListGroupCellType: StrengthenListCellType {
36 static let cellIdentifier: NSUserInterfaceItemIdentifier = NSUserInterfaceItemIdentifier("GroupCell")
38 static func estimateCellHeightForItem(item: StrengthenListItem, tableView: NSTableView) -> CGFloat {
44 final class StrengthenListGroupItem: NSObject, StrengthenListItem {
46 @objc let name: String
47 let type: EquipmentType
48 let cellType: StrengthenListCellType.Type = StrengthenListGroupCellType.self
50 init(type: EquipmentType) {
52 self.name = SlotItemEquipTypeTransformer().transformedValue(type.rawValue) as? String ?? "Unkown"
59 final class StrengthenListEnhancementItem: NSObject, StrengthenListItem {
61 let item: EnhancementListItem
62 var type: EquipmentType { return item.equipmentType }
63 let cellType: StrengthenListCellType.Type = StrengthenListItemCellView.self
65 init(item: EnhancementListItem) {
73 extension StrengthenListEnhancementItem {
75 var identifier: String { return item.identifier }
76 var weekday: Int { return item.weekday }
77 var equipmentType: EquipmentType { return item.equipmentType }
78 var targetEquipment: String { return item.targetEquipment }
79 var remodelEquipment: String? { return item.remodelEquipment }
80 var requiredEquipments: RequiredEquipmentSet { return item.requiredEquipments }
81 var secondsShipNames: [String] { return item.secondsShipNames }