Skip to content

Commit 3554a40

Browse files
committed
Integrate POSCatalogLoadingView in PointOfSaleDashboardView
1 parent 09818aa commit 3554a40

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Modules/Sources/PointOfSale/Presentation/PointOfSaleDashboardView.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ struct PointOfSaleDashboardView: View {
66
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
77
@Environment(\.posAnalytics) private var analytics
88
@Environment(\.posExternalViews) private var externalViews
9+
@Environment(\.dismiss) private var dismiss
910

1011
@State private var showExitPOSModal: Bool = false
1112
@State private var showSupport: Bool = false
1213
@State private var showDocumentation: Bool = false
1314
@State private var showSettings: Bool = false
1415
@State private var waitingTimeTracker: WaitingTimeTracker?
1516

17+
let animation: POSLoadingAnimation
18+
1619
@State private var floatingSize: CGSize = .zero
1720

1821
private var viewStateCoordinator: PointOfSaleViewStateCoordinator {
@@ -42,6 +45,7 @@ struct PointOfSaleDashboardView: View {
4245
case loading
4346
case ineligible(reason: POSIneligibleReason)
4447
case error(PointOfSaleErrorState)
48+
case catalogSyncing
4549
case content
4650
case unsupportedWidth
4751
}
@@ -50,7 +54,8 @@ struct PointOfSaleDashboardView: View {
5054
PointOfSaleDashboardViewHelper.determineViewState(
5155
eligibilityState: posModel.entryPointController.eligibilityState,
5256
itemsContainerState: itemsViewState.containerState,
53-
horizontalSizeClass: horizontalSizeClass
57+
horizontalSizeClass: horizontalSizeClass,
58+
catalogSyncState: posModel.catalogSyncState
5459
)
5560
}
5661

@@ -59,7 +64,7 @@ struct PointOfSaleDashboardView: View {
5964
ZStack(alignment: .bottomLeading) {
6065
switch viewState {
6166
case .loading:
62-
PointOfSaleLoadingView()
67+
PointOfSaleLoadingView(animation: animation)
6368
.transition(.opacity)
6469
.ignoresSafeArea()
6570
case .ineligible(let reason):
@@ -82,6 +87,12 @@ struct PointOfSaleDashboardView: View {
8287
}
8388
}
8489
})
90+
case .catalogSyncing:
91+
POSCatalogLoadingView(animation: animation) {
92+
dismiss()
93+
}
94+
.transition(.opacity)
95+
.ignoresSafeArea()
8596
case .content:
8697
contentView
8798
.accessibilitySortPriority(2)
@@ -273,19 +284,21 @@ private extension PointOfSaleDashboardView {
273284
#if DEBUG
274285

275286
#Preview("Container loading state") {
287+
@Previewable @Namespace var namespace
276288
return NavigationStack {
277-
PointOfSaleDashboardView()
289+
PointOfSaleDashboardView(animation: .init(namespace: namespace))
278290
.environment(POSPreviewHelpers.makePreviewAggregateModel())
279291
.environmentObject(POSModalManager())
280292
}
281293
}
282294

283295
#Preview("Content loading state") {
296+
@Previewable @Namespace var namespace
284297
let itemsController = PointOfSalePreviewItemsController()
285298
itemsController.itemsViewState = .init(containerState: .content, itemsStack: .init(root: .loading([]), itemStates: [:]))
286299
let posModel = POSPreviewHelpers.makePreviewAggregateModel(itemsController: itemsController)
287300
return NavigationStack {
288-
PointOfSaleDashboardView()
301+
PointOfSaleDashboardView(animation: .init(namespace: namespace))
289302
.environment(posModel)
290303
.environmentObject(POSModalManager())
291304
}

0 commit comments

Comments
 (0)