TaskView.swift 793 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // TaskView.swift
  3. // Todos
  4. //
  5. // Created by Sam Jaffe on 2/28/26.
  6. //
  7. import SwiftUI
  8. struct TaskView: View {
  9. @Binding var task: Task
  10. @State var showNotes: Bool = false
  11. var body: some View {
  12. VStack {
  13. HStack {
  14. Picker("" /* TODO: Add Icons */, selection: $task.status) {
  15. ForEach(Status.allCases) { unit in
  16. Text(String(describing: unit))
  17. }
  18. }.scaledToFit()
  19. TextField("Task Name", text: $task.name)
  20. }
  21. if showNotes {
  22. TextField("Notes", text: $task.notes)
  23. .font(.footnote)
  24. .padding(.leading, 30)
  25. }
  26. }.onHover { yes in
  27. showNotes = yes || !task.notes.isEmpty
  28. }
  29. }
  30. }
  31. #Preview {
  32. @Previewable @State var task = Task(name: "New Task")
  33. TaskView(task: $task)
  34. }