Skip to content

[Woo POS] Add totals view. Shuffle views on checkout flow #12809

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 23, 2024

Conversation

iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented May 22, 2024

Partially addresses #12763
Closes: #12764

This PR adds a initial Totals view, and shuffles the order of the different views depending if we're building or finalizing checkout. Most likely the view style will change, so I haven't taken much time with the UI details (eg: "Take payment" most likely will be removed or not be a button)

Description

Simulator Screen Recording - iPad Pro (12 9-inch) (6th generation) - 2024-05-22 at 15 54 04

Changes

  • New TotalsView. At the moment this just renders a list of products in-cart, and three buttons at the bottom for payment collection
  • Added an OrderStage enum that indicates where in the process are we, building or finalizing.

Testing instructions

  • Add a bunch of products to the cart
  • Tap Checkout
  • Observe how the views shuffle and the Cart appears to the left while a new Totals view appears to the right, with a list of all products added to the cart.
  • Remove products, observe that cart state is updated
  • Tap Add More
  • Observe we're back to order building and cart state is updated

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels May 22, 2024
@iamgabrielma iamgabrielma marked this pull request as ready for review May 22, 2024 09:06
@iamgabrielma iamgabrielma added this to the 18.8 milestone May 22, 2024
Comment on lines 34 to 44
.padding(.all, 10)
.frame(maxWidth: .infinity, idealHeight: 120)
.font(.title)
.foregroundColor(Color.primaryBackground)
.background(Color.white)
Button("Card") { debugPrint("Not implemented") }
.padding(.all, 10)
.frame(maxWidth: .infinity, idealHeight: 120)
.font(.title)
.foregroundColor(Color.primaryBackground)
.background(Color.white)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since most likely we'll share button styling in the POS, even if is not final, I think we can start to extract those and add more ButtonStyles to /ReusableViews?

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 22, 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 Numberpr12809-36a2a81
Version18.7
Bundle IDcom.automattic.alpha.woocommerce
Commit36a2a81
App Center BuildWooCommerce - Prototype Builds #9209
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Text("Totals")
.font(.title)
.foregroundColor(Color.white)
ForEach(viewModel.productsInCart, id: \.product.productID) { cartProduct in
Copy link
Contributor

Choose a reason for hiding this comment

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

Embed in ScrollView?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup yup! 6997ec8

.background(Color.secondaryBackground)
.frame(maxWidth: .infinity)
Spacer()
CartView(viewModel: viewModel)
Copy link
Contributor

Choose a reason for hiding this comment

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

you can extract this CartView and its setup into private var:

private var cartView: some View {
 CartView(viewModel: viewModel)
  .background(Color.secondaryBackground)
  .frame(maxWidth: .infinity)
}

You can do same thing with TotalsView and ProductGridView and just use those vars here in switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I've moved all subviews to variables on e5b9f11

.foregroundColor(.white)
}
Spacer()
HStack {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can put padding to this HStack, or some other layout tweak, so that button background (white) does not overflow to the bottom:

Simulator Screenshot - iPad Pro (11-inch) (4th generation) - 2024-05-22 at 14 02 52

Simulator Screenshot - iPad Pro (11-inch) (4th generation) - 2024-05-22 at 14 04 39

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, this only happens in landscape so I missed it. Fixed on 4896b7f

@iamgabrielma iamgabrielma requested a review from bozidarsevo May 23, 2024 04:36
Base automatically changed from task/pos-compose-viewmodel-outside-view to trunk May 23, 2024 16:50
@iamgabrielma iamgabrielma merged commit 42f2548 into trunk May 23, 2024
22 checks passed
@iamgabrielma iamgabrielma deleted the task/12764-pos-checkout-view-shuffle branch May 23, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS] Checkout flow view re-org
3 participants