add ability to delete an entry aka mark it missing

make entire row tappable instead of just content

closed #46
This commit is contained in:
Trey t
2022-01-29 12:17:35 -06:00
parent 01fcf70d45
commit 27e2bf2a40
3 changed files with 14 additions and 7 deletions

View File

@@ -63,6 +63,16 @@ struct ContentView: View {
showUpdateEntryAlert = false showUpdateEntryAlert = false
}) })
} }
if deleteEnabled {
Button(String(localized: "content_view_delete_entry"), action: {
if let selectedMissingEntry = selectedEntry {
viewModel.update(entry: selectedMissingEntry, toMood: Mood.missing)
}
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: {
selectedEntry = nil selectedEntry = nil
showUpdateEntryAlert = false showUpdateEntryAlert = false
@@ -190,18 +200,12 @@ struct ContentView: View {
return $0.forDate! > $1.forDate! return $0.forDate! > $1.forDate!
}), id: \.self) { entry in }), id: \.self) { entry in
entryListView(entry: entry) entryListView(entry: entry)
.contentShape(Rectangle())
.onTapGesture(perform: { .onTapGesture(perform: {
selectedEntry = entry selectedEntry = entry
showUpdateEntryAlert = true showUpdateEntryAlert = true
}) })
} }
// if deleteEnabled {
// .onDelete(perform: { offsets in
// withAnimation {
// viewModel.delete(offsets: offsets, inMonth: month, inYear: year)
// }
// })
// }
} }
} }

View File

@@ -42,6 +42,8 @@ struct SettingsView: View {
if useCloudKit { if useCloudKit {
cloudKitStatus cloudKitStatus
} }
canDelete
} }
Spacer() Spacer()
} }

View File

@@ -35,6 +35,7 @@
"content_view_tab_stats" = "Stats"; "content_view_tab_stats" = "Stats";
"content_view_fill_in_missing_entry" = "Fill in missing entry"; "content_view_fill_in_missing_entry" = "Fill in missing entry";
"content_view_fill_in_missing_entry_cancel" = "Cancel"; "content_view_fill_in_missing_entry_cancel" = "Cancel";
"content_view_delete_entry" = "Delete this entry";
"content_view_header_title" = "Past %d days"; "content_view_header_title" = "Past %d days";
"content_view_empty_title" = "You aint done shit"; "content_view_empty_title" = "You aint done shit";
"content_view_empty_body" = "Fucking vote or something?!?!? How the fuck was yesterday?"; "content_view_empty_body" = "Fucking vote or something?!?!? How the fuck was yesterday?";