mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
show context menu on button tap
This commit is contained in:
parent
d130ba6b92
commit
81522aef22
3 changed files with 35 additions and 4 deletions
|
|
@ -35,6 +35,7 @@ struct GridCardNavigationLink: View {
|
|||
|
||||
let item: FeedItem
|
||||
let searchQuery: String
|
||||
let actionHandler: (GridCardAction) -> Void
|
||||
|
||||
@Binding var selectedLinkItem: FeedItem?
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ struct GridCardNavigationLink: View {
|
|||
tag: item,
|
||||
selection: $selectedLinkItem
|
||||
) {
|
||||
GridCard(item: item)
|
||||
GridCard(item: item, actionHandler: actionHandler)
|
||||
}
|
||||
.buttonStyle(FlatLinkStyle())
|
||||
.onAppear {
|
||||
|
|
|
|||
|
|
@ -248,6 +248,15 @@ import Views
|
|||
let link = GridCardNavigationLink(
|
||||
item: item,
|
||||
searchQuery: searchQuery,
|
||||
actionHandler: { action in
|
||||
switch action {
|
||||
case .toggleArchiveStatus:
|
||||
viewModel.setLinkArchived(dataService: dataService, linkId: item.id, archived: !item.isArchived)
|
||||
case .delete:
|
||||
itemToRemove = item
|
||||
confirmationShown = true
|
||||
}
|
||||
},
|
||||
selectedLinkItem: $selectedLinkItem,
|
||||
viewModel: viewModel
|
||||
)
|
||||
|
|
|
|||
|
|
@ -50,11 +50,18 @@ public struct FeedCard: View {
|
|||
}
|
||||
}
|
||||
|
||||
public enum GridCardAction {
|
||||
case toggleArchiveStatus
|
||||
case delete
|
||||
}
|
||||
|
||||
public struct GridCard: View {
|
||||
let item: FeedItem
|
||||
let actionHandler: (GridCardAction) -> Void
|
||||
|
||||
public init(item: FeedItem) {
|
||||
public init(item: FeedItem, actionHandler: @escaping (GridCardAction) -> Void) {
|
||||
self.item = item
|
||||
self.actionHandler = actionHandler
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
|
|
@ -77,8 +84,22 @@ public struct GridCard: View {
|
|||
.foregroundColor(.appGrayTextContrast)
|
||||
.lineLimit(1)
|
||||
Spacer()
|
||||
Button(
|
||||
action: { print("grid button tapped") },
|
||||
Menu(
|
||||
content: {
|
||||
Button(
|
||||
action: { actionHandler(.toggleArchiveStatus) },
|
||||
label: {
|
||||
Label(
|
||||
item.isArchived ? "Unarchive" : "Archive",
|
||||
systemImage: item.isArchived ? "tray.and.arrow.down.fill" : "archivebox"
|
||||
)
|
||||
}
|
||||
)
|
||||
Button(
|
||||
action: { actionHandler(.delete) },
|
||||
label: { Label("Delete Link", systemImage: "trash") }
|
||||
)
|
||||
},
|
||||
label: { Image.profile }
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue