Skip to content

Commit 557a28d

Browse files
committed
Replace receipt page header with POSPageHeaderView with adjusted layout.
1 parent fd65fee commit 557a28d

File tree

1 file changed

+39
-49
lines changed

1 file changed

+39
-49
lines changed

WooCommerce/Classes/POS/Presentation/Reusable Views/POSSendReceiptView.swift

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,51 @@ struct POSSendReceiptView: View {
1818

1919
var body: some View {
2020
VStack(alignment: .center, spacing: conditionalPadding(8)) {
21-
HStack {
22-
Button(action: {
23-
withAnimation {
24-
isShowingSendReceiptView = false
25-
isTextFieldFocused = false
26-
}
27-
}, label: {
28-
HStack {
29-
Image(systemName: "chevron.backward")
30-
Text(Localization.emailReceiptNavigationText)
21+
POSPageHeaderView(title: Localization.emailReceiptNavigationText,
22+
backButtonConfiguration: .init(state: isLoading ? .disabled: .enabled,
23+
action: {
24+
withAnimation {
25+
isShowingSendReceiptView = false
26+
isTextFieldFocused = false
27+
}
28+
}))
29+
30+
VStack(alignment: .center, spacing: conditionalPadding(8)) {
31+
TextField(Localization.textfieldPlaceholder, text: $textFieldInput)
32+
.dynamicTypeSize(...DynamicTypeSize.accessibility1)
33+
.keyboardType(.emailAddress)
34+
.textInputAutocapitalization(.never)
35+
.autocorrectionDisabled()
36+
.multilineTextAlignment(.center)
37+
.font(POSFontStyle.posBodyXLarge)
38+
.focused()
39+
.focused($isTextFieldFocused)
40+
.padding()
41+
.onSubmit {
42+
sendReceipt()
3143
}
32-
.font(.posHeading)
33-
.foregroundColor(.posOnSurface)
34-
.dynamicTypeSize(...DynamicTypeSize.accessibility3)
35-
.accessibilityAddTraits(.isHeader)
36-
})
37-
Spacer()
38-
}
39-
.buttonStyle(.plain)
40-
.disabled(isLoading)
4144

42-
TextField(Localization.textfieldPlaceholder, text: $textFieldInput)
43-
.dynamicTypeSize(...DynamicTypeSize.accessibility1)
44-
.keyboardType(.emailAddress)
45-
.textInputAutocapitalization(.never)
46-
.autocorrectionDisabled()
47-
.multilineTextAlignment(.center)
48-
.font(POSFontStyle.posBodyXLarge)
49-
.focused()
50-
.focused($isTextFieldFocused)
51-
.padding()
52-
.onSubmit {
53-
sendReceipt()
45+
if let errorMessage = errorMessage {
46+
Text(errorMessage)
47+
.font(POSFontStyle.posBodyLargeRegular())
48+
.foregroundColor(.red)
49+
.padding(.bottom, Constants.errorMessagePadding)
5450
}
5551

56-
if let errorMessage = errorMessage {
57-
Text(errorMessage)
58-
.font(POSFontStyle.posBodyLargeRegular())
59-
.foregroundColor(.red)
60-
.padding(.bottom, Constants.errorMessagePadding)
61-
}
62-
63-
Button(action: {
64-
sendReceipt()
65-
}, label: {
66-
Text(Localization.buttonTitle)
67-
})
68-
.buttonStyle(POSFilledButtonStyle(size: .normal, isLoading: isLoading))
69-
.dynamicTypeSize(...DynamicTypeSize.accessibility3)
70-
.frame(maxWidth: .infinity)
71-
.disabled(isLoading)
52+
Button(action: {
53+
sendReceipt()
54+
}, label: {
55+
Text(Localization.buttonTitle)
56+
})
57+
.buttonStyle(POSFilledButtonStyle(size: .normal, isLoading: isLoading))
58+
.dynamicTypeSize(...DynamicTypeSize.accessibility3)
59+
.frame(maxWidth: .infinity)
60+
.disabled(isLoading)
7261

73-
Spacer()
62+
Spacer()
63+
}
64+
.padding([.horizontal, .bottom])
7465
}
75-
.padding([.horizontal, .bottom])
7666
.animation(.easeInOut, value: errorMessage)
7767
.onChange(of: textFieldInput) { _ in
7868
errorMessage = nil

0 commit comments

Comments
 (0)