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 // swiftlint:disable:next force_cast
31 return v as! NSTableCellView
35 struct StrengthenListGroupCellType: StrengthenListCellType {
37 static let cellIdentifier: NSUserInterfaceItemIdentifier = NSUserInterfaceItemIdentifier("GroupCell")
39 static func estimateCellHeightForItem(item: StrengthenListItem, tableView: NSTableView) -> CGFloat {
45 final class StrengthenListGroupItem: NSObject, StrengthenListItem {
47 @objc let name: String
48 let type: EquipmentType
49 let cellType: StrengthenListCellType.Type = StrengthenListGroupCellType.self
51 init(type: EquipmentType) {
53 self.name = SlotItemEquipTypeTransformer().transformedValue(type.rawValue) as? String ?? "Unkown"
60 final class StrengthenListEnhancementItem: NSObject, StrengthenListItem {
62 let item: EnhancementListItem
63 var type: EquipmentType { return item.equipmentType }
64 let cellType: StrengthenListCellType.Type = StrengthenListItemCellView.self
66 init(item: EnhancementListItem) {
74 extension StrengthenListEnhancementItem {
76 var identifier: String { return item.identifier }
77 var weekday: Int { return item.weekday }
78 var equipmentType: EquipmentType { return item.equipmentType }
79 var targetEquipment: String { return item.targetEquipment }
80 var remodelEquipment: String? { return item.remodelEquipment }
81 var requiredEquipments: RequiredEquipmentSet { return item.requiredEquipments }
82 var secondsShipNames: [String] { return item.secondsShipNames }