mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add copy and delete options to highlight list cards
This commit is contained in:
parent
e36920e96e
commit
36e5e76809
3 changed files with 39 additions and 12 deletions
|
|
@ -10,16 +10,29 @@ struct HighlightsListCard: View {
|
|||
let highlightParams: HighlightListItemParams
|
||||
@Binding var hasHighlightMutations: Bool
|
||||
let onSaveAnnotation: (String) -> Void
|
||||
let onDeleteHighlight: () -> Void
|
||||
|
||||
var contextMenuView: some View {
|
||||
Group {
|
||||
Button(
|
||||
action: {},
|
||||
label: { Label("Stubby One", systemImage: "highlighter") }
|
||||
action: {
|
||||
#if os(iOS)
|
||||
UIPasteboard.general.string = highlightParams.quote
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
let pasteBoard = NSPasteboard.general
|
||||
pasteBoard.clearContents()
|
||||
pasteBoard.writeObjects([highlightParams.quote as NSString])
|
||||
#endif
|
||||
|
||||
Snackbar.show(message: "Highlight copied")
|
||||
},
|
||||
label: { Label("Copy", systemImage: "doc.on.doc") }
|
||||
)
|
||||
Button(
|
||||
action: {},
|
||||
label: { Label("Stubby Two", systemImage: "textbox") }
|
||||
action: onDeleteHighlight,
|
||||
label: { Label("Delete", systemImage: "trash") }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,23 @@ struct HighlightsListView: View {
|
|||
ForEach(viewModel.highlightItems) { highlightParams in
|
||||
HighlightsListCard(
|
||||
highlightParams: highlightParams,
|
||||
hasHighlightMutations: $hasHighlightMutations
|
||||
) { newAnnotation in
|
||||
viewModel.updateAnnotation(
|
||||
highlightID: highlightParams.highlightID,
|
||||
annotation: newAnnotation,
|
||||
dataService: dataService
|
||||
)
|
||||
}
|
||||
hasHighlightMutations: $hasHighlightMutations,
|
||||
onSaveAnnotation: {
|
||||
viewModel.updateAnnotation(
|
||||
highlightID: highlightParams.highlightID,
|
||||
annotation: $0,
|
||||
dataService: dataService
|
||||
)
|
||||
},
|
||||
onDeleteHighlight: {
|
||||
hasHighlightMutations = true
|
||||
|
||||
viewModel.deleteHighlight(
|
||||
highlightID: highlightParams.highlightID,
|
||||
dataService: dataService
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ struct HighlightListItemParams: Identifiable {
|
|||
}
|
||||
}
|
||||
|
||||
func deleteHighlight(highlightID: String, dataService: DataService) {
|
||||
dataService.deleteHighlight(highlightID: highlightID)
|
||||
highlightItems.removeAll { $0.highlightID == highlightID }
|
||||
}
|
||||
|
||||
private func loadHighlights(item: LinkedItem) {
|
||||
let unsortedHighlights = item.highlights.asArray(of: Highlight.self)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue