@@ -20,6 +20,7 @@ struct WooShippingEditAddressView: View {
2020 @State private var previousFocusedField : WooShippingAddressFieldType ?
2121
2222 @Environment ( \. dismiss) private var dismiss
23+ @Environment ( \. sizeCategory) private var sizeCategory
2324
2425 @State private var isPresentingCountrySelector : Bool = false
2526 @State private var isPresentingStateSelector : Bool = false
@@ -77,6 +78,10 @@ struct WooShippingEditAddressView: View {
7778 . font ( . subheadline)
7879 . tint ( Color ( . accent) )
7980 }
81+
82+ if sizeCategory. isAccessibilityCategory {
83+ ctaFooter ( isScrollViewEmbedded: true )
84+ }
8085 }
8186 . padding ( )
8287 . onChange ( of: focusedField) { newField in
@@ -86,11 +91,6 @@ struct WooShippingEditAddressView: View {
8691 previousFocusedField = newField
8792 }
8893 . toolbar {
89- ToolbarItem ( placement: . cancellationAction) {
90- Button ( Localization . cancel) {
91- dismiss ( )
92- }
93- }
9494 ToolbarItemGroup ( placement: . keyboard) {
9595 Button ( action: {
9696 focusPreviousField ( )
@@ -113,71 +113,54 @@ struct WooShippingEditAddressView: View {
113113 }
114114 }
115115 }
116- . sheet ( isPresented: $isPresentingCountrySelector) {
117- NavigationStack {
118- FilterListSelector ( viewModel: viewModel. countrySelectorVM)
119- . navigationBarTitleDisplayMode ( . inline)
120- . toolbar {
121- ToolbarItem ( placement: . confirmationAction) {
122- Button {
123- isPresentingCountrySelector = false
124- } label: {
125- Text ( Localization . done)
126- . bold ( )
127- }
128- }
129- }
130- }
131- }
132- . sheet ( isPresented: $isPresentingStateSelector) {
133- NavigationStack {
134- FilterListSelector ( viewModel: viewModel. stateSelectorVM)
135- . navigationBarTitleDisplayMode ( . inline)
136- . toolbar {
137- ToolbarItem ( placement: . confirmationAction) {
138- Button {
139- isPresentingStateSelector = false
140- } label: {
141- Text ( Localization . done)
142- . bold ( )
143- }
144- }
145- }
116+ }
117+ . toolbar {
118+ ToolbarItem ( placement: . cancellationAction) {
119+ Button ( Localization . cancel) {
120+ dismiss ( )
146121 }
147122 }
148123 }
149124 . safeAreaInset ( edge: . bottom) {
150- VStack ( spacing: . zero) {
151- Divider ( ) . ignoresSafeArea ( edges: [ . horizontal] )
152- VStack ( spacing: Constants . verticalSpacing) {
153- HStack {
154- Image ( systemName: viewModel. status == . verified ? " checkmark.circle " : " exclamationmark.circle " )
155- Text ( viewModel. statusLabel)
156- }
157- . font ( . subheadline)
158- . foregroundStyle ( viewModel. status == . verified ? Constants . green : Constants . red)
159- Button ( Localization . Button. label ( for: viewModel. status) ) {
160- switch viewModel. status {
161- case . verified:
162- dismiss ( )
163- case . unverified:
164- Task { @MainActor in
165- await viewModel. remotelyValidateAddress ( )
125+ if !sizeCategory. isAccessibilityCategory {
126+ ctaFooter ( isScrollViewEmbedded: false )
127+ }
128+ }
129+ . sheet ( item: $viewModel. normalizeAddressVM) { viewModel in
130+ NavigationStack {
131+ WooShippingNormalizeAddressView ( viewModel: viewModel)
132+ }
133+ }
134+ . sheet ( isPresented: $isPresentingCountrySelector) {
135+ NavigationStack {
136+ FilterListSelector ( viewModel: viewModel. countrySelectorVM)
137+ . navigationBarTitleDisplayMode ( . inline)
138+ . toolbar {
139+ ToolbarItem ( placement: . confirmationAction) {
140+ Button {
141+ isPresentingCountrySelector = false
142+ } label: {
143+ Text ( Localization . done)
144+ . bold ( )
166145 }
167- case . missingInformation:
168- break
169146 }
170147 }
171- . buttonStyle ( PrimaryLoadingButtonStyle ( isLoading: viewModel. isLoading) )
172- . disabled ( viewModel. status == . missingInformation)
173- }
174- . padding ( )
175148 }
176- . background ( Color ( uiColor: . systemBackground) )
177149 }
178- . sheet ( item : $viewModel . normalizeAddressVM ) { viewModel in
150+ . sheet ( isPresented : $isPresentingStateSelector ) {
179151 NavigationStack {
180- WooShippingNormalizeAddressView ( viewModel: viewModel)
152+ FilterListSelector ( viewModel: viewModel. stateSelectorVM)
153+ . navigationBarTitleDisplayMode ( . inline)
154+ . toolbar {
155+ ToolbarItem ( placement: . confirmationAction) {
156+ Button {
157+ isPresentingStateSelector = false
158+ } label: {
159+ Text ( Localization . done)
160+ . bold ( )
161+ }
162+ }
163+ }
181164 }
182165 }
183166 . alert (
@@ -206,6 +189,44 @@ struct WooShippingEditAddressView: View {
206189 )
207190 }
208191
192+ private func ctaFooter( isScrollViewEmbedded: Bool ) -> some View {
193+ VStack ( spacing: . zero) {
194+ Divider ( )
195+ . ignoresSafeArea ( edges: [ . horizontal] )
196+ . padding (
197+ /// When embedded in scroll view
198+ /// we use a negative value to neglect the parent padding for the divider
199+ isScrollViewEmbedded ? . horizontal : [ ] ,
200+ - Constants. defaultPadding
201+ )
202+
203+ VStack ( spacing: Constants . verticalSpacing) {
204+ HStack {
205+ Image ( systemName: viewModel. status == . verified ? " checkmark.circle " : " exclamationmark.circle " )
206+ Text ( viewModel. statusLabel)
207+ }
208+ . font ( . subheadline)
209+ . foregroundStyle ( viewModel. status == . verified ? Constants . green : Constants . red)
210+ Button ( Localization . Button. label ( for: viewModel. status) ) {
211+ switch viewModel. status {
212+ case . verified:
213+ dismiss ( )
214+ case . unverified:
215+ Task { @MainActor in
216+ await viewModel. remotelyValidateAddress ( )
217+ }
218+ case . missingInformation:
219+ break
220+ }
221+ }
222+ . buttonStyle ( PrimaryLoadingButtonStyle ( isLoading: viewModel. isLoading) )
223+ . disabled ( viewModel. status == . missingInformation)
224+ }
225+ . padding ( isScrollViewEmbedded ? . vertical : . all)
226+ }
227+ . background ( Color ( uiColor: . systemBackground) )
228+ }
229+
209230 private struct AddressTextField : View {
210231 @ObservedObject var field : WooShippingAddressField
211232
@@ -345,6 +366,7 @@ extension WooShippingEditAddressView {
345366private extension WooShippingEditAddressView {
346367 enum Constants {
347368 static let verticalSpacing : CGFloat = 16
369+ static let defaultPadding : CGFloat = 16
348370 static let innerSpacing : CGFloat = 8
349371 static let extraPadding : CGFloat = 24
350372 static let cornerRadius : CGFloat = 8
0 commit comments