|
@@ -10,10 +10,11 @@ import SwiftData
|
|
|
|
|
|
|
|
struct ContentView: View {
|
|
struct ContentView: View {
|
|
|
@Environment(\.modelContext) private var modelContext
|
|
@Environment(\.modelContext) private var modelContext
|
|
|
|
|
+ @AppStorage(UserDefaultsKeys.WeekStart) private var weekStart = Date()
|
|
|
|
|
|
|
|
@Query(sort: \Project.sortOrder) private var items: [Project]
|
|
@Query(sort: \Project.sortOrder) private var items: [Project]
|
|
|
@State private var selection: Project?
|
|
@State private var selection: Project?
|
|
|
- @Binding var hasAutosave: Bool
|
|
|
|
|
|
|
+ @Binding var rotate: RotateTracking
|
|
|
|
|
|
|
|
var body: some View {
|
|
var body: some View {
|
|
|
NavigationSplitView {
|
|
NavigationSplitView {
|
|
@@ -45,12 +46,29 @@ struct ContentView: View {
|
|
|
ContentUnavailableView(header, systemImage: "doc.text.image.fill")
|
|
ContentUnavailableView(header, systemImage: "doc.text.image.fill")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- .alert("Autosave", isPresented: $hasAutosave) {
|
|
|
|
|
|
|
+ .confirmationDialog("Manually run \"Save and Cleanup\"?",
|
|
|
|
|
+ isPresented: $rotate.manuallyInvoked) {
|
|
|
|
|
+ Button("Yes") {
|
|
|
|
|
+ RotateController().saveAndRotate(items, &weekStart, &rotate)
|
|
|
|
|
+ rotate.summary = nil
|
|
|
|
|
+ }
|
|
|
|
|
+ Button("Cancel", role: .cancel) {}
|
|
|
|
|
+ } message: {
|
|
|
|
|
+ if let summary = rotate.summary {
|
|
|
|
|
+ Text(summary)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .alert("Autosave", isPresented: $rotate.hasTriggeredAutosave) {
|
|
|
|
|
+ Text("Cleaned up the following Tasks:\n" + (rotate.summary ?? ""))
|
|
|
Button("OK") {
|
|
Button("OK") {
|
|
|
- hasAutosave = false
|
|
|
|
|
|
|
+ rotate.hasTriggeredAutosave = false
|
|
|
|
|
+ rotate.summary = nil
|
|
|
}
|
|
}
|
|
|
} message: {
|
|
} message: {
|
|
|
Text("All completed tasks/subtasks have been deleted")
|
|
Text("All completed tasks/subtasks have been deleted")
|
|
|
|
|
+ if let summary = rotate.summary {
|
|
|
|
|
+ Text(summary)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -82,7 +100,7 @@ struct ContentView: View {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#Preview {
|
|
#Preview {
|
|
|
- @Previewable @State var hasAutosave = false
|
|
|
|
|
- ContentView(hasAutosave: $hasAutosave)
|
|
|
|
|
|
|
+ @Previewable @State var rotate = RotateTracking()
|
|
|
|
|
+ ContentView(rotate: $rotate)
|
|
|
.modelContainer(for: Project.self, inMemory: true)
|
|
.modelContainer(for: Project.self, inMemory: true)
|
|
|
}
|
|
}
|