Skip to content

Commit 644c9ee

Browse files
committed
Merge PointOfSaleLoading view and POSCatalogLoadingView
1 parent 3f3b654 commit 644c9ee

File tree

4 files changed

+65
-105
lines changed

4 files changed

+65
-105
lines changed
Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import SwiftUI
22

3-
struct POSLoadingAnimation {
4-
let namespace: Namespace.ID
5-
let progressTransitionId: String = "pos_card_present_payment_payment_alert_icon_matched_geometry_id"
6-
}
7-
83
struct PointOfSaleLoadingView: View {
9-
private let animation: POSLoadingAnimation
4+
private let isCatalogSyncing: Bool
5+
private let onExit: (() -> Void)?
106

11-
init(animation: POSLoadingAnimation) {
12-
self.animation = animation
7+
init(isCatalogSyncing: Bool = false, onExit: (() -> Void)? = nil) {
8+
self.isCatalogSyncing = isCatalogSyncing
9+
self.onExit = onExit
1310
}
1411

1512
var body: some View {
@@ -19,8 +16,29 @@ struct PointOfSaleLoadingView: View {
1916
Spacer()
2017
ProgressView()
2118
.progressViewStyle(POSProgressViewStyle())
22-
.matchedGeometryEffect(id: animation.progressTransitionId, in: animation.namespace, properties: .position)
23-
Spacer()
19+
20+
if isCatalogSyncing {
21+
Spacer().frame(height: POSSpacing.large * 2)
22+
Text(Localization.syncingTitle)
23+
.font(.posHeadingBold)
24+
Spacer()
25+
VStack(spacing: POSSpacing.medium) {
26+
Button {
27+
onExit?()
28+
} label: {
29+
Text(Localization.exitButtonTitle)
30+
.font(.posBodySmallBold(underline: true))
31+
.foregroundStyle(Color.posOnSurface)
32+
}
33+
34+
Text(Localization.exitButtonDescription)
35+
.font(.posCaptionRegular)
36+
.foregroundStyle(Color.posOnSurfaceVariantLowest)
37+
}
38+
.padding(.bottom, POSPadding.large)
39+
} else {
40+
Spacer()
41+
}
2442
}
2543
.multilineTextAlignment(.center)
2644
Spacer()
@@ -30,6 +48,31 @@ struct PointOfSaleLoadingView: View {
3048
}
3149

3250
#Preview {
33-
@Previewable @Namespace var namespace
34-
PointOfSaleLoadingView(animation: .init(namespace: namespace))
51+
PointOfSaleLoadingView()
52+
}
53+
54+
#Preview("Catalog Syncing") {
55+
PointOfSaleLoadingView(isCatalogSyncing: true) {}
56+
}
57+
58+
private extension PointOfSaleLoadingView {
59+
struct Localization {
60+
static let syncingTitle = NSLocalizedString(
61+
"pointOfSale.catalogLoadingView.title",
62+
value: "Syncing catalog",
63+
comment: "A title of a full screen view that is displayed while the POS catalog is being synced."
64+
)
65+
66+
static let exitButtonTitle = NSLocalizedString(
67+
"pointOfSale.catalogLoadingView.exitButton.title",
68+
value: "Exit POS",
69+
comment: "A button that exits POS."
70+
)
71+
72+
static let exitButtonDescription = NSLocalizedString(
73+
"pointOfSale.catalogLoadingView.exitButton.description",
74+
value: "Syncing will continue in the background.",
75+
comment: "A description within a full screen loading view for POS catalog."
76+
)
77+
}
3578
}

Modules/Sources/PointOfSale/Presentation/POSCatalogLoadingView.swift

Lines changed: 0 additions & 71 deletions
This file was deleted.

Modules/Sources/PointOfSale/Presentation/PointOfSaleDashboardView.swift

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ struct PointOfSaleDashboardView: View {
1414
@State private var showSettings: Bool = false
1515
@State private var waitingTimeTracker: WaitingTimeTracker?
1616

17-
let animation: POSLoadingAnimation
18-
1917
@State private var floatingSize: CGSize = .zero
2018

2119
private var viewStateCoordinator: PointOfSaleViewStateCoordinator {
@@ -62,17 +60,12 @@ struct PointOfSaleDashboardView: View {
6260
ZStack(alignment: .bottomLeading) {
6361
switch viewState {
6462
case .loading(let isCatalogSyncing):
65-
if isCatalogSyncing {
66-
POSCatalogLoadingView(animation: animation) {
67-
dismiss()
68-
}
69-
.transition(.opacity)
70-
.ignoresSafeArea()
71-
} else {
72-
PointOfSaleLoadingView(animation: animation)
73-
.transition(.opacity)
74-
.ignoresSafeArea()
75-
}
63+
PointOfSaleLoadingView(
64+
isCatalogSyncing: isCatalogSyncing,
65+
onExit: { dismiss() }
66+
)
67+
.transition(.opacity)
68+
.ignoresSafeArea()
7669
case .ineligible(let reason):
7770
POSIneligibleView(reason: reason, onRefresh: {
7871
try await posModel.entryPointController.refreshEligibility(reason: reason)
@@ -284,21 +277,19 @@ private extension PointOfSaleDashboardView {
284277
#if DEBUG
285278

286279
#Preview("Container loading state") {
287-
@Previewable @Namespace var namespace
288280
return NavigationStack {
289-
PointOfSaleDashboardView(animation: .init(namespace: namespace))
281+
PointOfSaleDashboardView()
290282
.environment(POSPreviewHelpers.makePreviewAggregateModel())
291283
.environmentObject(POSModalManager())
292284
}
293285
}
294286

295287
#Preview("Content loading state") {
296-
@Previewable @Namespace var namespace
297288
let itemsController = PointOfSalePreviewItemsController()
298289
itemsController.itemsViewState = .init(containerState: .content, itemsStack: .init(root: .loading([]), itemStates: [:]))
299290
let posModel = POSPreviewHelpers.makePreviewAggregateModel(itemsController: itemsController)
300291
return NavigationStack {
301-
PointOfSaleDashboardView(animation: .init(namespace: namespace))
292+
PointOfSaleDashboardView()
302293
.environment(posModel)
303294
.environmentObject(POSModalManager())
304295
}

Modules/Sources/PointOfSale/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public struct PointOfSaleEntryPointView: View {
2626
@State private var posEntryPointController: POSEntryPointController
2727
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
2828

29-
@Namespace private var namespace
30-
private var animation: POSLoadingAnimation { .init(namespace: namespace) }
31-
3229
private let onPointOfSaleModeActiveStateChange: ((Bool) -> Void)
3330
private let itemsController: PointOfSaleItemsControllerProtocol
3431
private let purchasableItemsSearchController: PointOfSaleSearchingItemsControllerProtocol
@@ -140,10 +137,10 @@ public struct PointOfSaleEntryPointView: View {
140137
public var body: some View {
141138
Group {
142139
if let posModel {
143-
PointOfSaleDashboardView(animation: animation)
140+
PointOfSaleDashboardView()
144141
.environment(posModel)
145142
} else {
146-
PointOfSaleLoadingView(animation: animation)
143+
PointOfSaleLoadingView()
147144
}
148145
}
149146
.task {

0 commit comments

Comments
 (0)