From d82ffa44324d1cd2fadb8b45336a53f6caddab39 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 4 Oct 2022 08:45:48 -0700 Subject: [PATCH] add view highlights context menu to home feed items --- .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 9 +++++++++ .../Sources/App/Views/Home/HomeFeedViewMac.swift | 2 ++ .../Sources/App/Views/Home/HomeFeedViewModel.swift | 1 + apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift | 1 + apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift | 5 +++++ 5 files changed, 18 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index a4a1e91b4..58800211b 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -62,6 +62,9 @@ import Views .sheet(item: $viewModel.itemUnderTitleEdit) { item in LinkedItemTitleEditView(item: item) } + .sheet(item: $viewModel.itemForHighlightsView) { item in + Text("Highlights view for: \(item.unwrappedTitle)") // TODO: implement view + } .toolbar { ToolbarItem(placement: .barTrailing) { Button("", action: {}) @@ -255,6 +258,10 @@ import Views viewModel: viewModel ) .contextMenu { + Button( + action: { viewModel.itemForHighlightsView = item }, + label: { Label("View Highlights", systemImage: "highlighter") } + ) Button( action: { viewModel.itemUnderTitleEdit = item }, label: { Label("Edit Title/Description", systemImage: "textbox") } @@ -372,6 +379,8 @@ import Views func contextMenuActionHandler(item: LinkedItem, action: GridCardAction) { switch action { + case .viewHighlights: + viewModel.itemForHighlightsView = item case .toggleArchiveStatus: viewModel.setLinkArchived(dataService: dataService, objectID: item.objectID, archived: !item.isArchived) case .delete: diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index adced8706..49a12d1c9 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -36,6 +36,7 @@ import Views viewModel: viewModel ) .contextMenu { + // TODO: add highlights view button Button( action: { viewModel.itemUnderTitleEdit = item }, label: { Label("Edit Title/Description", systemImage: "textbox") } @@ -137,6 +138,7 @@ import Views .sheet(item: $viewModel.itemUnderTitleEdit) { item in LinkedItemTitleEditView(item: item) } + // TODO: add highlights view sheet .task { if viewModel.items.isEmpty { loadItems(isRefresh: true) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 543d23727..65d4f4d75 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -17,6 +17,7 @@ import Views @Published var showPushNotificationPrimer = false @Published var itemUnderLabelEdit: LinkedItem? @Published var itemUnderTitleEdit: LinkedItem? + @Published var itemForHighlightsView: LinkedItem? @Published var searchTerm = "" @Published var selectedLabels = [LinkedItemLabel]() @Published var negatedLabels = [LinkedItemLabel]() diff --git a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift index 5ace227a6..5c8ac8803 100644 --- a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift +++ b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift @@ -15,4 +15,5 @@ public enum FeatureFlag { public static let enableSnooze = false public static let enableGridCardsOnPhone = false public static let enableTextToSpeechButton = true + public static let enableHighlightsView = true } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index d3f1707e8..99223de4d 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -8,6 +8,7 @@ public enum GridCardAction { case editLabels case editTitle case downloadAudio + case viewHighlights } public struct GridCard: View { @@ -45,6 +46,10 @@ public struct GridCard: View { var contextMenuView: some View { Group { + Button( + action: { menuActionHandler(.viewHighlights) }, + label: { Label("View Highlights", systemImage: "highlighter") } + ) Button( action: { menuActionHandler(.editTitle) }, label: { Label("Edit Title/Description", systemImage: "textbox") }