|
|
@@ -60,23 +60,11 @@ struct ProjectPanelView: View {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .onMove(perform: { indices, index in
|
|
|
- withAnimation {
|
|
|
- task.subtasks.wrappedValue.move(fromOffsets: indices, toOffset: index)
|
|
|
- for (index, item) in task.subtasks.wrappedValue.enumerated() {
|
|
|
- item.sortOrder = index
|
|
|
- }
|
|
|
- }
|
|
|
- }).moveDisabled(!move)
|
|
|
+ .onMove(perform: { moveItem(task.wrappedValue, $0, $1) })
|
|
|
+ .moveDisabled(!move)
|
|
|
}
|
|
|
- .onMove(perform: { indices, index in
|
|
|
- withAnimation {
|
|
|
- item.tasks.move(fromOffsets: indices, toOffset: index)
|
|
|
- for (index, item) in item.tasks.enumerated() {
|
|
|
- item.sortOrder = index
|
|
|
- }
|
|
|
- }
|
|
|
- }).moveDisabled(!move)
|
|
|
+ .onMove(perform: { moveItem(item, $0, $1) })
|
|
|
+ .moveDisabled(!move)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -88,6 +76,24 @@ struct ProjectPanelView: View {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private func moveItem(_ within: Project, _ fromOffsets: IndexSet, _ toOffset: Int) {
|
|
|
+ withAnimation {
|
|
|
+ within.tasks.move(fromOffsets: fromOffsets, toOffset: toOffset)
|
|
|
+ for (index, item) in within.tasks.enumerated() {
|
|
|
+ item.sortOrder = index
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private func moveItem(_ within: Task, _ fromOffsets: IndexSet, _ toOffset: Int) {
|
|
|
+ withAnimation {
|
|
|
+ within.subtasks.move(fromOffsets: fromOffsets, toOffset: toOffset)
|
|
|
+ for (index, item) in within.subtasks.enumerated() {
|
|
|
+ item.sortOrder = index
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private func deleteItem(item: Task, from: Project) {
|
|
|
withAnimation {
|
|
|
from.tasks.removeAll(where: { $0.id == item.id })
|