TaskView.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 private var showTags: Bool = false
  11. @State private var showNotes: Bool = false
  12. var body: some View {
  13. VStack {
  14. HStack {
  15. Picker("" /* TODO: Add Icons */, selection: $task.status) {
  16. ForEach(Status.allCases) { unit in
  17. Text(String(describing: unit))
  18. }
  19. }.scaledToFit()
  20. TextField("Task Name", text: $task.name)
  21. }
  22. if showTags {
  23. TagBarView(tags: $task.tags)
  24. .font(.footnote)
  25. .padding(.leading, 30)
  26. }
  27. if showNotes {
  28. TextField("Notes", text: $task.notes)
  29. .font(.footnote)
  30. .padding(.leading, 30)
  31. }
  32. }.onHover { yes in
  33. showTags = yes || !task.tags.isEmpty
  34. showNotes = yes || !task.notes.isEmpty
  35. }
  36. }
  37. }
  38. #Preview {
  39. @Previewable @State var task = Task(name: "New Task")
  40. TaskView(task: $task)
  41. .frame(minHeight: 100) // Preview does not resize window properly
  42. }