@@ -148,12 +148,10 @@ private extension WooShippingCreateLabelsView {
148148 Text ( Localization . BottomSheet. shipmentDetails)
149149 . foregroundStyle ( Color ( . primary) )
150150 . bold ( )
151- if viewModel. showAddressVerificationNotice {
152- addressVerificationNotice
153- . onTapGesture {
154- // TODO: Start address editing/verification flow if needed (if destination address is unverified).
155- }
156- }
151+ addressVerificationNotice ( with: viewModel. destinationAddressStatusNoticeLabel)
152+ . onTapGesture {
153+ // TODO: Start address editing/verification flow if needed (if destination address is unverified).
154+ }
157155 }
158156 }
159157
@@ -314,26 +312,29 @@ private extension WooShippingCreateLabelsView {
314312 }
315313
316314 /// View showing a notice about the destination address verification status.
317- var addressVerificationNotice : some View {
318- HStack ( spacing: 8 ) {
319- Image ( systemName: isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
320- Text ( Localization . AddressVerification. noticeLabel ( for: viewModel. destinationAddressStatus) )
321- . frame ( maxWidth: . infinity, alignment: . leading)
322- Button {
323- withAnimation {
324- viewModel. showAddressVerificationNotice = false
315+ @ViewBuilder
316+ func addressVerificationNotice( with label: String ? ) -> some View {
317+ if let label = viewModel. destinationAddressStatusNoticeLabel {
318+ HStack ( spacing: 8 ) {
319+ Image ( systemName: isDestinationAddressVerified ? " checkmark.circle " : " exclamationmark.circle " )
320+ Text ( label)
321+ . frame ( maxWidth: . infinity, alignment: . leading)
322+ Button {
323+ withAnimation {
324+ viewModel. destinationAddressStatusNoticeLabel = nil
325+ }
326+ } label: {
327+ Image ( systemName: " xmark " )
328+ . renderedIf ( !isDestinationAddressVerified)
325329 }
326- } label: {
327- Image ( systemName: " xmark " )
328- . renderedIf ( !isDestinationAddressVerified)
329330 }
331+ . font ( . subheadline)
332+ . foregroundStyle ( isDestinationAddressVerified ? Layout . green : Layout . red)
333+ . padding ( . horizontal, 16 )
334+ . padding ( . vertical, 12 )
335+ . background ( RoundedRectangle ( cornerRadius: Layout . cornerRadius)
336+ . fill ( Color ( uiColor: isDestinationAddressVerified ? . withColorStudio( . green, shade: . shade0) : . withColorStudio( . red, shade: . shade0) ) ) )
330337 }
331- . font ( . subheadline)
332- . foregroundStyle ( isDestinationAddressVerified ? Layout . green : Layout . red)
333- . padding ( . horizontal, 16 )
334- . padding ( . vertical, 12 )
335- . background ( RoundedRectangle ( cornerRadius: Layout . cornerRadius)
336- . fill ( Color ( uiColor: isDestinationAddressVerified ? . withColorStudio( . green, shade: . shade0) : . withColorStudio( . red, shade: . shade0) ) ) )
337338 }
338339}
339340
@@ -449,25 +450,6 @@ private extension WooShippingCreateLabelsView {
449450 static let missing = NSLocalizedString ( " wooShipping.createLabels.addressVerification.missing " ,
450451 value: " Missing address " ,
451452 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- }
462- static let destinationVerified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.destinationVerified " ,
463- value: " Verified destination address " ,
464- comment: " Notice when a destination address is verified on the shipping label creation screen " )
465- static let destinationUnverified = NSLocalizedString ( " wooShipping.createLabels.addressVerification.destinationUnverified " ,
466- value: " Destination address unverified " ,
467- 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 " )
471453 }
472454 }
473455}
0 commit comments