Skip to content

[Woo POS] UI - Cart: Product rows #12749

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 7 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions WooCommerce/Classes/POS/Presentation/CartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,47 @@ struct CartView: View {
var body: some View {
VStack {
Text("Cart")
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, 32)
.padding(.vertical, 8)
.font(.title)
.foregroundColor(Color.white)
ForEach(viewModel.productsInCart, id: \.product.productID) { cartProduct in
ProductRowView(cartProduct: cartProduct) {
viewModel.removeProductFromCart(cartProduct)
}
.background(Color.tertiaryBackground)
.padding(.horizontal, 32)
}
Spacer()
Button("Pay now") {
viewModel.submitCart()
}
.background(Color.secondaryBackground)
checkoutButton
.padding(.horizontal, 32)

}
.frame(maxWidth: .infinity)
.background(Color.secondaryBackground)
}
}

/// View sub-components
///
private extension CartView {
var checkoutButton: some View {
Button("Checkout") {
viewModel.submitCart()
}
.padding(.all, 20)
.frame(maxWidth: .infinity, idealHeight: 120)
.font(.title)
.foregroundColor(Color.primaryBackground)
.background(Color.white)
.cornerRadius(10)
}
}

#if DEBUG
#Preview {
CartView(viewModel: PointOfSaleDashboardViewModel(products: POSProductFactory.makeFakeProducts(),
cardReaderConnectionViewModel: .init(state: .connectingToReader)))
}
#endif
4 changes: 2 additions & 2 deletions WooCommerce/Classes/POS/Presentation/ProductCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct ProductCardView: View {
.foregroundStyle(Color.primaryBackground)
HStack(spacing: 8) {
QuantityBadgeView()
.frame(width: 50, height: 50)
.frame(width: 56, height: 56)
Spacer()
Button(action: {
onProductCardTapped?()
}, label: { })
.buttonStyle(POSPlusButtonStyle())
.frame(width: 50, height: 50)
.frame(width: 56, height: 56)
}
}
.frame(maxWidth: .infinity)
Expand Down
16 changes: 11 additions & 5 deletions WooCommerce/Classes/POS/Presentation/ProductRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@ struct ProductRowView: View {
var body: some View {
HStack {
Text(cartProduct.product.name)
.foregroundColor(Color.white)
.padding(.horizontal, 32)
.foregroundColor(Color.primaryBackground)
Spacer()
Button(action: {
onProductRemoveTapped?()
}, label: {
Image(systemName: "minus.circle.fill")
.foregroundColor(Color.white)
Image(systemName: "x.circle")
})
.frame(width: 56, height: 56, alignment: .trailing)
.padding(.horizontal, 32)
.foregroundColor(Color.lightBlue)
.background(Color(.clear))
}
.frame(maxWidth: .infinity)
.border(Color.gray, width: 1)
.frame(maxWidth: .infinity, idealHeight: 120)
.foregroundColor(Color.tertiaryBackground)
}
}

#if DEBUG
#Preview {
ProductRowView(cartProduct: CartProduct(id: UUID(),
product: POSProductFactory.makeProduct(),
quantity: 2))
}
#endif
6 changes: 6 additions & 0 deletions WooCommerce/Classes/POS/Utils/Color+WooCommercePOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ extension Color {
return Color(red: 142.0 / 255.0, green: 208.0 / 255.0, blue: 240.0 / 255.0)
}

/// POS color: Light Blue
///
static var lightBlue: Color {
return Color(red: 202.0 / 255.0, green: 237.0 / 255.0, blue: 255.0 / 255.0)
}

/// Default POS text color
///
static var primaryText: Color {
Expand Down