You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
63 lines
2.0 KiB
// |
|
// MultipleSectionModel.swift |
|
// Lookfit |
|
// |
|
// Created by lemo on 2018/6/2. |
|
// Copyright © 2020年 ecell. All rights reserved. |
|
// |
|
|
|
import Foundation |
|
|
|
enum MultipleSectionModel { |
|
/// 设置类型的Section |
|
case SettingSection(title: String, items: [SectionItem]) |
|
/// 带开始时间结束时间的Section |
|
case DoubleTimePickerSection(title: String, items: [SectionItem]) |
|
/// 单组选择Section |
|
case SinglePickerSection(title: String, items: [SectionItem]) |
|
} |
|
|
|
enum SectionItem { |
|
case TableViewCellModel(cellModel: TableViewCellModel) |
|
case DoubleTimePicker(leftTitle: String?, rightTitle: String?, selectedItems: [String]?) |
|
case SinglePicker(title: String?, selectedItem: String?) |
|
} |
|
|
|
extension MultipleSectionModel: SectionModelType { |
|
init(original: MultipleSectionModel, items: [SectionItem]) { |
|
switch original { |
|
case let .SettingSection(title: title, items: _): |
|
self = .SettingSection(title: title, items: items) |
|
case let .DoubleTimePickerSection(title: title, items: _): |
|
self = .DoubleTimePickerSection(title: title, items: items) |
|
case let .SinglePickerSection(title: title, items: _): |
|
self = .SinglePickerSection(title: title, items: items) |
|
} |
|
} |
|
|
|
typealias Item = SectionItem |
|
|
|
var items: [SectionItem] { |
|
switch self { |
|
case .SettingSection(title: _, items: let items): |
|
return items.map { $0 } |
|
case .DoubleTimePickerSection(title: _, items: let items): |
|
return items.map { $0 } |
|
case .SinglePickerSection(title: _, items: let items): |
|
return items.map { $0 } |
|
} |
|
} |
|
} |
|
|
|
extension MultipleSectionModel { |
|
var title: String { |
|
switch self { |
|
case .SettingSection(title: let title, items: _): |
|
return title |
|
case .DoubleTimePickerSection(title: let title, items: _): |
|
return title |
|
case .SinglePickerSection(title: let title, items: _): |
|
return title |
|
} |
|
} |
|
}
|
|
|