Skip to content

Commit

Permalink
Make cash view modal presentation from totals
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgabrielma committed Dec 20, 2024
1 parent 6144cf7 commit 6eb26ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ struct PointOfSaleCollectCashView: View {
@State private var isLoading: Bool = false
@State private var errorMessage: String?

@Binding var isVisible: Bool

private var orderTotal: String? {
if case .loaded(let totals) = posModel.orderState {
return totals.orderTotal
Expand All @@ -18,7 +20,7 @@ struct PointOfSaleCollectCashView: View {
VStack(alignment: .center, spacing: 20) {
HStack {
Button(action: {
posModel.cancelCashPayment()
isVisible = false
}, label: {
VStack {
HStack {
Expand Down Expand Up @@ -124,6 +126,6 @@ private extension PointOfSaleCollectCashView {
itemsController: PointOfSalePreviewItemsController(),
cardPresentPaymentService: CardPresentPaymentPreviewService(),
orderController: PointOfSalePreviewOrderController())
PointOfSaleCollectCashView()
PointOfSaleCollectCashView(isVisible: .constant(true))
.environmentObject(posModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,9 @@ struct PointOfSaleDashboardView: View {
}

if posModel.orderStage == .finalizing {
switch posModel.paymentState {
case .acceptingCash:
PointOfSaleCollectCashView()
default:
TotalsView()
.accessibilitySortPriority(2)
.transition(.move(edge: .trailing))
}
TotalsView()
.accessibilitySortPriority(2)
.transition(.move(edge: .trailing))
}
}
.animation(.default, value: posModel.orderStage)
Expand Down
7 changes: 6 additions & 1 deletion WooCommerce/Classes/POS/Presentation/TotalsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct TotalsView: View {
@Environment(\.dynamicTypeSize) var dynamicTypeSize
@Environment(\.colorScheme) var colorScheme

@State private var shouldShowCollectCashPayment: Bool = false

var body: some View {
HStack {
switch posModel.orderState {
Expand Down Expand Up @@ -57,7 +59,7 @@ struct TotalsView: View {
.layoutPriority(2)
}
Button(action: {
posModel.collectCashPayment()
shouldShowCollectCashPayment = true
}, label: {
Text(Localization.cashPaymentButtonTitle)
.font(POSFontStyle.posBodyEmphasized)
Expand Down Expand Up @@ -86,6 +88,9 @@ struct TotalsView: View {
}
.onChange(of: shouldShowTotalsFields, perform: hideTotalsFieldsWithDelay)
.geometryGroupIfSupported()
.fullScreenCover(isPresented: $shouldShowCollectCashPayment) {
PointOfSaleCollectCashView(isVisible: $shouldShowCollectCashPayment)
}
}

private var backgroundColor: Color {
Expand Down

0 comments on commit 6eb26ef

Please sign in to comment.