feat: 组合根装配会话与导航(Tab + 登录 + 提交页)
This commit is contained in:
@@ -1,14 +1,49 @@
|
||||
import CoreDomain
|
||||
import CoreModel
|
||||
import CoreRepository
|
||||
import FeatureAuth
|
||||
import FeatureCheckin
|
||||
import FeatureHome
|
||||
import FeaturePlan
|
||||
import FeatureProfile
|
||||
|
||||
/// 手写组合根 / DI 容器(对应 Android Hilt 的 AppContainer)。
|
||||
@MainActor
|
||||
public enum AppContainer {
|
||||
/// 装配 FeatureHome 依赖并返回 ViewModel。
|
||||
// 共享的有状态仓库(登录态、打卡、计划可提交,需跨页面共享单例)。
|
||||
private static let sessionRepository: SessionRepository = FakeSessionRepository()
|
||||
private static let checkinRepository: CheckinRepository = FakeCheckinRepository()
|
||||
private static let planRepository: PlanRepository = FakePlanRepository()
|
||||
|
||||
private static let sessionUseCase = SessionUseCase(repository: sessionRepository)
|
||||
private static let checkinUseCase = CheckinUseCase(repository: checkinRepository)
|
||||
private static let planUseCase = PlanUseCase(repository: planRepository)
|
||||
|
||||
public static func makeHomeViewModel() -> HomeViewModel {
|
||||
let repository: HomeRepository = FakeHomeRepository()
|
||||
let useCase = HomeUseCase(repository: repository)
|
||||
return HomeViewModel(homeUseCase: useCase)
|
||||
return HomeViewModel(homeUseCase: useCase, sessionUseCase: sessionUseCase)
|
||||
}
|
||||
|
||||
public static func makeCheckinViewModel() -> CheckinViewModel {
|
||||
CheckinViewModel(checkinUseCase: checkinUseCase, sessionUseCase: sessionUseCase)
|
||||
}
|
||||
|
||||
public static func makePlanViewModel() -> PlanViewModel {
|
||||
PlanViewModel(planUseCase: planUseCase, sessionUseCase: sessionUseCase)
|
||||
}
|
||||
|
||||
public static func makeProfileViewModel() -> ProfileViewModel {
|
||||
let repository: ProfileRepository = FakeProfileRepository()
|
||||
let useCase = ProfileUseCase(repository: repository)
|
||||
return ProfileViewModel(profileUseCase: useCase, sessionUseCase: sessionUseCase)
|
||||
}
|
||||
|
||||
public static func makeAuthViewModel() -> AuthViewModel {
|
||||
AuthViewModel(sessionUseCase: sessionUseCase)
|
||||
}
|
||||
|
||||
public static func makePlanSubmitViewModel(type: PlanType, periodKey: String) -> PlanSubmitViewModel {
|
||||
PlanSubmitViewModel(planUseCase: planUseCase, type: type, periodKey: periodKey)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user