SubTaskView.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // SubTaskView.swift
  3. // Todos
  4. //
  5. // Created by Sam Jaffe on 2/28/26.
  6. //
  7. import SwiftUI
  8. struct SubTaskView: View {
  9. @Binding var task: SubTask
  10. @State private var showNotes: Bool = false
  11. @State private var hideNotes: 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. }
  20. TextField("Task Name", text: $task.name)
  21. }
  22. if showNotes {
  23. HStack {
  24. TextField("Notes", text: $task.notes)
  25. .font(.footnote)
  26. .padding(.leading, 30)
  27. ShowHideTapper(shown: $showNotes, hideToggle: $hideNotes)
  28. }
  29. }
  30. }.onHover { yes in
  31. showNotes = yes || !(hideNotes || task.notes.isEmpty)
  32. }
  33. }
  34. }
  35. #Preview {
  36. @Previewable @State var task = SubTask(name: "New Task")
  37. SubTaskView(task: $task)
  38. .frame(minHeight: 100) // Preview does not resize window properly
  39. }