From 18fc5d19a457fa4ec83c0b8c528a3ea7a16088de Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 25 Nov 2022 15:10:02 +0800 Subject: [PATCH] Display an info alert if a user taps on Highlight but does not have a highlight --- .../Share/Views/ShareExtensionView.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift index 82788db6a..07073c409 100644 --- a/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Share/Views/ShareExtensionView.swift @@ -16,6 +16,7 @@ public struct ShareExtensionView: View { @State var messageText: String? @State var viewState = ViewState.mainView + @State var showHighlightInstructionAlert = false enum FocusField: Hashable { case titleEditor @@ -297,7 +298,7 @@ public struct ShareExtensionView: View { Button( action: {}, label: { - Button(action: {}, label: { Label("Dismiss", systemImage: "arrow.down.to.line") }) + Button("Dismiss", role: .cancel, action: {}) } ) Button(action: { @@ -452,7 +453,11 @@ public struct ShareExtensionView: View { highlightSection .onTapGesture { withAnimation { - viewState = .viewingHighlight + if viewModel.highlightData != nil { + viewState = .viewingHighlight + } else { + showHighlightInstructionAlert = true + } } } } @@ -481,6 +486,10 @@ public struct ShareExtensionView: View { .sheet(isPresented: $labelsViewModel.showCreateLabelModal) { CreateLabelView(viewModel: labelsViewModel) } + .alert("Before saving an article select text in Safari to create a highlight on save.", + isPresented: $showHighlightInstructionAlert) { + Button("Ok", role: .cancel) { showHighlightInstructionAlert = false } + } .environmentObject(viewModel.services.dataService) .task { await labelsViewModel.loadLabelsFromStore(dataService: viewModel.services.dataService)