@@ -44,9 +44,8 @@ final class StoreStatsV4PeriodViewController: UIViewController {
4444 // MARK: - Subviews
4545
4646 @IBOutlet private weak var containerStackView : UIStackView !
47- @IBOutlet private weak var visitorsStackView : UIStackView !
4847 @IBOutlet private weak var visitorsTitle : UILabel !
49- @IBOutlet private weak var visitorsData : UILabel !
48+ @IBOutlet private weak var visitorsDataOrRedactedView : StoreStatsDataOrRedactedView !
5049 @IBOutlet private weak var ordersTitle : UILabel !
5150 @IBOutlet private weak var ordersData : UILabel !
5251 @IBOutlet private weak var conversionStackView : UIStackView !
@@ -118,8 +117,6 @@ final class StoreStatsV4PeriodViewController: UIViewController {
118117 roundSmallNumbers: false ) ?? String ( )
119118 }
120119
121- private lazy var visitorsEmptyView = StoreStatsSiteVisitEmptyView ( )
122-
123120 private var cancellables : Set < AnyCancellable > = [ ]
124121
125122 // MARK: - Initialization
@@ -192,7 +189,7 @@ private extension StoreStatsV4PeriodViewController {
192189 } . store ( in: & cancellables)
193190
194191 viewModel. visitorStatsText. sink { [ weak self] visitorStatsLabel in
195- self ? . visitorsData . text = visitorStatsLabel
192+ self ? . visitorsDataOrRedactedView . data = visitorStatsLabel
196193 } . store ( in: & cancellables)
197194
198195 viewModel. conversionStatsText. sink { [ weak self] conversionStatsLabel in
@@ -205,7 +202,7 @@ private extension StoreStatsV4PeriodViewController {
205202 guard let self = self else { return }
206203 let textColor = selectedIndex == nil ? Constants . statsTextColor: Constants . statsHighlightTextColor
207204 self . ordersData. textColor = textColor
208- self . visitorsData . textColor = textColor
205+ self . visitorsDataOrRedactedView . isHighlighted = selectedIndex != nil
209206 self . revenueData. textColor = textColor
210207 self . conversionData. textColor = textColor
211208
@@ -290,13 +287,6 @@ private extension StoreStatsV4PeriodViewController {
290287 view. backgroundColor = Constants . containerBackgroundColor
291288 containerStackView. backgroundColor = Constants . containerBackgroundColor
292289 timeRangeBarView. backgroundColor = Constants . headerComponentBackgroundColor
293- visitorsStackView. backgroundColor = Constants . headerComponentBackgroundColor
294-
295- // Visitor empty view - insert it at the second-to-last index,
296- // since we need the footer view (with height = 20) as the last item in the stack view.
297- let emptyViewIndex = max ( 0 , visitorsStackView. arrangedSubviews. count - 2 )
298- visitorsStackView. insertArrangedSubview ( visitorsEmptyView, at: emptyViewIndex)
299- visitorsEmptyView. isHidden = true
300290
301291 // Titles
302292 visitorsTitle. text = NSLocalizedString ( " Visitors " , comment: " Visitors stat label on dashboard - should be plural. " )
@@ -416,7 +406,6 @@ private extension StoreStatsV4PeriodViewController {
416406//
417407private extension StoreStatsV4PeriodViewController {
418408 func updateSiteVisitStats( mode: SiteVisitStatsMode ) {
419- visitorsStackView. isHidden = mode == . hidden
420409 reloadSiteVisitUI ( )
421410 updateConversionStatsVisibility ( visitStatsMode: mode)
422411 }
@@ -472,11 +461,10 @@ private extension StoreStatsV4PeriodViewController {
472461 reloadSiteVisitUI ( )
473462 return
474463 }
475- guard visitorsData != nil else {
464+ guard visitorsDataOrRedactedView != nil else {
476465 return
477466 }
478- visitorsData. isHidden = false
479- visitorsEmptyView. isHidden = true
467+ visitorsDataOrRedactedView. state = . data
480468 }
481469 }
482470
@@ -603,43 +591,32 @@ private extension StoreStatsV4PeriodViewController {
603591 reloadSiteVisitUI ( )
604592 updateConversionStatsVisibility ( visitStatsMode: siteVisitStatsMode)
605593 reloadChart ( animateChart: animateChart)
606- let visitStatsElements : [ Any ] = {
607- switch siteVisitStatsMode {
608- case . default:
609- return [ visitorsTitle as Any ,
610- visitorsData as Any ]
611- case . redactedDueToJetpack:
612- return [ visitorsTitle as Any ,
613- visitorsEmptyView as Any ]
614- case . hidden:
615- return [ ]
616- }
617- } ( )
618594
619- view. accessibilityElements = visitStatsElements + [ ordersTitle as Any ,
620- ordersData as Any ,
621- revenueTitle as Any ,
622- revenueData as Any ,
623- conversionTitle as Any ,
624- conversionData as Any ,
625- yAxisAccessibilityView as Any ,
626- xAxisAccessibilityView as Any ,
627- chartAccessibilityView as Any ]
595+ view. accessibilityElements = [ ordersTitle as Any ,
596+ ordersData as Any ,
597+ visitorsTitle as Any ,
598+ visitorsDataOrRedactedView as Any ,
599+ revenueTitle as Any ,
600+ revenueData as Any ,
601+ conversionTitle as Any ,
602+ conversionData as Any ,
603+ yAxisAccessibilityView as Any ,
604+ xAxisAccessibilityView as Any ,
605+ chartAccessibilityView as Any ]
628606 }
629607
630608 func reloadSiteVisitUI( ) {
609+ guard visitorsDataOrRedactedView != nil else {
610+ return
611+ }
612+
631613 switch siteVisitStatsMode {
632614 case . hidden:
633- break
615+ visitorsDataOrRedactedView . state = . redacted
634616 case . redactedDueToJetpack:
635- visitorsData. isHidden = true
636- visitorsEmptyView. isHidden = false
617+ visitorsDataOrRedactedView. state = . redactedDueToJetpack
637618 case . default:
638- guard visitorsData != nil else {
639- return
640- }
641- visitorsData. isHidden = false
642- visitorsEmptyView. isHidden = true
619+ visitorsDataOrRedactedView. state = . data
643620 }
644621 }
645622
@@ -720,7 +697,7 @@ private extension StoreStatsV4PeriodViewController {
720697 }
721698
722699 func updateStatsDataToDefaultStyles( ) {
723- [ visitorsData , ordersData, conversionData] . forEach { label in
700+ [ ordersData, conversionData] . forEach { label in
724701 label? . font = Constants . statsFont
725702 label? . textColor = Constants . statsTextColor
726703 }
0 commit comments