|
@@ -10,13 +10,11 @@ import SwiftData
|
|
|
|
|
|
|
|
struct TaskView: View {
|
|
struct TaskView: View {
|
|
|
@Environment(\.modelContext) private var modelContext
|
|
@Environment(\.modelContext) private var modelContext
|
|
|
- @AppStorage(UserDefaultsKeys.Category) var allGroups = CodableArray<Category>()
|
|
|
|
|
@Binding var task: Task
|
|
@Binding var task: Task
|
|
|
|
|
|
|
|
@State private var showDialogue: Bool = false
|
|
@State private var showDialogue: Bool = false
|
|
|
@State private var hideTags: Bool = false
|
|
@State private var hideTags: Bool = false
|
|
|
@State private var hideNotes: Bool = false
|
|
@State private var hideNotes: Bool = false
|
|
|
- @State private var empty = Category()
|
|
|
|
|
let unset: Priority? = nil
|
|
let unset: Priority? = nil
|
|
|
|
|
|
|
|
@FocusState private var isFocused: Bool
|
|
@FocusState private var isFocused: Bool
|
|
@@ -44,9 +42,7 @@ struct TaskView: View {
|
|
|
TextField("Task Name", text: $task.name)
|
|
TextField("Task Name", text: $task.name)
|
|
|
.focused($isFocused)
|
|
.focused($isFocused)
|
|
|
|
|
|
|
|
- if let grp = $allGroups.first(where: { $0.name.wrappedValue == task.category }) {
|
|
|
|
|
- ColorPicker("", selection: grp.color).disabled(true).scaledToFit()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CategoryColorDisplay(category: $task.category)
|
|
|
|
|
|
|
|
Button(action: addItem) {
|
|
Button(action: addItem) {
|
|
|
Image(systemName: "plus")
|
|
Image(systemName: "plus")
|
|
@@ -62,13 +58,8 @@ struct TaskView: View {
|
|
|
.buttonStyle(.borderless)
|
|
.buttonStyle(.borderless)
|
|
|
.popover(isPresented: $showDialogue) {
|
|
.popover(isPresented: $showDialogue) {
|
|
|
List {
|
|
List {
|
|
|
- Picker("Category", selection: $task.category) {
|
|
|
|
|
- Text(empty.name).tag("")
|
|
|
|
|
- ForEach(allGroups) { group in
|
|
|
|
|
- Text(group.name)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- .fixedSize(horizontal: true, vertical: false)
|
|
|
|
|
|
|
+ CategoryPicker(category: $task.category)
|
|
|
|
|
+ .fixedSize(horizontal: true, vertical: false)
|
|
|
|
|
|
|
|
Picker("Priority", selection: $task.priority) {
|
|
Picker("Priority", selection: $task.priority) {
|
|
|
Text("").tag(unset)
|
|
Text("").tag(unset)
|