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

//
// 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
}
}
}