Created
January 21, 2020 02:18
-
-
Save learner2011/660d99f1784014323eebb7e739c952c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SectionView: View { | |
@Binding var prioritizedTasks: TaskStore.PriotizedTasks | |
var body: some View { | |
ForEach(prioritizedTasks.tasks) { index in | |
RowView(task: self.$prioritizedTasks.tasks[index]) | |
} | |
.onMove { sourceIndices, destinationIndex in | |
self.prioritizedTasks.tasks.move( | |
fromOffsets: sourceIndices, | |
toOffset: destinationIndex | |
) | |
} | |
.onDelete { indexSet in | |
self.prioritizedTasks.tasks.remove(atOffsets: indexSet) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TaskStore.PrioritizedTasks.swift | |
// TaskList | |
// | |
// Created by Ashwin Raghuraman on 1/15/20. | |
// Copyright © 2020 Ashwin Raghuraman. All rights reserved. | |
// | |
extension TaskStore { | |
struct PriotizedTasks { | |
let priority: Task.Priority | |
let tasks: [Task] | |
} | |
} | |
extension TaskStore.PriotizedTasks: Identifiable { | |
var id: Task.Priority { priority } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment