同步已迁移的 iOS 模块

This commit is contained in:
2026-06-22 15:35:12 +08:00
parent 0a0d4fbd79
commit 08465fffde
48 changed files with 4455 additions and 15 deletions

View File

@ -12,6 +12,7 @@ import SwiftUI
enum AppRoute: Hashable {
case placeholder(title: String)
case home(HomeRoute)
case profile(ProfileRoute)
/// NavigationStack push TabBar
var hidesTabBarWhenPushed: Bool {
@ -26,6 +27,8 @@ enum AppRoute: Hashable {
PlaceholderDetailView(title: title)
case .home(let route):
route.destinationView
case .profile(let route):
route.destinationView
}
}
}
@ -52,6 +55,7 @@ final class RouterPath {
/// Tab Tab NavigationStack
final class AppRouter {
var selectedTab: AppTab = .home
var selectedOrdersEntry: OrdersEntry = .storeOrders
private var routers: [AppTab: RouterPath] = [:]
/// Tab
@ -80,9 +84,16 @@ final class AppRouter {
selectedTab = tab
}
/// Tab
func selectOrders(entry: OrdersEntry) {
selectedOrdersEntry = entry
selectedTab = .orders
}
/// Tab Tab
func reset() {
selectedTab = .home
selectedOrdersEntry = .storeOrders
routers.values.forEach { $0.reset() }
}
}

View File

@ -19,6 +19,8 @@ struct RootView: View {
@State private var authAPI: AuthAPI
@State private var profileAPI: ProfileAPI
@State private var accountContextAPI: AccountContextAPI
@State private var ordersAPI: OrdersAPI
@State private var statisticsAPI: StatisticsAPI
@State private var authSessionCoordinator: AuthSessionCoordinator
@State private var sessionBootstrapper: SessionBootstrapper
@ -31,6 +33,8 @@ struct RootView: View {
_authAPI = State(initialValue: AuthAPI(client: apiClient))
_profileAPI = State(initialValue: ProfileAPI(client: apiClient))
_accountContextAPI = State(initialValue: AccountContextAPI(client: apiClient))
_ordersAPI = State(initialValue: OrdersAPI(client: apiClient))
_statisticsAPI = State(initialValue: StatisticsAPI(client: apiClient))
_authSessionCoordinator = State(
initialValue: AuthSessionCoordinator(
tokenStore: tokenStore,
@ -59,6 +63,8 @@ struct RootView: View {
.environment(authAPI)
.environment(profileAPI)
.environment(accountContextAPI)
.environment(ordersAPI)
.environment(statisticsAPI)
.environment(authSessionCoordinator)
.task {
apiClient.bindAuthTokenProvider { appSession.token }