Skip to content

[Woo POS] UI: Reader connection presentation flow with simulated happy path #12740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 16, 2024

Conversation

jaclync
Copy link
Contributor

@jaclync jaclync commented May 15, 2024

Simulated flow for #12711

Why

Before having a concrete design, we can start working on the card reader connection flow with a mocked state machine. In a WIP PR #12723, I worked on extracting the UI logic from CardReaderConnectionController so that we can reuse the state machine logic while the UI/UX differs from the existing app. From that WIP work, we know a list of UI states and we can build the reader connection flow based on that list.

How

All of the changes in this PR are in the POS framework (noted as pos).

After reviewing the code for the UI states in CardReaderConnectionController, I concluded them into the following smaller list combining a few similar states and defined a new UI state CardReaderConnectionUIState in pos:

  • General connected/disconneceted states:
    • notConnected(search: () -> Void)
    • connected(readerID: String, disconnect: () -> Void)
  • States from card reader connection based on CardReaderConnectionController
    • scanningForReader(cancel: () -> Void)
    • scanningFailed(error: Error, close: () -> Void)
    • connectingToReader
    • connectingFailed(error: CardReaderConnectionError, retrySearch: () -> Void, cancelSearch: () -> Void)
    • readersFound(readerIDs: [String], connect: (String) -> Void, continueSearch: () -> Void)
    • updateInProgress(requiredUpdate: Bool, progress: Float, cancel: (() -> Void)?)
    • updatingFailed(error: CardReaderUpdateError, tryAgain: (() -> Void)?, close: () -> Void)

Then, each UI state corresponds to a new SwiftUI view that follows the latest design when available.

To integrate with the POS dashboard, CardReaderConnectionView and its view model were created and shown in a sheet when the user taps on the "Reader not connected" CTA in the navigation bar.

To simulate the happy path for searching & connecting to a reader, CardReaderConnectionViewModel. checkReaderConnection is called on view's onAppear to mock the UI state transition.

Testing instructions

  • Go to the Menu tab
  • Ensure the POS feature switch is enabled (if not, go to Settings > Experimental Features, then enable "Point of Sale")
  • Tap Point of Sale menu item
  • Tap Reader not connected in the navigation bar --> the searching view should be shown first, then after 2 seconds, a list of 1 reader should be shown
  • Tap Connect --> the connecting view should be shown first, then after 2 seconds, the connected view is shown

Screenshots

Simulator.Screen.Recording.-.iPad.Air.5th.generation.-.2024-05-15.at.16.42.05.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: POS labels May 15, 2024
@jaclync jaclync added this to the 18.7 milestone May 15, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented May 15, 2024

1 Warning
⚠️ This PR is assigned to the milestone 18.7. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 15, 2024

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr12740-ff8c694
Version18.6
Bundle IDcom.automattic.alpha.woocommerce
Commitff8c694
App Center BuildWooCommerce - Prototype Builds #9065
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@jaclync jaclync changed the title [Woo POS] UI: Reader connection presentation flow [Woo POS] UI: Reader connection presentation flow with simulated happy path May 15, 2024
@jaclync jaclync marked this pull request as ready for review May 15, 2024 09:00
* trunk: (22 commits)
  Update button image to use “plus circle” symbol
  make property constant (again!)
  make property constant
  remove unused PlusButtonView
  remove whitespace
  Refactor plus button to use reusable view and style
  Don't throw error if coupon reports are empty.
  Require time range to fetch most active coupons.
  Make start date and end data non optional for fetching active coupons.
  Fix vstack width when cart view is empty
  Update components background colors
  Update product card colors
  Update remove button and quantity badge
  Update ProductFactory util
  address merge conflict
  Remove CartProduct from cart
  Extract views to own files. Add previews
  Add communication between product list and cart
  Create ProductCardView, PlusButtonView, QuantityBadgeView
  Action in coupon store to fetch most active coupons.
  ...

# Conflicts:
#	WooCommercePOS/WooCommercePOS.xcodeproj/project.pbxproj
@bozidarsevo
Copy link
Contributor

Looks ok, I will check again once CI is green, if that is ok.

@jaclync
Copy link
Contributor Author

jaclync commented May 15, 2024

Looks ok, I will check again once CI is green, if that is ok.

Sure, CI is green now. I'm not sure why the iPad UI tests failed to run at all, but all the PR changes are in the POS framework and aren't supposed to affect the app behavior.

@@ -5,7 +5,7 @@ public struct PointOfSaleEntryPointView: View {
// Temporary. DI proper product models once we have a data layer
private let viewModel: PointOfSaleDashboardViewModel = {
let products = ProductFactory.makeFakeProducts()
let viewModel = PointOfSaleDashboardViewModel(products: products)
let viewModel = PointOfSaleDashboardViewModel(products: products, cardReaderConnectionViewModel: .init(state: .scanningForReader(cancel: {})))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 While simplified at this point, I like that we have some sort of init state which should help with testability if we want to start a flow in a specific stage, something we should think about implementing in the final designs

@iamgabrielma
Copy link
Contributor

Looks good to me as well 👍

@jaclync
Copy link
Contributor Author

jaclync commented May 16, 2024

@iamgabrielma @bozidarsevo When the PR looks okay, could you stamp it to enable merge? 😄 I'm preparing a PR #12747 that moves all the POS files including the ones in this PR to the main app.

@jaclync jaclync merged commit 1a489dd into trunk May 16, 2024
22 checks passed
@jaclync jaclync deleted the feat/12711-card-reader-connection-flow branch May 16, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS status: feature-flagged Behind a feature flag. Milestone is not strongly held.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants