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. Image(systemName: task.status.label)
  16. .frame(width: 20)
  17. .padding(.trailing, -10)
  18. Picker("", selection: $task.status) {
  19. ForEach(Status.allCases) { unit in
  20. Text(String(describing: unit))
  21. }
  22. }
  23. .fixedSize(horizontal: true, vertical: false)
  24. TextField("Task Name", text: $task.name)
  25. .focused($isFocused)
  26. }
  27. if isFocused || !(hideNotes || task.notes.isEmpty){
  28. HStack {
  29. TextField("Notes", text: $task.notes)
  30. .font(.footnote)
  31. .focused($isFocused)
  32. .padding(.leading, 30)
  33. VisibilityTapper(hideToggle: $hideNotes)
  34. .focused($isFocused)
  35. }
  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. }