can delete any entry and it will fill with a missing entry
can update any entry
This commit is contained in:
@@ -105,7 +105,9 @@ class ContentModeViewModel: ObservableObject {
|
||||
entriesToDelete.append(obj)
|
||||
}
|
||||
entriesToDelete.forEach({ entry in
|
||||
let entryDate = entry.forDate!
|
||||
PersistenceController.shared.viewContext.delete(entry)
|
||||
self.add(mood: .missing, forDate: entryDate)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ struct ContentView: View {
|
||||
|
||||
@State private var showingSheet = false
|
||||
@State private var showTodayInput = true
|
||||
@State private var selectedMissingEntry: MoodEntry?
|
||||
@State private var showMissingAlert = false
|
||||
@State private var selectedEntry: MoodEntry?
|
||||
@State private var showUpdateEntryAlert = false
|
||||
|
||||
@ObservedObject var viewModel = ContentModeViewModel()
|
||||
|
||||
@@ -48,18 +48,18 @@ struct ContentView: View {
|
||||
needsOnboarding = false
|
||||
viewModel.updateOnboardingData(onboardingData: onboardingData)
|
||||
})
|
||||
}).alert(String(localized: "content_view_fill_in_missing_entry"), isPresented: $showMissingAlert) {
|
||||
}).alert(String(localized: "content_view_fill_in_missing_entry"), isPresented: $showUpdateEntryAlert) {
|
||||
ForEach(Mood.allValues) { mood in
|
||||
Button(mood.strValue, action: {
|
||||
if let selectedMissingEntry = selectedMissingEntry {
|
||||
if let selectedMissingEntry = selectedEntry {
|
||||
viewModel.update(entry: selectedMissingEntry, toMood: mood)
|
||||
}
|
||||
showMissingAlert = false
|
||||
showUpdateEntryAlert = false
|
||||
})
|
||||
}
|
||||
Button(String(localized: "content_view_fill_in_missing_entry_cancel"), role: .cancel, action: {
|
||||
selectedMissingEntry = nil
|
||||
showMissingAlert = false
|
||||
selectedEntry = nil
|
||||
showUpdateEntryAlert = false
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -133,10 +133,8 @@ struct ContentView: View {
|
||||
}), id: \.self) { entry in
|
||||
entryListView(entry: entry)
|
||||
.onTapGesture(perform: {
|
||||
if entry.moodValue == Mood.missing.rawValue {
|
||||
selectedMissingEntry = entry
|
||||
showMissingAlert = true
|
||||
}
|
||||
selectedEntry = entry
|
||||
showUpdateEntryAlert = true
|
||||
})
|
||||
}.onDelete(perform: { offsets in
|
||||
withAnimation {
|
||||
|
||||
Reference in New Issue
Block a user