Skip to content

Commit 65da4bd

Browse files
committed
Use view model to handle whether the address verification notice is displayed
1 parent e55ee94 commit 65da4bd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsView.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ struct WooShippingCreateLabelsView: View {
3737
/// Whether the origin address list sheet is presented.
3838
@State private var isOriginAddressListPresented = false
3939

40-
/// Whether the address verification notice is displayed.
41-
@State private var isAddressVerificationNoticePresented = true
42-
4340
var body: some View {
4441
NavigationStack {
4542
ScrollView {
@@ -82,9 +79,7 @@ struct WooShippingCreateLabelsView: View {
8279
Text(Localization.BottomSheet.shipmentDetails)
8380
.foregroundStyle(Color(.primary))
8481
.bold()
85-
// TODO: Only display the notice if the address is unverified, or
86-
// if the address was just verified (and then auto-dismiss it after a couple seconds).
87-
if isAddressVerificationNoticePresented {
82+
if viewModel.showAddressVerificationNotice {
8883
addressVerificationNotice
8984
.onTapGesture {
9085
// TODO: Start address editing/verification flow if needed (if destination address is unverified).
@@ -301,7 +296,7 @@ private extension WooShippingCreateLabelsView {
301296
.frame(maxWidth: .infinity, alignment: .leading)
302297
Button {
303298
withAnimation {
304-
isAddressVerificationNoticePresented = false
299+
viewModel.showAddressVerificationNotice = false
305300
}
306301
} label: {
307302
Image(systemName: "xmark")

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingCreateLabelsViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ final class WooShippingCreateLabelsViewModel: ObservableObject {
6969
/// Whether the destination address is verified.
7070
@Published private(set) var isDestinationAddressVerified: Bool = false
7171

72+
// TODO: Set to false if the destination address is already verified.
73+
// TODO: Set to true for a couple seconds after the destination address is verified.
74+
/// Whether the destination address verification notice is displayed.
75+
@Published var showAddressVerificationNotice = true
76+
7277
/// Shipping lines for the order, with formatted amount.
7378
let shippingLines: [WooShipping_ShippingLineViewModel]
7479

0 commit comments

Comments
 (0)