Skip to content

Commit 1ea5411

Browse files
committed
Replace buttons in payment success view to use POSButtonStyle. Achieve 0.5 width with GeometryReader.
1 parent f1cc700 commit 1ea5411

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ struct PointOfSalePaymentSuccessView: View {
4242
}
4343
}
4444

45-
PaymentsActionButtons(isShowingSendReceiptView: $isShowingSendReceiptView,
46-
isShowingReceiptNotEligibleBanner: $isShowingReceiptNotEligibleBanner)
47-
.offset(y: isViewLoaded ? 0 : -Constants.animationOffset)
48-
.opacity(isViewLoaded ? 1 : 0)
45+
GeometryReader { geometry in
46+
PaymentsActionButtons(isShowingSendReceiptView: $isShowingSendReceiptView,
47+
isShowingReceiptNotEligibleBanner: $isShowingReceiptNotEligibleBanner)
48+
.frame(width: geometry.size.width / 2)
49+
.frame(maxWidth: .infinity, alignment: .center)
50+
.offset(y: isViewLoaded ? 0 : -Constants.animationOffset)
51+
.opacity(isViewLoaded ? 1 : 0)
52+
}
4953
}
5054
.multilineTextAlignment(.center)
5155

@@ -104,10 +108,17 @@ private extension PointOfSalePaymentSuccessView {
104108
}
105109
}
106110

111+
#if DEBUG
107112
@available(iOS 17.0, *)
108113
#Preview {
114+
let posModel = PointOfSaleAggregateModel(
115+
itemsController: PointOfSalePreviewItemsController(),
116+
cardPresentPaymentService: CardPresentPaymentPreviewService(),
117+
orderController: PointOfSalePreviewOrderController())
109118
return PointOfSalePaymentSuccessView(
110119
viewModel: PointOfSalePaymentSuccessViewModel(formattedOrderTotal: "$3.00",
111120
paymentMethod: .card)
112121
)
122+
.environment(posModel)
113123
}
124+
#endif

WooCommerce/Classes/POS/Presentation/PaymentButtons.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,8 @@ private extension PaymentsActionButtons {
3636
Text(Localization.sendReceipt)
3737
.font(Constants.buttonFont)
3838
}
39-
.frame(minWidth: UIScreen.main.bounds.width / 2)
4039
})
41-
.padding(Constants.buttonPadding)
42-
.foregroundColor(Color.posPrimaryText)
43-
.background(Color.clear)
44-
.overlay {
45-
RoundedRectangle(cornerRadius: Constants.buttonCornerRadius)
46-
.stroke(Color.posPrimaryText, lineWidth: 1.0)
47-
}
40+
.buttonStyle(POSButtonStyle(variant: .outlined, size: .normal))
4841
}
4942

5043
var newOrderButton: some View {
@@ -56,12 +49,8 @@ private extension PaymentsActionButtons {
5649
Text(Localization.newOrder)
5750
.font(Constants.buttonFont)
5851
}
59-
.frame(minWidth: UIScreen.main.bounds.width / 2)
6052
})
61-
.padding(Constants.buttonPadding)
62-
.foregroundColor(Color.posOnInverseSurface)
63-
.background(Color.posPrimaryButtonBackground)
64-
.cornerRadius(Constants.buttonCornerRadius)
53+
.buttonStyle(POSButtonStyle(variant: .filled, size: .normal))
6554
}
6655
}
6756

@@ -89,9 +78,7 @@ private extension PaymentsActionButtons {
8978
private extension PaymentsActionButtons {
9079
enum Constants {
9180
static let buttonSpacing: CGFloat = 12
92-
static let buttonPadding: CGFloat = 32
9381
static let buttonFont: POSFontStyle = .posBodyEmphasized
94-
static let buttonCornerRadius: CGFloat = 8
9582
}
9683

9784
enum Localization {

0 commit comments

Comments
 (0)