| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // SubTaskView.swift
- // Todos
- //
- // Created by Sam Jaffe on 2/28/26.
- //
- import SwiftUI
- struct SubTaskView: View {
- @Binding var task: SubTask
- @State private var hideNotes: Bool = false
- @FocusState private var isFocused: Bool
- var body: some View {
- VStack {
- HStack {
- Label("", systemImage: "chevron.right")
- .padding(.trailing, -10)
- Image(systemName: task.status.label)
- .frame(width: 20)
- .padding(.trailing, -10)
- Picker("", selection: $task.status) {
- ForEach(Status.allCases) { unit in
- Text(String(describing: unit))
- }
- }
- .fixedSize(horizontal: true, vertical: false)
- TextField("Task Name", text: $task.name)
- .focused($isFocused)
- }
- if isFocused || !(hideNotes || task.notes.isEmpty) {
- HStack {
- TextField("Notes", text: $task.notes)
- .font(.footnote)
- .padding(.leading, 30)
- VisibilityTapper(hideToggle: $hideNotes)
- }.focused($isFocused)
- }
- }
- }
- }
- #Preview {
- @Previewable @State var task = SubTask(name: "New Task")
- SubTaskView(task: $task)
- .frame(minHeight: 100) // Preview does not resize window properly
- }
|