diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 241aca58f..ab5df11ae 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -241,6 +241,16 @@ import Views private let columns = Array(repeating: GridItem(.flexible(), spacing: 20), count: 2) + func contextMenuActionHandler(item: FeedItem, action: GridCardAction) { + switch action { + case .toggleArchiveStatus: + viewModel.setLinkArchived(dataService: dataService, linkId: item.id, archived: !item.isArchived) + case .delete: + itemToRemove = item + confirmationShown = true + } + } + var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: 20) { @@ -248,27 +258,10 @@ 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 - } - }, + actionHandler: { contextMenuActionHandler(item: item, action: $0) }, selectedLinkItem: $selectedLinkItem, viewModel: viewModel ) - .contextMenu { - FeedItemContextMenuView( - item: item, - selectedLinkItem: $selectedLinkItem, - snoozePresented: $snoozePresented, - itemToSnooze: $itemToSnooze, - viewModel: viewModel - ) - } if #available(iOS 15.0, *) { link .alert("Are you sure?", isPresented: $confirmationShown) { diff --git a/apple/OmnivoreKit/Sources/Views/HomeFeedCardView.swift b/apple/OmnivoreKit/Sources/Views/HomeFeedCardView.swift index 5fb4e8675..9107b2a7d 100644 --- a/apple/OmnivoreKit/Sources/Views/HomeFeedCardView.swift +++ b/apple/OmnivoreKit/Sources/Views/HomeFeedCardView.swift @@ -64,6 +64,24 @@ public struct GridCard: View { self.actionHandler = actionHandler } + var contextMenuView: some View { + Group { + 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") } + ) + } + } + public var body: some View { VStack(alignment: .leading, spacing: 16) { // Progress Bar @@ -84,24 +102,7 @@ public struct GridCard: View { .foregroundColor(.appGrayTextContrast) .lineLimit(1) Spacer() - 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 } - ) + Menu(content: { contextMenuView }, label: { Image.profile }) } HStack { @@ -164,23 +165,7 @@ public struct GridCard: View { } .background(Color(.secondarySystemGroupedBackground)) .cornerRadius(6) - } -} - -struct TextChipdep: View { - let text: String - let color: Color - - var body: some View { - Capsule() - .fill(color.opacity(0.3)) - .border(color.opacity(0.7), width: 3) - .overlay( - Text(text) - .font(.appFootnote) - .foregroundColor(color) - .padding() - ) + .contextMenu { contextMenuView } } }