2 // StrengthenListItem.swift
5 // Created by Hori,Masaki on 2017/03/24.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 protocol StrengthenListItem {
12 var type: EquipmentType { get }
13 var cellType: StrengthenListCellType.Type { get }
16 protocol StrengthenListCellType {
17 static var cellIdentifier: String { get }
18 static func estimateCellHeightForItem(item: StrengthenListItem, tableView: NSTableView) -> CGFloat
19 static func makeCellWithItem(item: StrengthenListItem, tableView: NSTableView, owner: AnyObject?) -> NSTableCellView
22 extension StrengthenListCellType {
23 static func makeCellWithItem(item: StrengthenListItem,
24 tableView: NSTableView,
25 owner: AnyObject?) -> NSTableCellView {
26 let v = tableView.make(withIdentifier: cellIdentifier, owner: nil)
28 // swiftlint:disable:next force_cast
29 return v as! NSTableCellView
33 struct StrengthenListGroupCellType: StrengthenListCellType {
34 static let cellIdentifier: String = "GroupCell"
35 static func estimateCellHeightForItem(item: StrengthenListItem, tableView: NSTableView) -> CGFloat {
40 class StrengthenListGroupItem: NSObject, StrengthenListItem {
42 let type: EquipmentType
43 let cellType: StrengthenListCellType.Type = StrengthenListGroupCellType.self
45 init(type: EquipmentType) {
46 self.name = SlotItemEquipTypeTransformer().transformedValue(type.rawValue) as? String ?? "Unkown"
52 class StrengthenListEnhancementItem: NSObject, StrengthenListItem {
53 let item: EnhancementListItem
54 var type: EquipmentType { return item.equipmentType }
55 let cellType: StrengthenListCellType.Type = StrengthenListItemCellView.self
57 init(item: EnhancementListItem) {
63 extension StrengthenListEnhancementItem {
64 var identifier: String { return item.identifier }
65 var weekday: Int { return item.weekday }
66 var equipmentType: EquipmentType { return item.equipmentType }
67 var targetEquipment: String { return item.targetEquipment }
68 var remodelEquipment: String? { return item.remodelEquipment }
69 var requiredEquipments: RequiredEquipmentSet { return item.requiredEquipments }
70 var secondsShipNames: [String] { return item.secondsShipNames }