| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // TaskView.swift
- // Todos
- //
- // Created by Sam Jaffe on 2/28/26.
- //
- import SwiftUI
- struct TaskView: View {
- @Binding var task: Task
- @State private var showTags: Bool = false
- @State private var hideTags: Bool = false
- @State private var showNotes: Bool = false
- @State private var hideNotes: Bool = false
- var body: some View {
- VStack {
- HStack {
- Picker("" /* TODO: Add Icons */, selection: $task.status) {
- ForEach(Status.allCases) { unit in
- Text(String(describing: unit))
- }
- }.scaledToFit()
- TextField("Task Name", text: $task.name)
- }
-
- if showTags {
- HStack {
- TagBarView(tags: $task.tags)
- .font(.footnote)
- .padding(.leading, 30)
- ShowHideTapper(shown: $showTags, hideToggle: $hideTags)
- }
- }
-
- if showNotes {
- HStack {
- TextField("Notes", text: $task.notes)
- .font(.footnote)
- .padding(.leading, 30)
- ShowHideTapper(shown: $showNotes, hideToggle: $hideNotes)
- }
- }
- }.onHover { yes in
- showTags = yes || !(hideTags || task.tags.isEmpty)
- showNotes = yes || !(hideNotes || task.notes.isEmpty)
- }
- }
- }
- #Preview {
- @Previewable @State var task = Task(name: "New Task")
- TaskView(task: $task)
- .frame(minHeight: 100) // Preview does not resize window properly
- }
|