From 10fdef1634e73db47826d72b012318510e1dd5ee Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Thu, 21 Sep 2023 13:49:02 +0400 Subject: [PATCH] Complete onboarding --- .../iosHyperskillApp.xcodeproj/project.pbxproj | 4 ++++ .../Sources/Modules/App/AppViewModel.swift | 8 ++++++++ .../Modules/App/ViewControllers/AppViewController.swift | 2 +- .../NotificationsOnboardingAssembly.swift | 7 +++++++ .../NotificationsOnboardingOutputProtocol.swift | 5 +++++ .../NotificationsOnboardingViewModel.swift | 6 ++++++ .../Views/NotificationsOnboardingView.swift | 4 ++-- 7 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingOutputProtocol.swift diff --git a/iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj b/iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj index 62fb16f173..f9781178ad 100644 --- a/iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj +++ b/iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj @@ -331,6 +331,7 @@ 2CB279AF28C72AA400EDDCC8 /* DeepLinkRouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB279AE28C72AA400EDDCC8 /* DeepLinkRouterProtocol.swift */; }; 2CB45762288EC29D007C2D77 /* StepQuizActionButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB45761288EC29D007C2D77 /* StepQuizActionButtons.swift */; }; 2CB45764288ED6D4007C2D77 /* StepQuizActionButtonCodeQuizDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB45763288ED6D4007C2D77 /* StepQuizActionButtonCodeQuizDelegate.swift */; }; + 2CB64A3F2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB64A3E2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift */; }; 2CBC97C62A55435E0078E445 /* StageImplementStageCompletedModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC97C52A55435E0078E445 /* StageImplementStageCompletedModalView.swift */; }; 2CBC97C82A5549F10078E445 /* HypercoinLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC97C72A5549F10078E445 /* HypercoinLabel.swift */; }; 2CBC97CA2A5553330078E445 /* StageImplementStageCompletedModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC97C92A5553330078E445 /* StageImplementStageCompletedModalViewController.swift */; }; @@ -912,6 +913,7 @@ 2CB279AE28C72AA400EDDCC8 /* DeepLinkRouterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkRouterProtocol.swift; sourceTree = ""; }; 2CB45761288EC29D007C2D77 /* StepQuizActionButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepQuizActionButtons.swift; sourceTree = ""; }; 2CB45763288ED6D4007C2D77 /* StepQuizActionButtonCodeQuizDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepQuizActionButtonCodeQuizDelegate.swift; sourceTree = ""; }; + 2CB64A3E2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsOnboardingOutputProtocol.swift; sourceTree = ""; }; 2CBC97C52A55435E0078E445 /* StageImplementStageCompletedModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StageImplementStageCompletedModalView.swift; sourceTree = ""; }; 2CBC97C72A5549F10078E445 /* HypercoinLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HypercoinLabel.swift; sourceTree = ""; }; 2CBC97C92A5553330078E445 /* StageImplementStageCompletedModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StageImplementStageCompletedModalViewController.swift; sourceTree = ""; }; @@ -3142,6 +3144,7 @@ isa = PBXGroup; children = ( C2D19C8A442CF9C4F00370B8 /* NotificationsOnboardingAssembly.swift */, + 2CB64A3E2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift */, E3570563AEEEEF2F5495BCA6 /* NotificationsOnboardingViewModel.swift */, 2C68FD7D2ABC351D00D9EBE2 /* Views */, ); @@ -4177,6 +4180,7 @@ E9D2D670284E0A70000757AC /* StepQuizMatchingViewData.swift in Sources */, E99B218C2887EA14006A6154 /* StepQuizStringSkeletonView.swift in Sources */, 2C20FBC0284F65F6006D879E /* HTMLToAttributedStringConverter.swift in Sources */, + 2CB64A3F2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift in Sources */, 2C93AF2529B34FE6004639E0 /* StepQuizPyCharmAssembly.swift in Sources */, 2CDA98412944512D00ADE539 /* ProfileSkeletonView.swift in Sources */, 2CEDE70729965B4D0032D399 /* RestartApplicationLocalNotification.swift in Sources */, diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/AppViewModel.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/AppViewModel.swift index ca4e6692a7..658420994d 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/AppViewModel.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/AppViewModel.swift @@ -123,6 +123,14 @@ extension AppViewModel: OnboardingOutputProtocol { } } +// MARK: - AppViewModel: NotificationsOnboardingOutputProtocol - + +extension AppViewModel: NotificationsOnboardingOutputProtocol { + func handleNotificationsOnboardingCompleted() { + onNewMessage(AppFeatureMessageNotificationOnboardingCompleted()) + } +} + // MARK: - AppViewModel: AppTabBarControllerDelegate - extension AppViewModel: AppTabBarControllerDelegate { diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/ViewControllers/AppViewController.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/ViewControllers/AppViewController.swift index 16da49fa72..37193adfe4 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/ViewControllers/AppViewController.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/App/ViewControllers/AppViewController.swift @@ -113,7 +113,7 @@ extension AppViewController: AppViewControllerProtocol { navigationController.navigationBar.prefersLargeTitles = true return navigationController case .notificationOnBoardingScreen: - let assembly = NotificationsOnboardingAssembly() + let assembly = NotificationsOnboardingAssembly(output: viewModel) return assembly.makeModule() } }() diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingAssembly.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingAssembly.swift index 75fc36ee25..8c6e04ea02 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingAssembly.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingAssembly.swift @@ -2,6 +2,12 @@ import shared import SwiftUI final class NotificationsOnboardingAssembly: UIKitAssembly { + private weak var moduleOutput: NotificationsOnboardingOutputProtocol? + + init(output: NotificationsOnboardingOutputProtocol?) { + self.moduleOutput = output + } + func makeModule() -> UIViewController { let notificationsOnboardingComponent = AppGraphBridge.sharedAppGraph.buildNotificationsOnboardingComponent() @@ -9,6 +15,7 @@ final class NotificationsOnboardingAssembly: UIKitAssembly { notificationsRegistrationService: .shared, feature: notificationsOnboardingComponent.notificationsOnboardingFeature ) + notificationsOnboardingViewModel.moduleOutput = moduleOutput let notificationsOnboardingView = NotificationsOnboardingView( viewModel: notificationsOnboardingViewModel diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingOutputProtocol.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingOutputProtocol.swift new file mode 100644 index 0000000000..e2e56b463c --- /dev/null +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingOutputProtocol.swift @@ -0,0 +1,5 @@ +import Foundation + +protocol NotificationsOnboardingOutputProtocol: AnyObject { + func handleNotificationsOnboardingCompleted() +} diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingViewModel.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingViewModel.swift index 9ec890a112..a9f98ca8c8 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingViewModel.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/NotificationsOnboardingViewModel.swift @@ -6,6 +6,8 @@ final class NotificationsOnboardingViewModel: FeatureViewModel< NotificationsOnboardingFeatureMessage, NotificationsOnboardingFeatureActionViewAction > { + weak var moduleOutput: NotificationsOnboardingOutputProtocol? + private let notificationsRegistrationService: NotificationsRegistrationService init( @@ -45,6 +47,10 @@ final class NotificationsOnboardingViewModel: FeatureViewModel< } } + func doCompleteOnboarding() { + moduleOutput?.handleNotificationsOnboardingCompleted() + } + // MARK: Analytic func logViewedEvent() { diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/Views/NotificationsOnboardingView.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/Views/NotificationsOnboardingView.swift index 68163b99d4..4dbc94681b 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/Views/NotificationsOnboardingView.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/NotificationsOnboarding/Views/NotificationsOnboardingView.swift @@ -42,7 +42,7 @@ private extension NotificationsOnboardingView { ) { switch NotificationsOnboardingFeatureActionViewActionKs(viewAction) { case .completeNotificationOnboarding: - #warning("TODO") + viewModel.doCompleteOnboarding() case .requestNotificationPermission: viewModel.doRequestNotificationPermission() } @@ -54,7 +54,7 @@ private extension NotificationsOnboardingView { struct NotificationsOnboardingView_Previews: PreviewProvider { static var previews: some View { UIKitViewControllerPreview { - NotificationsOnboardingAssembly().makeModule() + NotificationsOnboardingAssembly(output: nil).makeModule() } } }