@@ -28,63 +28,60 @@ struct PointOfSaleCollectCashView: View {
2828 var body : some View {
2929 ScrollView {
3030 VStack ( alignment: . center, spacing: conditionalPadding ( 8 ) ) {
31- HStack {
31+ POSPageHeaderView ( title: Localization . backNavigationTitle,
32+ subtitle: formattedOrderTotal,
33+ backButtonConfiguration: . init( state: isLoading ? . disabled: . enabled,
34+ action: {
35+ Task { @MainActor in
36+ await posModel. cancelCashPayment ( )
37+ isTextFieldFocused = false
38+ }
39+ } ) )
40+
41+ VStack {
42+ FormattableAmountTextField ( viewModel: textFieldViewModel, style: . pos)
43+ . focused ( $isTextFieldFocused)
44+ . dynamicTypeSize ( ... DynamicTypeSize . accessibility1)
45+ . onSubmit {
46+ Task { @MainActor in
47+ await submitCashAmount ( )
48+ }
49+ }
50+ . onChange ( of: textFieldViewModel. amount) { newValue in
51+ textFieldAmountInput = newValue
52+ updateChangeDueMessage ( )
53+ }
54+
55+ if let changeDue = changeDueMessage {
56+ Text ( changeDue)
57+ . font ( . posBodyLargeRegular( ) )
58+ . foregroundColor ( . posOnSurfaceVariantHighest)
59+ }
60+
61+ if let errorMessage = errorMessage {
62+ Text ( errorMessage)
63+ . font ( POSFontStyle . posBodyLargeRegular ( ) )
64+ . foregroundColor ( . red)
65+ . padding ( . bottom, Constants . errorMessagePadding)
66+ }
67+
3268 Button ( action: {
3369 Task { @MainActor in
34- await posModel. cancelCashPayment ( )
35- isTextFieldFocused = false
70+ await submitCashAmount ( )
3671 }
3772 } , label: {
38- navigationHeader
73+ Text ( Localization . markPaymentCompletedButtonTitle )
3974 } )
40- . disabled ( isLoading)
41- Spacer ( )
42- . renderedIf ( !dynamicTypeSize. isAccessibilitySize)
43- }
44-
45- FormattableAmountTextField ( viewModel: textFieldViewModel, style: . pos)
46- . focused ( $isTextFieldFocused)
75+ . buttonStyle ( POSFilledButtonStyle ( size: . normal, isLoading: isLoading) )
76+ . frame ( maxWidth: . infinity)
4777 . dynamicTypeSize ( ... DynamicTypeSize . accessibility1)
48- . onSubmit {
49- Task { @MainActor in
50- await submitCashAmount ( )
51- }
52- }
53- . onChange ( of: textFieldViewModel. amount) { newValue in
54- textFieldAmountInput = newValue
55- updateChangeDueMessage ( )
56- }
57-
58- if let changeDue = changeDueMessage {
59- Text ( changeDue)
60- . font ( . posBodyLargeRegular( ) )
61- . foregroundColor ( . posOnSurfaceVariantHighest)
62- }
78+ . disabled ( isLoading)
6379
64- if let errorMessage = errorMessage {
65- Text ( errorMessage)
66- . font ( POSFontStyle . posBodyLargeRegular ( ) )
67- . foregroundColor ( . red)
68- . padding ( . bottom, Constants . errorMessagePadding)
80+ Spacer ( )
6981 }
70-
71- Button ( action: {
72- Task { @MainActor in
73- await submitCashAmount ( )
74- }
75- } , label: {
76- Text ( Localization . markPaymentCompletedButtonTitle)
77- } )
78- . buttonStyle ( POSFilledButtonStyle ( size: . normal, isLoading: isLoading) )
79- . frame ( maxWidth: . infinity)
80- . dynamicTypeSize ( ... DynamicTypeSize . accessibility1)
81- . disabled ( isLoading)
82-
83- Spacer ( )
82+ . padding ( [ . horizontal, . bottom] )
8483 }
8584 . background ( backgroundColor)
86- . padding ( . top, conditionalPadding ( Constants . navigationHeaderTopPadding) )
87- . padding ( [ . horizontal, . bottom] )
8885 . animation ( . easeInOut, value: errorMessage)
8986 . animation ( . easeInOut, value: changeDueMessage)
9087 . onChange ( of: textFieldAmountInput) { _ in
@@ -98,29 +95,6 @@ struct PointOfSaleCollectCashView: View {
9895 }
9996}
10097
101- @available ( iOS 17 . 0 , * )
102- private extension PointOfSaleCollectCashView {
103- @ViewBuilder
104- var navigationHeader : some View {
105- HStack ( alignment: . top) {
106- Image ( systemName: " chevron.backward " )
107- . font ( . posBodyLargeBold, maximumContentSizeCategory: . accessibilityLarge)
108- DynamicVStack ( horizontalAlignment: . leading, spacing: Constants . navigationButtonSpacing) {
109- Text ( Localization . backNavigationTitle)
110- . font ( . posHeading)
111- . accessibilityAddTraits ( . isHeader)
112- if dynamicTypeSize. isAccessibilitySize {
113- Spacer ( )
114- }
115- Text ( formattedOrderTotal)
116- . font ( . posBodyLargeRegular( ) )
117- }
118- . padding ( . top, - Constants. navigationButtonSpacing)
119- }
120- . foregroundColor ( navigationForegroundColor)
121- }
122- }
123-
12498@available ( iOS 17 . 0 , * )
12599private extension PointOfSaleCollectCashView {
126100 private func submitCashAmount( ) async {
@@ -170,10 +144,6 @@ private extension PointOfSaleCollectCashView {
170144 . posSurface
171145 }
172146
173- private var navigationForegroundColor : Color {
174- isLoading ? . posDisabledContainer : . primary
175- }
176-
177147 enum Localization {
178148 static let backNavigationTitle = NSLocalizedString (
179149 " pointOfSale.cashview.back.navigation.title " ,
0 commit comments