|
|
@@ -10,31 +10,28 @@ import SwiftData
|
|
|
|
|
|
struct ProjectPanelView: View {
|
|
|
@Environment(\.modelContext) private var modelContext
|
|
|
- @AppStorage(UserDefaultsKeys.Category) var allGroups = CodableArray<Category>()
|
|
|
|
|
|
@Bindable var item: Project
|
|
|
- @State private var empty = Category()
|
|
|
|
|
|
@State private var showDialogue = false
|
|
|
- @State private var move = false
|
|
|
+ @State private var moveGuestureEnabled = false
|
|
|
+
|
|
|
@State private var taskFilter = ""
|
|
|
- @State private var statuses = StatusList()
|
|
|
+ @State private var statusFilter = StatusList()
|
|
|
|
|
|
var body: some View {
|
|
|
HStack {
|
|
|
TextField("Project Name", text: $item.name)
|
|
|
.font(.title)
|
|
|
.padding(.leading, 10)
|
|
|
- if let grp = $allGroups.first(where: { $0.name.wrappedValue == item.category }) {
|
|
|
- ColorPicker("", selection: grp.color).disabled(true).scaledToFit()
|
|
|
- }
|
|
|
+ CategoryColorDisplay(category: $item.category)
|
|
|
Spacer()
|
|
|
Button(action: addItem) {
|
|
|
Image(systemName: "plus")
|
|
|
}
|
|
|
.help("New Task")
|
|
|
.padding(.trailing, 10)
|
|
|
- if move {
|
|
|
+ if moveGuestureEnabled {
|
|
|
Label("", systemImage: "arrow.up.arrow.down")
|
|
|
.foregroundStyle(.red)
|
|
|
.font(.title2)
|
|
|
@@ -46,11 +43,11 @@ struct ProjectPanelView: View {
|
|
|
.font(.title2)
|
|
|
.help("Only showing text matching '\(taskFilter)'")
|
|
|
}
|
|
|
- if !statuses.all {
|
|
|
+ if !statusFilter.all {
|
|
|
Label("", systemImage: "exclamationmark.magnifyingglass")
|
|
|
.foregroundStyle(.blue)
|
|
|
.font(.title2)
|
|
|
- .help(statuses.description)
|
|
|
+ .help(statusFilter.description)
|
|
|
}
|
|
|
Button {
|
|
|
showDialogue = !showDialogue
|
|
|
@@ -64,23 +61,18 @@ struct ProjectPanelView: View {
|
|
|
List {
|
|
|
Label("Settings", systemImage: "gearshape")
|
|
|
.font(.title)
|
|
|
- Picker("Category", selection: $item.category) {
|
|
|
- Text(empty.name).tag("")
|
|
|
- ForEach(allGroups) { group in
|
|
|
- Text(group.name)
|
|
|
- }
|
|
|
- }
|
|
|
+ CategoryPicker(category: $item.category)
|
|
|
Label("Filters", systemImage: "magnifyingglass")
|
|
|
.font(.title)
|
|
|
HStack {
|
|
|
Label("", systemImage: "arrow.up.arrow.down")
|
|
|
- Toggle("Move Tasks", isOn: $move)
|
|
|
+ Toggle("Move Tasks", isOn: $moveGuestureEnabled)
|
|
|
}
|
|
|
HStack {
|
|
|
Label("", systemImage: "text.magnifyingglass")
|
|
|
TextField("Filter Tasks", text: $taskFilter)
|
|
|
}
|
|
|
- StatusChecklist(statuses: $statuses)
|
|
|
+ StatusChecklist(statuses: $statusFilter)
|
|
|
}
|
|
|
}
|
|
|
Text("")
|
|
|
@@ -105,10 +97,10 @@ struct ProjectPanelView: View {
|
|
|
}
|
|
|
}
|
|
|
.onMove(perform: { moveItem(task.wrappedValue, $0, $1) })
|
|
|
- .moveDisabled(!move)
|
|
|
+ .moveDisabled(!moveGuestureEnabled)
|
|
|
}
|
|
|
.onMove(perform: { moveItem(item, $0, $1) })
|
|
|
- .moveDisabled(!move)
|
|
|
+ .moveDisabled(!moveGuestureEnabled)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -116,7 +108,7 @@ struct ProjectPanelView: View {
|
|
|
return items.sorted(by: T.less).filter({
|
|
|
let value = $0.wrappedValue
|
|
|
return value.name.isEmpty ||
|
|
|
- (statuses.test(value.status) &&
|
|
|
+ (statusFilter.test(value.status) &&
|
|
|
(taskFilter.isEmpty || value.containsText(taskFilter)))
|
|
|
})
|
|
|
}
|