SubTaskView.swift 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. StatusPicker(status: $task.status)
  18. TextField("Task Name", text: $task.name)
  19. .focused($isFocused)
  20. }
  21. if isFocused || !(hideNotes || task.notes.isEmpty) {
  22. HStack {
  23. TextField("Notes", text: $task.notes)
  24. .font(.footnote)
  25. .padding(.leading, 30)
  26. VisibilityTapper(hideToggle: $hideNotes)
  27. }.focused($isFocused)
  28. }
  29. }
  30. }
  31. }
  32. #Preview {
  33. @Previewable @State var task = SubTask(name: "New Task")
  34. SubTaskView(task: $task)
  35. .frame(minHeight: 100) // Preview does not resize window properly
  36. }