@@ -37,6 +37,11 @@ struct WooShippingCreateLabelsView: View {
3737 /// Whether the origin address list sheet is presented.
3838 @State private var isOriginAddressListPresented = false
3939
40+ /// Whether the destination address is verified.
41+ private var isDestinationAddressVerified : Bool {
42+ viewModel. destinationAddressStatus == . verified
43+ }
44+
4045 var body : some View {
4146 NavigationStack {
4247 ScrollView {
@@ -298,39 +303,37 @@ private extension WooShippingCreateLabelsView {
298303 . disabled ( !viewModel. isPurchaseButtonEnabled)
299304 }
300305
301- /// View showing the address verification status.
306+ /// View showing the address verification status for a destination address .
302307 var addressVerificationLabel : some View {
303308 HStack ( spacing: 4 ) {
304- Image ( systemName: viewModel. isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
305- Text ( viewModel. isDestinationAddressVerified
306- ? Localization . AddressVerification. verified : Localization . AddressVerification. unverified)
309+ Image ( systemName: isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
310+ Text ( Localization . AddressVerification. label ( for: viewModel. destinationAddressStatus) )
307311 }
308312 . font ( . subheadline)
309- . foregroundStyle ( viewModel . isDestinationAddressVerified ? Layout . green : Layout . red)
313+ . foregroundStyle ( isDestinationAddressVerified ? Layout . green : Layout . red)
310314 }
311315
312- /// View showing a notice about the address verification status.
316+ /// View showing a notice about the destination address verification status.
313317 var addressVerificationNotice : some View {
314318 HStack ( spacing: 8 ) {
315- Image ( systemName: viewModel. isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
316- Text ( viewModel. isDestinationAddressVerified
317- ? Localization . AddressVerification. destinationVerified : Localization . AddressVerification. destinationUnverified)
319+ Image ( systemName: isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
320+ Text ( Localization . AddressVerification. noticeLabel ( for: viewModel. destinationAddressStatus) )
318321 . frame ( maxWidth: . infinity, alignment: . leading)
319322 Button {
320323 withAnimation {
321324 viewModel. showAddressVerificationNotice = false
322325 }
323326 } label: {
324327 Image ( systemName: " xmark " )
325- . renderedIf ( !viewModel . isDestinationAddressVerified)
328+ . renderedIf ( !isDestinationAddressVerified)
326329 }
327330 }
328331 . font ( . subheadline)
329- . foregroundStyle ( viewModel . isDestinationAddressVerified ? Layout . green : Layout . red)
332+ . foregroundStyle ( isDestinationAddressVerified ? Layout . green : Layout . red)
330333 . padding ( . horizontal, 16 )
331334 . padding ( . vertical, 12 )
332335 . background ( RoundedRectangle ( cornerRadius: Layout . cornerRadius)
333- . fill ( Color ( uiColor: viewModel . isDestinationAddressVerified ? . withColorStudio( . green, shade: . shade0) : . withColorStudio( . red, shade: . shade0) ) ) )
336+ . fill ( Color ( uiColor: isDestinationAddressVerified ? . withColorStudio( . green, shade: . shade0) : . withColorStudio( . red, shade: . shade0) ) ) )
334337 }
335338}
336339
@@ -427,18 +430,44 @@ private extension WooShippingCreateLabelsView {
427430 }
428431
429432 enum AddressVerification {
433+ static func label( for status: WooShippingCreateLabelsViewModel . DestinationAddressStatus ) -> String {
434+ switch status {
435+ case . verified:
436+ return verified
437+ case . unverified:
438+ return unverified
439+ case . missing:
440+ return missing
441+ }
442+ }
430443 static let verified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.verified " ,
431444 value: " Address verified " ,
432445 comment: " Label when an address is verified on the shipping label creation screen " )
433446 static let unverified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.unverified " ,
434447 value: " Unverified address " ,
435448 comment: " Label when an address is unverified on the shipping label creation screen " )
449+ static let missing = NSLocalizedString ( " wooShipping.createLabels.addressVerification.missing " ,
450+ value: " Missing address " ,
451+ comment: " Label when an address is missing on the shipping label creation screen " )
452+ static func noticeLabel( for status: WooShippingCreateLabelsViewModel . DestinationAddressStatus ) -> String {
453+ switch status {
454+ case . verified:
455+ return destinationVerified
456+ case . unverified:
457+ return destinationUnverified
458+ case . missing:
459+ return destinationMissing
460+ }
461+ }
436462 static let destinationVerified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.destinationVerified " ,
437463 value: " Verified destination address " ,
438464 comment: " Notice when a destination address is verified on the shipping label creation screen " )
439465 static let destinationUnverified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.destinationUnverified " ,
440466 value: " Destination address unverified " ,
441467 comment: " Notice when a destination address is unverified on the shipping label creation screen " )
468+ static let destinationMissing = NSLocalizedString ( " wooShipping.createLabels.addressVerification.destinationMissing " ,
469+ value: " Destination address missing " ,
470+ comment: " Notice when a destination address is missing on the shipping label creation screen " )
442471 }
443472 }
444473}
0 commit comments