Skip to content

Commit b5d85a7

Browse files
[Shipping Labels] Delay error notice (#15342)
2 parents 44a533f + 133d31f commit b5d85a7

File tree

2 files changed

+57
-41
lines changed

2 files changed

+57
-41
lines changed

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

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

40+
@State private var isReadyToShowErrorNotice = false
41+
4042
@State private var showingCustomsForm = false
4143

4244
/// Whether the destination address is verified.
@@ -199,48 +201,57 @@ private extension WooShippingCreateLabelsView {
199201
.foregroundStyle(Color(.primary))
200202
.bold()
201203

202-
// Unverified notice for origin address
203-
if let originAddressUnverifiedNoticeLabel = viewModel.originAddressUnverifiedNoticeLabel {
204-
verificationNotice(with: originAddressUnverifiedNoticeLabel,
205-
isVerified: false,
206-
onDismiss: {
207-
withAnimation {
208-
viewModel.originAddressUnverifiedNoticeLabel = nil
209-
}
210-
},
211-
onTap: {
212-
viewModel.editSelectedOriginAddress()
213-
})
214-
}
204+
if isReadyToShowErrorNotice {
205+
// Unverified notice for origin address
206+
if let originAddressUnverifiedNoticeLabel = viewModel.originAddressUnverifiedNoticeLabel {
207+
verificationNotice(with: originAddressUnverifiedNoticeLabel,
208+
isVerified: false,
209+
onDismiss: {
210+
withAnimation {
211+
viewModel.originAddressUnverifiedNoticeLabel = nil
212+
}
213+
},
214+
onTap: {
215+
viewModel.editSelectedOriginAddress()
216+
})
217+
}
215218

216-
// Verification notice for destination address
217-
if let destinationAddressStatusNoticeLabel = viewModel.destinationAddressStatusNoticeLabel {
218-
verificationNotice(with: destinationAddressStatusNoticeLabel,
219-
isVerified: isDestinationAddressVerified,
220-
onDismiss: {
221-
withAnimation {
222-
viewModel.destinationAddressStatusNoticeLabel = nil
223-
}
224-
},
225-
onTap: {
226-
if !isDestinationAddressVerified {
227-
viewModel.editDestinationAddress()
228-
}
229-
})
230-
}
219+
// Verification notice for destination address
220+
if let destinationAddressStatusNoticeLabel = viewModel.destinationAddressStatusNoticeLabel {
221+
verificationNotice(with: destinationAddressStatusNoticeLabel,
222+
isVerified: isDestinationAddressVerified,
223+
onDismiss: {
224+
withAnimation {
225+
viewModel.destinationAddressStatusNoticeLabel = nil
226+
}
227+
},
228+
onTap: {
229+
if !isDestinationAddressVerified {
230+
viewModel.editDestinationAddress()
231+
}
232+
})
233+
}
231234

232-
// Verification notice for missing ITN in customs form
233-
if let itnMissingNoticeLabel = viewModel.itnMissingNoticeLabel {
234-
verificationNotice(with: itnMissingNoticeLabel,
235-
isVerified: false,
236-
onDismiss: {
237-
withAnimation {
238-
viewModel.itnMissingNoticeLabel = nil
239-
}
240-
},
241-
onTap: {
242-
showingCustomsForm = true
243-
})
235+
// Verification notice for missing ITN in customs form
236+
if let itnMissingNoticeLabel = viewModel.itnMissingNoticeLabel {
237+
verificationNotice(with: itnMissingNoticeLabel,
238+
isVerified: false,
239+
onDismiss: {
240+
withAnimation {
241+
viewModel.itnMissingNoticeLabel = nil
242+
}
243+
},
244+
onTap: {
245+
showingCustomsForm = true
246+
})
247+
}
248+
}
249+
}
250+
.onAppear {
251+
/// A brief delay in requesting user attention after the UI loads
252+
/// to avoid overwhelming them with too many changes at once when opening the screen.
253+
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
254+
self.isReadyToShowErrorNotice = true
244255
}
245256
}
246257
}

WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/ExpandableBottomSheet.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ struct ExpandableBottomSheet<AlwaysVisibleContent, ExpandableContent>: View wher
7979
// Always visible content
8080
alwaysVisibleContent()
8181
.trackSize(size: $fixedContentSize)
82-
.onChange(of: fixedContentSize, perform: { _ in
82+
.onChange(of: fixedContentSize, perform: { [fixedContentSize] _ in
83+
guard fixedContentSize.width > 0,
84+
fixedContentSize.height > 0 else {
85+
// No animation for initial load
86+
return panelHeight = calculateHeight()
87+
}
8388
withAnimation {
8489
panelHeight = calculateHeight()
8590
}

0 commit comments

Comments
 (0)