From b169f7ae00c985e48235be101eb4147c24c6c514 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 25 Feb 2025 14:19:46 +0530 Subject: [PATCH] Make `destinationAddressStatus` optional and wait for the remote response. --- .../WooShippingCreateLabelsView.swift | 13 ++++++++----- .../WooShippingCreateLabelsViewModel.swift | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift index 735083987aa..dff61fb6687 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift @@ -312,13 +312,16 @@ private extension WooShippingCreateLabelsView { } /// View showing the address verification status for a destination address. + @ViewBuilder var addressVerificationLabel: some View { - HStack(spacing: 4) { - Image(systemName: isDestinationAddressVerified ? "checkmark.circle" : "exclamationmark.circle") - Text(Localization.AddressVerification.label(for: viewModel.destinationAddressStatus)) + if let destinationAddressStatus = viewModel.destinationAddressStatus { + HStack(spacing: 4) { + Image(systemName: isDestinationAddressVerified ? "checkmark.circle" : "exclamationmark.circle") + Text(Localization.AddressVerification.label(for: destinationAddressStatus)) + } + .font(.subheadline) + .foregroundStyle(isDestinationAddressVerified ? Layout.green : Layout.red) } - .font(.subheadline) - .foregroundStyle(isDestinationAddressVerified ? Layout.green : Layout.red) } /// View showing a notice about the destination address verification status. diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsViewModel.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsViewModel.swift index 184a02cf9d5..36bcb0601c7 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsViewModel.swift @@ -73,9 +73,9 @@ final class WooShippingCreateLabelsViewModel: ObservableObject { case missing } - // TODO: Add support for updating the destination address status when it is edited or verified remotely. + // TODO: Add support for updating the destination address status when it is edited. /// The current destination address status. - @Published private(set) var destinationAddressStatus: DestinationAddressStatus = .unverified + @Published private(set) var destinationAddressStatus: DestinationAddressStatus? /// This property can be set to display a notice with the provided label about the destination address status. @Published var destinationAddressStatusNoticeLabel: String? @@ -383,6 +383,7 @@ private extension WooShippingCreateLabelsViewModel { func observeDestinationAddressStatus() { /// Set the notice when the destination address status changes. $destinationAddressStatus + .compactMap { $0 } .map { status in switch status { case .verified: