From 653caa0b84e15863ed65568061f55b5f1c6f7259 Mon Sep 17 00:00:00 2001 From: AndyChen1024 Date: Mon, 14 Sep 2026 21:10:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20app=20=E7=BB=84=E5=90=88=E6=A0=B9?= =?UTF-8?q?=E4=B8=8E=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IosClientKit/Sources/App/AppContainer.swift | 14 ++++++++ IosClientKit/Sources/App/AppRootView.swift | 36 +++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 IosClientKit/Sources/App/AppContainer.swift create mode 100644 IosClientKit/Sources/App/AppRootView.swift diff --git a/IosClientKit/Sources/App/AppContainer.swift b/IosClientKit/Sources/App/AppContainer.swift new file mode 100644 index 0000000..356801d --- /dev/null +++ b/IosClientKit/Sources/App/AppContainer.swift @@ -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) + } +} diff --git a/IosClientKit/Sources/App/AppRootView.swift b/IosClientKit/Sources/App/AppRootView.swift new file mode 100644 index 0000000..33e4b69 --- /dev/null +++ b/IosClientKit/Sources/App/AppRootView.swift @@ -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") } + } + } +}