refactor: app 组合根与导航
This commit is contained in:
14
IosClientKit/Sources/App/AppContainer.swift
Normal file
14
IosClientKit/Sources/App/AppContainer.swift
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import CoreDomain
|
||||||
|
import CoreRepository
|
||||||
|
import FeatureHome
|
||||||
|
|
||||||
|
/// 手写组合根 / DI 容器(对应 Android Hilt 的 AppContainer)。
|
||||||
|
@MainActor
|
||||||
|
public enum AppContainer {
|
||||||
|
/// 装配 FeatureHome 依赖并返回 ViewModel。
|
||||||
|
public static func makeHomeViewModel() -> HomeViewModel {
|
||||||
|
let repository: HomeRepository = FakeHomeRepository()
|
||||||
|
let useCase = HomeUseCase(repository: repository)
|
||||||
|
return HomeViewModel(homeUseCase: useCase)
|
||||||
|
}
|
||||||
|
}
|
||||||
36
IosClientKit/Sources/App/AppRootView.swift
Normal file
36
IosClientKit/Sources/App/AppRootView.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import CoreUI
|
||||||
|
import FeatureAuth
|
||||||
|
import FeatureHome
|
||||||
|
|
||||||
|
public struct AppRootView: View {
|
||||||
|
@State private var homeViewModel: HomeViewModel
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
_homeViewModel = State(initialValue: AppContainer.makeHomeViewModel())
|
||||||
|
}
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
|
TabView {
|
||||||
|
NavigationStack {
|
||||||
|
HomeScreen(viewModel: homeViewModel)
|
||||||
|
}
|
||||||
|
.tabItem { Label("首页", systemImage: "house.fill") }
|
||||||
|
|
||||||
|
NavigationStack {
|
||||||
|
PlaceholderView("计划", systemImage: "calendar")
|
||||||
|
}
|
||||||
|
.tabItem { Label("计划", systemImage: "calendar") }
|
||||||
|
|
||||||
|
NavigationStack {
|
||||||
|
PlaceholderView("打卡", systemImage: "checkmark.seal.fill")
|
||||||
|
}
|
||||||
|
.tabItem { Label("打卡", systemImage: "checkmark.seal.fill") }
|
||||||
|
|
||||||
|
NavigationStack {
|
||||||
|
AuthScreen()
|
||||||
|
}
|
||||||
|
.tabItem { Label("我的", systemImage: "person.crop.circle") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user