From f7172f02b1539de2cddd20b638c9fa981551a281 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 13 Jun 2022 21:55:05 -0700 Subject: [PATCH] show title edit sheets from context menu taps --- .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 7 ++++++- .../Sources/App/Views/Home/HomeFeedViewMac.swift | 2 +- .../App/Views/Home/HomeFeedViewModel.swift | 1 + .../Sources/App/Views/LinkItemDetailView.swift | 8 +++++++- .../App/Views/LinkedItemTitleEditView.swift | 15 +++++++++++++++ .../App/Views/WebReader/WebReaderContainer.swift | 6 +++++- .../Sources/Views/FeedItem/GridCard.swift | 3 ++- 7 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 5804bcaeb..480e84012 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -55,6 +55,9 @@ import Views .sheet(item: $viewModel.itemUnderLabelEdit) { item in ApplyLabelsView(mode: .item(item), onSave: nil) } + .sheet(item: $viewModel.itemUnderTitleEdit) { item in + LinkedItemTitleEditView(item: item) + } .toolbar { ToolbarItem(placement: .barTrailing) { Button("", action: {}) @@ -231,7 +234,7 @@ import Views ) .contextMenu { Button( - action: { print("show edit modal") }, + action: { viewModel.itemUnderTitleEdit = item }, label: { Label("Edit Title/Description", systemImage: "textbox") } ) Button( @@ -348,6 +351,8 @@ import Views confirmationShown = true case .editLabels: viewModel.itemUnderLabelEdit = item + case .editTitle: + viewModel.itemUnderTitleEdit = item } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index a4c13d463..0dc402ac8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -27,7 +27,7 @@ import Views ) .contextMenu { Button( - action: { print("show edit modal") }, + action: { viewModel.itemUnderTitleEdit = item }, label: { Label("Edit Title/Description", systemImage: "textbox") } ) Button( diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 247ccf7db..2d104d0ee 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -14,6 +14,7 @@ import Views @Published var isLoading = false @Published var showPushNotificationPrimer = false @Published var itemUnderLabelEdit: LinkedItem? + @Published var itemUnderTitleEdit: LinkedItem? @Published var searchTerm = "" @Published var selectedLabels = [LinkedItemLabel]() @Published var negatedLabels = [LinkedItemLabel]() diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index ec57317f6..7d8fc2a40 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -119,6 +119,7 @@ struct LinkItemDetailView: View { static let navBarHeight = 50.0 @ObservedObject private var viewModel: LinkItemDetailViewModel @State private var showFontSizePopover = false + @State private var showTitleEdit = false @State private var navBarVisibilityRatio = 1.0 @State private var showDeleteConfirmation = false @@ -207,7 +208,7 @@ struct LinkItemDetailView: View { content: { Group { Button( - action: { print("show edit modal") }, + action: { showTitleEdit = true }, label: { Label("Edit Title/Description", systemImage: "textbox") } ) Button( @@ -244,6 +245,11 @@ struct LinkItemDetailView: View { } Button("Cancel", role: .cancel, action: {}) } + .sheet(isPresented: $showTitleEdit) { + if let item = viewModel.item { + LinkedItemTitleEditView(item: item) + } + } } #if os(iOS) diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift new file mode 100644 index 000000000..904d1ca89 --- /dev/null +++ b/apple/OmnivoreKit/Sources/App/Views/LinkedItemTitleEditView.swift @@ -0,0 +1,15 @@ +import Models +import Services +import SwiftUI + +struct LinkedItemTitleEditView: View { + @EnvironmentObject var dataService: DataService + @Environment(\.presentationMode) private var presentationMode +// @StateObject var viewModel = LabelsViewModel() + + let item: LinkedItem + + var body: some View { + Text(item.title ?? "unknown item") + } +} diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 44c46a776..5bc1db9ef 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -10,6 +10,7 @@ import WebKit @State private var showPreferencesPopover = false @State private var showLabelsModal = false + @State private var showTitleEdit = false @State var showHighlightAnnotationModal = false @State var safariWebLink: SafariWebLink? @State private var navBarVisibilityRatio = 1.0 @@ -83,7 +84,7 @@ import WebKit content: { Group { Button( - action: { print("show edit modal") }, + action: { showTitleEdit = true }, label: { Label("Edit Title/Description", systemImage: "textbox") } ) Button( @@ -134,6 +135,9 @@ import WebKit .sheet(isPresented: $showLabelsModal) { ApplyLabelsView(mode: .item(item), onSave: { _ in showLabelsModal = false }) } + .sheet(isPresented: $showTitleEdit) { + LinkedItemTitleEditView(item: item) + } } var body: some View { diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index ed2aba12b..1e8e46254 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -6,6 +6,7 @@ public enum GridCardAction { case toggleArchiveStatus case delete case editLabels + case editTitle } public struct GridCard: View { @@ -44,7 +45,7 @@ public struct GridCard: View { var contextMenuView: some View { Group { Button( - action: { print("show edit modal") }, + action: { menuActionHandler(.editTitle) }, label: { Label("Edit Title/Description", systemImage: "textbox") } ) Button(