From 0b7bfc3b05f7af3ede92a947608f9c30579ba3e8 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:20:30 +0900 Subject: [PATCH] =?UTF-8?q?[Fix/#104]=20=EC=BD=94=EB=94=94=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Coordinator/AppCoordinator.swift | 14 ++++++++------ .../Sources/Coordinator/AuthCoordinator.swift | 17 +++++++++-------- .../Sources/Coordinator/BaseCoordinator.swift | 6 +++--- 3 files changed, 20 insertions(+), 17 deletions(-) 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