SubTaskView.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 hideNotes: Bool = false
  11. @FocusState private var isFocused: Bool
  12. var body: some View {
  13. VStack {
  14. HStack {
  15. Label("", systemImage: "chevron.right")
  16. .padding(.trailing, -10)
  17. Image(systemName: task.status.label)
  18. .frame(width: 20)
  19. .padding(.trailing, -10)
  20. Picker("", selection: $task.status) {
  21. ForEach(Status.allCases) { unit in
  22. Text(unit.description).tag(unit)
  23. }
  24. }
  25. .fixedSize(horizontal: true, vertical: false)
  26. TextField("Task Name", text: $task.name)
  27. .focused($isFocused)
  28. }
  29. if isFocused || !(hideNotes || task.notes.isEmpty) {
  30. HStack {
  31. TextField("Notes", text: $task.notes)
  32. .font(.footnote)
  33. .padding(.leading, 30)
  34. VisibilityTapper(hideToggle: $hideNotes)
  35. }.focused($isFocused)
  36. }
  37. }
  38. }
  39. }
  40. #Preview {
  41. @Previewable @State var task = SubTask(name: "New Task")
  42. SubTaskView(task: $task)
  43. .frame(minHeight: 100) // Preview does not resize window properly
  44. }