Skip to content

Commit

Permalink
[Woo POS ] Add documentation link to floating button (#15085)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgabrielma authored Feb 10, 2025
2 parents 01b89b7 + b73d7c4 commit 7158e89
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ struct POSFloatingControlView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Binding private var showExitPOSModal: Bool
@Binding private var showSupport: Bool
@Binding private var showDocumentation: Bool

init(showExitPOSModal: Binding<Bool>, showSupport: Binding<Bool>) {
init(showExitPOSModal: Binding<Bool>,
showSupport: Binding<Bool>,
showDocumentation: Binding<Bool>) {
self._showExitPOSModal = showExitPOSModal
self._showSupport = showSupport
self._showDocumentation = showDocumentation
}

var body: some View {
Expand All @@ -35,6 +39,14 @@ struct POSFloatingControlView: View {
icon: { Image(systemName: "questionmark.circle") }
)
}
Button {
showDocumentation = true
} label: {
Label(
title: { Text(Localization.viewDocumentation) },
icon: { Image(systemName: "info.circle") }
)
}
} label: {
VStack {
Spacer()
Expand Down Expand Up @@ -105,5 +117,26 @@ private extension POSFloatingControlView {
value: "Get Support",
comment: "The title of the floating button to get support for Point of Sale, shown in a popover menu."
)

static let viewDocumentation = NSLocalizedString(
"pointOfSale.floatingButtons.viewDocumentation.button.title",
value: "Documentation",
comment: "The title of the floating button to read Point of Sale documentation, shown in a popover menu."
)
}
}

#if DEBUG
@available(iOS 17.0, *)
#Preview {
let posModel = PointOfSaleAggregateModel(
itemsController: PointOfSalePreviewItemsController(),
cardPresentPaymentService: CardPresentPaymentPreviewService(),
orderController: PointOfSalePreviewOrderController())

POSFloatingControlView(showExitPOSModal: .constant(false),
showSupport: .constant(false),
showDocumentation: .constant(false))
.environment(posModel)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct PointOfSaleDashboardView: View {

@State private var showExitPOSModal: Bool = false
@State private var showSupport: Bool = false
@State private var showDocumentation: Bool = false

@State private var floatingSize: CGSize = .zero

Expand Down Expand Up @@ -41,7 +42,8 @@ struct PointOfSaleDashboardView: View {
}

POSFloatingControlView(showExitPOSModal: $showExitPOSModal,
showSupport: $showSupport)
showSupport: $showSupport,
showDocumentation: $showDocumentation)
.shadow(color: Color.black.opacity(0.12), radius: 4, y: 2)
.offset(x: Constants.floatingControlHorizontalOffset, y: -Constants.floatingControlVerticalOffset)
.trackSize(size: $floatingSize)
Expand Down Expand Up @@ -77,6 +79,9 @@ struct PointOfSaleDashboardView: View {
.sheet(isPresented: $showSupport) {
supportForm
}
.sheet(isPresented: $showDocumentation) {
documentationView
}
.task {
await posModel.loadItems(base: .root)
}
Expand Down Expand Up @@ -128,6 +133,10 @@ private extension PointOfSaleDashboardView {
.navigationViewStyle(.stack)
}

var documentationView: some View {
SafariView(url: WooConstants.URLs.pointOfSaleDocumentation.asURL())
}

func paymentsOnboardingView(from onboardingViewModel: CardPresentPaymentsOnboardingViewModel) -> some View {
onboardingViewModel.showSupport = { [weak posModel] in
posModel?.cancelCardPaymentsOnboarding()
Expand Down
4 changes: 3 additions & 1 deletion WooCommerce/Classes/System/WooConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ extension WooConstants {
///
case inPersonPaymentsLearnMoreStripe = "https://woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/"

/// URL for the order creation feedback survey (full order creation and simple payments)
/// URL for Point of Sale documentation
///
case pointOfSaleDocumentation = "https://woocommerce.com/document/woo-mobile-app-point-of-sale-mode/"

#if DEBUG
case orderCreationFeedback = "https://automattic.survey.fm/woo-app-order-creation-testing"
#else
Expand Down

0 comments on commit 7158e89

Please sign in to comment.