Skip to content

Conversation

@joshheald
Copy link
Contributor

@joshheald joshheald commented Jul 8, 2025

Closes WOOMOB-695
Merge after #15882

Description

This PR adds some basic structure that we'll use to build the scanner set up flows. Sorry it's pretty big – I ended up having to move a lot of stuff around.

I'm doing this with a view to correctly transitioning between the views, keeping buttons and header more or less in the same place but having bigger transitions for the content. Not animated yet, this PR focuses on removing the use of NavigationStack.

We will define different steps for each scanner's flow, and then move along one flow at a time, handled by the PointOfSaleBarcodeScannerSetupFlowManager working with multiple flows.

Steps to reproduce

  1. Launch the app and open POS
  2. Tap ... and open Barcode Scanning to see the scanner selection screen
  3. Tap Other – observe that the existing modal is shown (though a different size.)
  4. Tap Back – observe that the selection screen is shown again
  5. Tap a scanner – observe that a placeholder view is shown with customised buttons; Done only.

Screenshots

scanner.flow.structure.mp4

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

@joshheald joshheald added this to the 22.8 milestone Jul 8, 2025
@joshheald joshheald added type: task An internally driven task. status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: POS labels Jul 8, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jul 8, 2025

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 22.8. 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 Jul 8, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr15883-5e405e7
Version22.7
Bundle IDcom.automattic.alpha.woocommerce
Commit5e405e7
Installation URL5j0t20lu1nsqo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Base automatically changed from woomob-695-woo-posbarcodes-set-up-flow-choose-a-scanner-screen to trunk July 9, 2025 06:06
@joshheald joshheald marked this pull request as ready for review July 9, 2025 10:56
@joshheald joshheald requested a review from staskus July 9, 2025 10:58
@staskus staskus self-assigned this Jul 9, 2025
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Nice! 👍 I've done a few similar dynamic flows in other apps, I think it's done with the right balance:

  • Keeping the concept of a scan selection static
  • Adding title and button configurations, keeping the default option
  • Allowing to define content for each step

I thought the best way to review it to try the ergonomics and defining a custom flow.

I'm not approving it yet, I see the the navigation within the flow steps is not working, I don't know if it's supposed to be in the scope or not, although the code is written in the way that I think it should but the currentContent is not updating when calling .nextStep()

title: .constant(AttributedString(currentTitle)))

VStack {
currentContent
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wrapping the content within the TabView will help with transition animations, although it could be tricky, especially if we don't know how many steps we have until the initial selection is made. Nevertheless, I would consider something like this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... that's definitely worth trying, though I do want to keep it open to branching flows in future – e.g. additional steps after a failure for troubleshooting, going back to an arbitrary point in the flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

though I do want to keep it open to branching flows in future – e.g. additional steps after a failure for troubleshooting, going back to an arbitrary point in the flow.

TabView seems to be only partially suitable for this dynamic approach. Some online answers suggest that it's needed to change .id(..) of TabView whenever the content changes. I haven't tested it, though.

This is where it becomes interesting with the dynamic approach. Question whether we want to define within the steps of the flow more like a tree, to see possible paths if failures happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, potentially. Let's avoid complicating it too much for now though.

The transitions in my early experiments could work pretty well like this, so we'll see how we get on 😊

Aside: controls for flows like this really feel like something a mobile platform should provide, given how common they are.

switch scannerType {
case .socketS720:
return [
createWelcomeStep(title: "Socket S720 Setup")
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't work fully, at least not yet. If I define more steps, the UI is not updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I'll have a play, thanks.

I would expect it to work, but I pulled multi-step flows out a while ago while focusing on the structure and getting the PR to a managable size. My guess is that there's some failing of observation going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staskus Yes, it was because the Flow wasn't @Observable.

Simple fix in 5e405e7, thanks for the catch and sorry for missing it!

content.changing.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, a simple fix indeed! Thanks. 👍

)
}

private var steps: [PointOfSaleBarcodeScannerSetupStep] {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice, it will be handy to have all the steps in one place 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. If we need to in future, we can pass them in and define them separately. I'm wary of generalising this too much right now, but also want to keep it open to that; we may have other flows in POS in future, e.g. printer set up, or even configuring a customer's choices for a subscription/booking cart item.

@joshheald joshheald requested a review from staskus July 10, 2025 07:59
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

🚢

@joshheald joshheald merged commit dba69c0 into trunk Jul 10, 2025
13 checks passed
@joshheald joshheald deleted the woomob-695-woo-posbarcodes-set-up-flow-structure branch July 10, 2025 11:16
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. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants