|
|
@@ -14,7 +14,10 @@ struct ProjectPanelView: View {
|
|
|
|
|
|
@Bindable var item: Project
|
|
|
@State private var empty = Category()
|
|
|
+
|
|
|
+ @State private var showDialogue = false
|
|
|
@State private var move = false
|
|
|
+ @State private var statuses = StatusList()
|
|
|
|
|
|
var body: some View {
|
|
|
HStack {
|
|
|
@@ -27,8 +30,24 @@ struct ProjectPanelView: View {
|
|
|
}
|
|
|
.help("New Task")
|
|
|
.padding(.trailing, 10)
|
|
|
- Toggle("Move Tasks", isOn: $move)
|
|
|
- .padding(.trailing, 10)
|
|
|
+ Button {
|
|
|
+ showDialogue = !showDialogue
|
|
|
+ } label: {
|
|
|
+ Label("", systemImage: "ellipsis.circle")
|
|
|
+ .foregroundStyle(.gray)
|
|
|
+ .font(.title)
|
|
|
+ }
|
|
|
+ .buttonStyle(.borderless)
|
|
|
+ .popover(isPresented: $showDialogue) {
|
|
|
+ List{
|
|
|
+ HStack {
|
|
|
+ Label("", systemImage: "arrow.up.arrow.down")
|
|
|
+ Toggle("Move Tasks", isOn: $move)
|
|
|
+ }
|
|
|
+ StatusChecklist(statuses: $statuses)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Text("")
|
|
|
}
|
|
|
HStack(alignment: .top) {
|
|
|
TextField("Project Notes", text: $item.notes, axis: .vertical)
|
|
|
@@ -44,7 +63,7 @@ struct ProjectPanelView: View {
|
|
|
}.help("Default category for new Tasks")
|
|
|
}
|
|
|
List {
|
|
|
- ForEach($item.tasks.sorted(by: Task.less), id: \.id) { task in
|
|
|
+ ForEach(selected($item.tasks), id: \.id) { task in
|
|
|
TaskView(task: task)
|
|
|
.swipeActions {
|
|
|
Button("Delete", systemImage: "trash", role: .destructive) {
|
|
|
@@ -52,7 +71,7 @@ struct ProjectPanelView: View {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ForEach(task.subtasks.sorted(by: SubTask.less), id: \.id) { subtask in
|
|
|
+ ForEach(selected(task.subtasks), id: \.id) { subtask in
|
|
|
SubTaskView(task: subtask)
|
|
|
.swipeActions {
|
|
|
Button("Delete", systemImage: "trash", role: .destructive) {
|
|
|
@@ -67,6 +86,12 @@ struct ProjectPanelView: View {
|
|
|
.moveDisabled(!move)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private func selected<T : Ordered & Filterable>(_ items: Binding<[T]>) -> [Binding<T>] {
|
|
|
+ return items.sorted(by: T.less).filter({
|
|
|
+ statuses.test($0.wrappedValue.status)
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
private func addItem() {
|
|
|
withAnimation {
|