Slide 37
Slide 37 text
3FOEFSFS
class TodoListCollectionRenderer: CollectionRenderer {
typealias State = ToDoListReactor.State
typealias Store = ViewStore
enum ID: Int {
case todo
case empty
}
@SectionBuilder
func createSections(state: State, store: Store) -> [Section] {
if state.todoList.isEmpty {
empty()
} else {
todo(state: state, store: store)
}
}
func createLayoutSection(id: ID, env: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection {
switch id {
case .list:
return .list(itemWidth: .fractionalWidth(1.0), itemHeight: .estimated(.s222))
case .empty:
return .list(itemWidth: .fractionalWidth(1.0), itemHeight: .fractionalHeight(1.0))
}
}
}
func todo(state: State, store: Store) -> Section {
Section(
id: ID.todo,
data: state.todoList,
dataID: \.self
) { todo in
TodoItemView(
Title: todo.content,
done: todo.done
)
.onTapGesture {
store.send(.showDetail(todo))
}
}
}