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.append(obj)
|
||||||
}
|
}
|
||||||
entriesToDelete.forEach({ entry in
|
entriesToDelete.forEach({ entry in
|
||||||
|
let entryDate = entry.forDate!
|
||||||
PersistenceController.shared.viewContext.delete(entry)
|
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 showingSheet = false
|
||||||
@State private var showTodayInput = true
|
@State private var showTodayInput = true
|
||||||
@State private var selectedMissingEntry: MoodEntry?
|
@State private var selectedEntry: MoodEntry?
|
||||||
@State private var showMissingAlert = false
|
@State private var showUpdateEntryAlert = false
|
||||||
|
|
||||||
@ObservedObject var viewModel = ContentModeViewModel()
|
@ObservedObject var viewModel = ContentModeViewModel()
|
||||||
|
|
||||||
@@ -48,18 +48,18 @@ struct ContentView: View {
|
|||||||
needsOnboarding = false
|
needsOnboarding = false
|
||||||
viewModel.updateOnboardingData(onboardingData: onboardingData)
|
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
|
ForEach(Mood.allValues) { mood in
|
||||||
Button(mood.strValue, action: {
|
Button(mood.strValue, action: {
|
||||||
if let selectedMissingEntry = selectedMissingEntry {
|
if let selectedMissingEntry = selectedEntry {
|
||||||
viewModel.update(entry: selectedMissingEntry, toMood: mood)
|
viewModel.update(entry: selectedMissingEntry, toMood: mood)
|
||||||
}
|
}
|
||||||
showMissingAlert = false
|
showUpdateEntryAlert = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Button(String(localized: "content_view_fill_in_missing_entry_cancel"), role: .cancel, action: {
|
Button(String(localized: "content_view_fill_in_missing_entry_cancel"), role: .cancel, action: {
|
||||||
selectedMissingEntry = nil
|
selectedEntry = nil
|
||||||
showMissingAlert = false
|
showUpdateEntryAlert = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,10 +133,8 @@ struct ContentView: View {
|
|||||||
}), id: \.self) { entry in
|
}), id: \.self) { entry in
|
||||||
entryListView(entry: entry)
|
entryListView(entry: entry)
|
||||||
.onTapGesture(perform: {
|
.onTapGesture(perform: {
|
||||||
if entry.moodValue == Mood.missing.rawValue {
|
selectedEntry = entry
|
||||||
selectedMissingEntry = entry
|
showUpdateEntryAlert = true
|
||||||
showMissingAlert = true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}.onDelete(perform: { offsets in
|
}.onDelete(perform: { offsets in
|
||||||
withAnimation {
|
withAnimation {
|
||||||
|
|||||||
Reference in New Issue
Block a user