From 742dad4867ebb1f11edeb21848904c5bc3828716 Mon Sep 17 00:00:00 2001 From: Winnie Teichmann <4530+thatswinnie@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:01:37 +0200 Subject: [PATCH] Refactor FXIOS-7429 [v119] Integrate onboarding in bottom sheet (#16472) * Add onboarding card to view controller * Display onboarding if user is not opted in yet * Optimize code --- Client/Frontend/Fakespot/FakespotViewController.swift | 8 +++++++- Client/Frontend/Fakespot/FakespotViewModel.swift | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Client/Frontend/Fakespot/FakespotViewController.swift b/Client/Frontend/Fakespot/FakespotViewController.swift index 2a02307e1343..286735a0483d 100644 --- a/Client/Frontend/Fakespot/FakespotViewController.swift +++ b/Client/Frontend/Fakespot/FakespotViewController.swift @@ -160,7 +160,7 @@ class FakespotViewController: UIViewController, Themeable, UIAdaptivePresentatio private func updateContent() { contentStackView.removeAllArrangedViews() - viewModel.state.viewElements.forEach { element in + viewModel.viewElements.forEach { element in guard let view = createContentView(viewElement: element) else { return } contentStackView.addArrangedSubview(view) @@ -177,6 +177,12 @@ class FakespotViewController: UIViewController, Themeable, UIAdaptivePresentatio let view: FakespotLoadingView = .build() return view + case .onboarding: + let viewModel = FakespotOptInCardViewModel() + let view: FakespotOptInCardView = .build() + view.configure(viewModel) + return view + case .reliabilityCard: guard let cardViewModel = viewModel.reliabilityCardViewModel else { return nil } let view: FakespotReliabilityCardView = .build() diff --git a/Client/Frontend/Fakespot/FakespotViewModel.swift b/Client/Frontend/Fakespot/FakespotViewModel.swift index e7c1c0b11406..acd209cd153f 100644 --- a/Client/Frontend/Fakespot/FakespotViewModel.swift +++ b/Client/Frontend/Fakespot/FakespotViewModel.swift @@ -12,7 +12,7 @@ class FakespotViewModel { case loaded(ProductAnalysisData?) case error(Error) - var viewElements: [ViewElement] { + fileprivate var viewElements: [ViewElement] { var elements: [ViewElement] = [] switch self { @@ -38,7 +38,7 @@ class FakespotViewModel { return elements } - var productData: ProductAnalysisData? { + fileprivate var productData: ProductAnalysisData? { switch self { case .loading, .error: return nil case .loaded(let data): return data @@ -48,7 +48,7 @@ class FakespotViewModel { enum ViewElement { case loadingView -// case onboarding // card not created yet (FXIOS-7270) + case onboarding case reliabilityCard case adjustRatingCard case highlightsCard @@ -68,7 +68,7 @@ class FakespotViewModel { var onStateChange: (() -> Void)? var viewElements: [ViewElement] { -// guard isOptedIn else { return [.onboarding] } // card not created yet (FXIOS-7270) + guard isOptedIn else { return [.onboarding] } return state.viewElements }