Skip to content

Commit 2df1459

Browse files
committed
Dismiss onboarding banner when CTA is tapped
1 parent 191f02f commit 2df1459

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

WooCommerce/Classes/ViewModels/Feature Announcement Cards/ProductsOnboardingAnnouncementCardViewModel.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ struct ProductsOnboardingAnnouncementCardViewModel: AnnouncementCardViewModelPro
1818
// No-op
1919
}
2020

21-
/// Opens the Products tab when the Call To Action button is tapped
22-
///
23-
func ctaTapped() {
24-
guard let tabBarController = AppDelegate.shared.tabBarController else {
25-
return
26-
}
21+
// MARK: Call to Action
22+
23+
let onCTATapped: (() -> Void)?
2724

28-
tabBarController.navigateTo(.products)
25+
func ctaTapped() {
26+
onCTATapped?()
2927
}
3028

3129
// MARK: Dismiss button (disabled)

WooCommerce/Classes/ViewRelated/Dashboard/DashboardViewModel.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ final class DashboardViewModel {
123123
ServiceLocator.analytics.track(.productsOnboardingEligible)
124124

125125
if self?.featureFlagService.isFeatureFlagEnabled(.productsOnboarding) == true {
126-
let viewModel = ProductsOnboardingAnnouncementCardViewModel()
126+
let viewModel = ProductsOnboardingAnnouncementCardViewModel(onCTATapped: { [weak self] in
127+
guard let tabBarController = AppDelegate.shared.tabBarController else {
128+
return
129+
}
130+
131+
self?.announcementViewModel = nil // Dismiss announcement
132+
tabBarController.navigateTo(.products)
133+
})
127134
self?.announcementViewModel = viewModel
128135
}
129136
}

0 commit comments

Comments
 (0)