// // CategorySidebarView.swift // Todos // // Created by Sam Jaffe on 2/28/26. // import SwiftUI import SwiftData struct CategoryPanelView: View { @Bindable var item: Category var body: some View { let style = Date.FormatStyle(date: .numeric, time: .standard) HStack { Text(item.name) .font(.title) .padding(.leading, 10) Spacer() Button(action: addItem) { Image(systemName: "plus") } .help("New Task") .padding(.trailing, 10) } Text("Created on \(item.timestamp, format: style)") List { ForEach($item.tasks) { task in TaskView(task: task) } } } private func addItem() { withAnimation { let newTask = Task(name: "New Task") item.tasks.append(newTask) } } } #Preview { @Previewable @State var item = Category(timestamp: Date()) CategoryPanelView(item: item) }