Skip to content

Commit 3856e30

Browse files
authored
Merge pull request #8158 from woocommerce/issue/8145-analytics-hub-entry-point
[Analytics Hub] Add a "see more" button on the dashboard
2 parents 667f70d + 8244653 commit 3856e30

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
5151
return buildConfig == .alpha
5252
case .nativeJetpackSetupFlow:
5353
return buildConfig == .localDeveloper || buildConfig == .alpha
54+
case .analyticsHub:
55+
return buildConfig == .localDeveloper || buildConfig == .alpha
5456
default:
5557
return true
5658
}

Experiments/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,8 @@ public enum FeatureFlag: Int {
125125
/// TODO-8075: replace this with A/B test.
126126
///
127127
case nativeJetpackSetupFlow
128+
129+
/// Temporary feature flag for the native Jetpack setup flow.
130+
///
131+
case analyticsHub
128132
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import SwiftUI
2+
import Yosemite
3+
4+
final class AnalyticsHubHostingViewController: UIHostingController<AnalyticsHubView> {
5+
init(timeRange: StatsTimeRangeV4) {
6+
super.init(rootView: AnalyticsHubView(timeRange: timeRange))
7+
}
8+
9+
@available(*, unavailable)
10+
required dynamic init?(coder aDecoder: NSCoder) {
11+
fatalError("init(coder:) has not been implemented")
12+
}
13+
}
14+
15+
struct AnalyticsHubView: View {
16+
let timeRange: StatsTimeRangeV4
17+
18+
var body: some View {
19+
Text("Selected time range: \(timeRange.rawValue)")
20+
}
21+
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ final class StoreStatsAndTopPerformersPeriodViewController: UIViewController {
8383

8484
private lazy var inAppFeedbackCardViewController = InAppFeedbackCardViewController()
8585

86+
private lazy var analyticsHubButtonView = createAnalyticsHubButtonView()
87+
8688
/// An array of UIViews for the In-app Feedback Card. This will be dynamically shown
8789
/// or hidden depending on the configuration.
8890
private lazy var inAppFeedbackCardViewsForStackView: [UIView] = createInAppFeedbackCardViewsForStackView()
@@ -182,6 +184,7 @@ extension StoreStatsAndTopPerformersPeriodViewController {
182184

183185
func displayGhostContent() {
184186
storeStatsPeriodViewController.displayGhostContent()
187+
analyticsHubButtonView.startGhostAnimation(style: Constants.ghostStyle)
185188
topPerformersHeaderView.startGhostAnimation(style: Constants.ghostStyle)
186189
topPerformersPeriodViewController.displayGhostContent()
187190
}
@@ -190,6 +193,7 @@ extension StoreStatsAndTopPerformersPeriodViewController {
190193
///
191194
func removeStoreStatsGhostContent() {
192195
storeStatsPeriodViewController.removeGhostContent()
196+
analyticsHubButtonView.stopGhostAnimation()
193197
topPerformersHeaderView.stopGhostAnimation()
194198
}
195199

@@ -287,6 +291,11 @@ private extension StoreStatsAndTopPerformersPeriodViewController {
287291
storeStatsPeriodView.heightAnchor.constraint(equalToConstant: Constants.storeStatsPeriodViewHeight),
288292
])
289293

294+
// Analytics Hub ("See more") button
295+
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.analyticsHub) {
296+
stackView.addArrangedSubview(analyticsHubButtonView)
297+
}
298+
290299
// In-app Feedback Card
291300
stackView.addArrangedSubviews(inAppFeedbackCardViewsForStackView)
292301

@@ -327,11 +336,30 @@ private extension StoreStatsAndTopPerformersPeriodViewController {
327336
return [emptySpaceView, cardView]
328337
}
329338

339+
func createAnalyticsHubButtonView() -> UIView {
340+
let button = UIButton(frame: .zero)
341+
button.translatesAutoresizingMaskIntoConstraints = false
342+
button.applySecondaryButtonStyle()
343+
button.setTitle(Localization.seeMoreButton, for: .normal)
344+
button.addTarget(self, action: #selector(seeMoreButtonTapped), for: .touchUpInside)
345+
346+
let view = UIView(frame: .zero)
347+
view.addSubview(button)
348+
view.pinSubviewToSafeArea(button, insets: Constants.buttonInsets)
349+
350+
return view
351+
}
352+
330353
func configureInAppFeedbackViewControllerAction() {
331354
inAppFeedbackCardViewController.onFeedbackGiven = { [weak self] in
332355
self?.viewModel.onInAppFeedbackCardAction()
333356
}
334357
}
358+
359+
@objc func seeMoreButtonTapped() {
360+
let analyticsHubVC = AnalyticsHubHostingViewController(timeRange: timeRange)
361+
show(analyticsHubVC, sender: self)
362+
}
335363
}
336364

337365
// MARK: Actions
@@ -349,5 +377,10 @@ private extension StoreStatsAndTopPerformersPeriodViewController {
349377
static let storeStatsPeriodViewHeight: CGFloat = 444
350378
static let ghostStyle: GhostStyle = .wooDefaultGhostStyle
351379
static let backgroundColor: UIColor = .systemBackground
380+
static let buttonInsets: UIEdgeInsets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
381+
}
382+
383+
enum Localization {
384+
static let seeMoreButton = NSLocalizedString("See more", comment: "Button on the stats dashboard that navigates user to the analytics hub")
352385
}
353386
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@
11591159
ABC35528D2D6BE6F516E5CEF /* InPersonPaymentsOnboardingError.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC35A4B736A0B2D8348DD08 /* InPersonPaymentsOnboardingError.swift */; };
11601160
ABC35F18E744C5576B986CB3 /* InPersonPaymentsUnavailableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC35055F8AC8C8EB649F421 /* InPersonPaymentsUnavailableView.swift */; };
11611161
AE1CC33829129A010021C8EF /* LinkBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE1CC33729129A010021C8EF /* LinkBehavior.swift */; };
1162+
AE2EA1142927F87B000392B6 /* AnalyticsHubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2EA1132927F87B000392B6 /* AnalyticsHubView.swift */; };
11621163
AE3AA889290C303B00BE422D /* WebKitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3AA888290C303B00BE422D /* WebKitViewController.swift */; };
11631164
AE3AA88B290C30B900BE422D /* WebViewControllerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3AA88A290C30B900BE422D /* WebViewControllerConfiguration.swift */; };
11641165
AE3AA88D290C30E800BE422D /* WebProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3AA88C290C30E800BE422D /* WebProgressView.swift */; };
@@ -3108,6 +3109,7 @@
31083109
ABC353433EABC5F0EC796222 /* CardReaderSettingsSearchingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardReaderSettingsSearchingViewController.swift; sourceTree = "<group>"; };
31093110
ABC35A4B736A0B2D8348DD08 /* InPersonPaymentsOnboardingError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsOnboardingError.swift; sourceTree = "<group>"; };
31103111
AE1CC33729129A010021C8EF /* LinkBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkBehavior.swift; sourceTree = "<group>"; };
3112+
AE2EA1132927F87B000392B6 /* AnalyticsHubView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsHubView.swift; sourceTree = "<group>"; };
31113113
AE3AA888290C303B00BE422D /* WebKitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebKitViewController.swift; sourceTree = "<group>"; };
31123114
AE3AA88A290C30B900BE422D /* WebViewControllerConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewControllerConfiguration.swift; sourceTree = "<group>"; };
31133115
AE3AA88C290C30E800BE422D /* WebProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebProgressView.swift; sourceTree = "<group>"; };
@@ -6676,6 +6678,14 @@
66766678
path = FlowCoordinator;
66776679
sourceTree = "<group>";
66786680
};
6681+
AE2EA1122927F86C000392B6 /* AnalyticsHub */ = {
6682+
isa = PBXGroup;
6683+
children = (
6684+
AE2EA1132927F87B000392B6 /* AnalyticsHubView.swift */,
6685+
);
6686+
path = AnalyticsHub;
6687+
sourceTree = "<group>";
6688+
};
66796689
AE9E04732776034B003FA09E /* CustomerSection */ = {
66806690
isa = PBXGroup;
66816691
children = (
@@ -8043,6 +8053,7 @@
80438053
CE85FD5120F677460080B73E /* Dashboard */ = {
80448054
isa = PBXGroup;
80458055
children = (
8056+
AE2EA1122927F86C000392B6 /* AnalyticsHub */,
80468057
DE23CFF827462CD2003BE54E /* JetpackInstall */,
80478058
02F843D8273646190017FE12 /* JetpackConnectionPackageSites */,
80488059
028BAC4322F3AE3B008BB4AF /* Stats v4 */,
@@ -10187,6 +10198,7 @@
1018710198
CC254F2D26C17AB5005F3C82 /* BottomButtonView.swift in Sources */,
1018810199
DEF36DE92898D3CF00178AC2 /* AuthenticatedWebViewController.swift in Sources */,
1018910200
74334F36214AB130006D6AC5 /* ProductTableViewCell.swift in Sources */,
10201+
AE2EA1142927F87B000392B6 /* AnalyticsHubView.swift in Sources */,
1019010202
D8610D762570AE1F00A5DF27 /* NotWPErrorViewModel.swift in Sources */,
1019110203
0245465B24EE7637004F531C /* ProductFormEventLoggerProtocol.swift in Sources */,
1019210204
02C1853D27FF153A00ABD764 /* CardPresentRefundOrchestrator.swift in Sources */,

0 commit comments

Comments
 (0)