Skip to content

Commit

Permalink
Complete onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Sep 21, 2023
1 parent d23acbd commit 10fdef1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -912,6 +913,7 @@
2CB279AE28C72AA400EDDCC8 /* DeepLinkRouterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkRouterProtocol.swift; sourceTree = "<group>"; };
2CB45761288EC29D007C2D77 /* StepQuizActionButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepQuizActionButtons.swift; sourceTree = "<group>"; };
2CB45763288ED6D4007C2D77 /* StepQuizActionButtonCodeQuizDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepQuizActionButtonCodeQuizDelegate.swift; sourceTree = "<group>"; };
2CB64A3E2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsOnboardingOutputProtocol.swift; sourceTree = "<group>"; };
2CBC97C52A55435E0078E445 /* StageImplementStageCompletedModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StageImplementStageCompletedModalView.swift; sourceTree = "<group>"; };
2CBC97C72A5549F10078E445 /* HypercoinLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HypercoinLabel.swift; sourceTree = "<group>"; };
2CBC97C92A5553330078E445 /* StageImplementStageCompletedModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StageImplementStageCompletedModalViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3142,6 +3144,7 @@
isa = PBXGroup;
children = (
C2D19C8A442CF9C4F00370B8 /* NotificationsOnboardingAssembly.swift */,
2CB64A3E2ABC47590053A998 /* NotificationsOnboardingOutputProtocol.swift */,
E3570563AEEEEF2F5495BCA6 /* NotificationsOnboardingViewModel.swift */,
2C68FD7D2ABC351D00D9EBE2 /* Views */,
);
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ extension AppViewModel: OnboardingOutputProtocol {
}
}

// MARK: - AppViewModel: NotificationsOnboardingOutputProtocol -

extension AppViewModel: NotificationsOnboardingOutputProtocol {
func handleNotificationsOnboardingCompleted() {
onNewMessage(AppFeatureMessageNotificationOnboardingCompleted())
}
}

// MARK: - AppViewModel: AppTabBarControllerDelegate -

extension AppViewModel: AppTabBarControllerDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ 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()

let notificationsOnboardingViewModel = NotificationsOnboardingViewModel(
notificationsRegistrationService: .shared,
feature: notificationsOnboardingComponent.notificationsOnboardingFeature
)
notificationsOnboardingViewModel.moduleOutput = moduleOutput

let notificationsOnboardingView = NotificationsOnboardingView(
viewModel: notificationsOnboardingViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

protocol NotificationsOnboardingOutputProtocol: AnyObject {
func handleNotificationsOnboardingCompleted()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ final class NotificationsOnboardingViewModel: FeatureViewModel<
NotificationsOnboardingFeatureMessage,
NotificationsOnboardingFeatureActionViewAction
> {
weak var moduleOutput: NotificationsOnboardingOutputProtocol?

private let notificationsRegistrationService: NotificationsRegistrationService

init(
Expand Down Expand Up @@ -45,6 +47,10 @@ final class NotificationsOnboardingViewModel: FeatureViewModel<
}
}

func doCompleteOnboarding() {
moduleOutput?.handleNotificationsOnboardingCompleted()
}

// MARK: Analytic

func logViewedEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private extension NotificationsOnboardingView {
) {
switch NotificationsOnboardingFeatureActionViewActionKs(viewAction) {
case .completeNotificationOnboarding:
#warning("TODO")
viewModel.doCompleteOnboarding()
case .requestNotificationPermission:
viewModel.doRequestNotificationPermission()
}
Expand All @@ -54,7 +54,7 @@ private extension NotificationsOnboardingView {
struct NotificationsOnboardingView_Previews: PreviewProvider {
static var previews: some View {
UIKitViewControllerPreview {
NotificationsOnboardingAssembly().makeModule()
NotificationsOnboardingAssembly(output: nil).makeModule()
}
}
}

0 comments on commit 10fdef1

Please sign in to comment.