diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift index 8b87d981..52cbf5b2 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift @@ -15,14 +15,15 @@ import MyPageFeature final class AppCoordinator: ObservableObject, CoordinatorType { - @Published var currentView: AnyView = AnyView(SplashView(coordinator: AppCoordinator(navigationPath: .init()))) + @Published var currentView: AnyView = AnyView(EmptyView()) @Published var appState: AppState = .login - var navigationPath: NavigationPath - var parentCoordinator: (any CoordinatorType)? + + var navigationPath: NavigationPath = NavigationPath() + private let diContainer: AppDIContainer - init(navigationPath: NavigationPath) { - self.navigationPath = navigationPath + init(diContainer: AppDIContainer) { + self.diContainer = diContainer } func start() -> AnyView { @@ -53,7 +54,8 @@ final class AppCoordinator: ObservableObject, CoordinatorType { } func startLogin() { - let authCoordinator = AuthCoordinator(parentCoordinator: self, navigationPath: navigationPath) + let authDIContainer = diContainer.injectAuthDIContainer() + let authCoordinator = AuthCoordinator(navigationPath: navigationPath, diContainer: authDIContainer) currentView = authCoordinator.start() } diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift index 4bff3112..933126c9 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift @@ -11,19 +11,20 @@ import SwiftUI import LoginFeature final class AuthCoordinator: ObservableObject, CoordinatorType { - var parentCoordinator: (any CoordinatorType)? - var navigationPath: NavigationPath - + private let diContainer: AuthDIContainer + init( - parentCoordinator: any CoordinatorType, - navigationPath: NavigationPath + navigationPath: NavigationPath, + diContainer: AuthDIContainer ) { - self.parentCoordinator = parentCoordinator self.navigationPath = navigationPath + self.diContainer = diContainer } - + func start() -> AnyView { - return AnyView(LoginView(viewModel: LoginViewModel())) + let viewModel = diContainer.injectLoginViewModel() + let view = LoginView(viewModel: viewModel) + return AnyView(view) } } diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift index 1b457c7e..08808fb4 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift @@ -10,10 +10,10 @@ import Combine import Core -// MARK: - BaseCoordinator 프로토콜 +// MARK: - BaseCoordinator + +/// NavigationStack을 사용할 경우 이전에 대한 정보를 모두 갖고 있기 때문에 부모 - 자식 코디네이터 불필요 public protocol CoordinatorType: AnyObject { - - var parentCoordinator: (any CoordinatorType)? { get set } var navigationPath: NavigationPath { get set } func start() -> AnyView