Skip to content

Commit 447fd5d

Browse files
committed
Allow user interactions on dashboard tabs and remove placeholder content per section per time range tab.
1 parent fb56e28 commit 447fd5d

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Stats v4/StoreStatsAndTopPerformersPeriodViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,15 @@ extension StoreStatsAndTopPerformersPeriodViewController {
176176
topPerformersPeriodViewController.displayGhostContent()
177177
}
178178

179-
/// Unlocks the and removes the Placeholder Content
179+
/// Removes the placeholder content for store stats.
180180
///
181-
func removeGhostContent() {
181+
func removeStoreStatsGhostContent() {
182182
storeStatsPeriodViewController.removeGhostContent()
183+
}
184+
185+
/// Removes the placeholder content for top performers.
186+
///
187+
func removeTopPerformersGhostContent() {
183188
topPerformersPeriodViewController.removeGhostContent()
184189
}
185190

WooCommerce/Classes/ViewRelated/Dashboard/Stats v4/StoreStatsAndTopPerformersViewController.swift

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ private extension StoreStatsAndTopPerformersViewController {
109109
defer {
110110
group.notify(queue: .main) { [weak self] in
111111
self?.isSyncing = false
112-
self?.removeGhostContent()
113112
self?.showSpinner(shouldShowSpinner: false)
114113
if let error = syncError {
115114
DDLogError("⛔️ Error loading dashboard: \(error)")
@@ -150,8 +149,12 @@ private extension StoreStatsAndTopPerformersViewController {
150149
// For tasks dispatched for each time period.
151150
let periodGroup = DispatchGroup()
152151

152+
// For tasks dispatched for store stats (order and visitor stats) for each time period.
153+
let periodStoreStatsGroup = DispatchGroup()
154+
153155
group.enter()
154156
periodGroup.enter()
157+
periodStoreStatsGroup.enter()
155158
self.syncStats(for: siteID,
156159
siteTimezone: timezoneForSync,
157160
timeRange: vc.timeRange,
@@ -165,10 +168,12 @@ private extension StoreStatsAndTopPerformersViewController {
165168
}
166169
group.leave()
167170
periodGroup.leave()
171+
periodStoreStatsGroup.leave()
168172
}
169173

170174
group.enter()
171175
periodGroup.enter()
176+
periodStoreStatsGroup.enter()
172177
self.syncSiteVisitStats(for: siteID,
173178
siteTimezone: timezoneForSync,
174179
timeRange: vc.timeRange,
@@ -179,6 +184,7 @@ private extension StoreStatsAndTopPerformersViewController {
179184
}
180185
group.leave()
181186
periodGroup.leave()
187+
periodStoreStatsGroup.leave()
182188
}
183189

184190
group.enter()
@@ -193,6 +199,8 @@ private extension StoreStatsAndTopPerformersViewController {
193199
}
194200
group.leave()
195201
periodGroup.leave()
202+
203+
vc.removeTopPerformersGhostContent()
196204
}
197205

198206
periodGroup.notify(queue: .main) {
@@ -203,6 +211,10 @@ private extension StoreStatsAndTopPerformersViewController {
203211
syncError = periodSyncError
204212
}
205213
}
214+
215+
periodStoreStatsGroup.notify(queue: .main) {
216+
vc.removeStoreStatsGhostContent()
217+
}
206218
}
207219
}
208220

@@ -224,27 +236,12 @@ private extension StoreStatsAndTopPerformersViewController {
224236
/// Displays the Ghost Placeholder whenever there is no visible data.
225237
///
226238
func ensureGhostContentIsDisplayed() {
227-
guard visibleChildViewController.shouldDisplayStoreStatsGhostContent else {
228-
return
239+
periodVCs.forEach { periodVC in
240+
guard periodVC.shouldDisplayStoreStatsGhostContent else {
241+
return
242+
}
243+
periodVC.displayGhostContent()
229244
}
230-
231-
displayGhostContent()
232-
}
233-
234-
/// Locks UI Interaction and displays Ghost Placeholder animations.
235-
///
236-
func displayGhostContent() {
237-
view.isUserInteractionEnabled = false
238-
buttonBarView.startGhostAnimation(style: .wooDefaultGhostStyle)
239-
visibleChildViewController.displayGhostContent()
240-
}
241-
242-
/// Unlocks the and removes the Placeholder Content
243-
///
244-
func removeGhostContent() {
245-
view.isUserInteractionEnabled = true
246-
buttonBarView.stopGhostAnimation()
247-
visibleChildViewController.removeGhostContent()
248245
}
249246

250247
/// If the Ghost Content was previously onscreen, this method will restart the animations.

WooCommerce/Classes/ViewRelated/Dashboard/Stats v4/StoreStatsV4PeriodViewController.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ final class StoreStatsV4PeriodViewController: UIViewController {
156156
observeReloadChartAnimated()
157157
}
158158

159+
override func viewWillAppear(_ animated: Bool) {
160+
super.viewWillAppear(animated)
161+
restartGhostAnimationIfNeeded()
162+
}
163+
159164
override func viewDidAppear(_ animated: Bool) {
160165
super.viewDidAppear(animated)
161166
reloadAllFields()
@@ -263,6 +268,12 @@ extension StoreStatsV4PeriodViewController {
263268
view.pinSubviewToAllEdges(placeholderChartsView)
264269
}
265270

271+
private func restartGhostAnimationIfNeeded() {
272+
guard placeholderChartsView.superview != nil else {
273+
return
274+
}
275+
placeholderChartsView.restartGhostAnimation(style: .wooDefaultGhostStyle)
276+
}
266277
}
267278

268279
// MARK: - Configuration

0 commit comments

Comments
 (0)