Initial commit
This commit is contained in:
38
suixinkan/Features/Main/Views/MainTabsView.swift
Normal file
38
suixinkan/Features/Main/Views/MainTabsView.swift
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// MainTabsView.swift
|
||||
// suixinkan
|
||||
//
|
||||
// Created by Codex on 2026/6/18.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// 主 Tab 容器视图,为每个 Tab 创建独立的 NavigationStack。
|
||||
struct MainTabsView: View {
|
||||
@Environment(AppRouter.self) private var appRouter
|
||||
|
||||
var body: some View {
|
||||
@Bindable var appRouter = appRouter
|
||||
|
||||
TabView(selection: $appRouter.selectedTab) {
|
||||
ForEach(AppTab.allCases) { tab in
|
||||
NavigationStack(path: appRouter.binding(for: tab)) {
|
||||
tab.rootView
|
||||
.navigationTitle(tab.title)
|
||||
.navigationDestination(for: AppRoute.self) { route in
|
||||
route.destinationView
|
||||
.toolbar(route.hidesTabBarWhenPushed ? .hidden : .visible, for: .tabBar)
|
||||
}
|
||||
}
|
||||
.environment(appRouter.router(for: tab))
|
||||
.tabItem { tab.label }
|
||||
.tag(tab)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
MainTabsView()
|
||||
.environment(AppRouter())
|
||||
}
|
||||
77
suixinkan/Features/Main/Views/PlaceholderRootViews.swift
Normal file
77
suixinkan/Features/Main/Views/PlaceholderRootViews.swift
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// PlaceholderRootViews.swift
|
||||
// suixinkan
|
||||
//
|
||||
// Created by Codex on 2026/6/18.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// 首页根视图,占位承载后续首页迁移内容。
|
||||
struct HomeRootView: View {
|
||||
var body: some View {
|
||||
HomeView()
|
||||
}
|
||||
}
|
||||
|
||||
/// 订单根视图,占位承载后续订单模块迁移内容。
|
||||
struct OrdersRootView: View {
|
||||
var body: some View {
|
||||
PlaceholderTabRootView(title: "订单", systemImage: "doc.text")
|
||||
}
|
||||
}
|
||||
|
||||
/// 数据根视图,占位承载后续统计模块迁移内容。
|
||||
struct StatisticsRootView: View {
|
||||
var body: some View {
|
||||
PlaceholderTabRootView(title: "数据", systemImage: "chart.bar")
|
||||
}
|
||||
}
|
||||
|
||||
/// 我的根视图,当前承载个人信息页面。
|
||||
struct ProfileRootView: View {
|
||||
var body: some View {
|
||||
ProfileView()
|
||||
}
|
||||
}
|
||||
|
||||
/// 通用 Tab 占位视图,用于未迁移模块的临时入口。
|
||||
private struct PlaceholderTabRootView: View {
|
||||
@Environment(RouterPath.self) private var router
|
||||
|
||||
let title: String
|
||||
let systemImage: String
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
Image(systemName: systemImage)
|
||||
.font(.system(size: 44, weight: .semibold))
|
||||
.foregroundStyle(.tint)
|
||||
|
||||
Text(title)
|
||||
.font(.title2.weight(.semibold))
|
||||
|
||||
Button {
|
||||
router.navigate(to: .placeholder(title: "\(title)详情"))
|
||||
} label: {
|
||||
Label("打开详情", systemImage: "chevron.right")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Color(.systemGroupedBackground))
|
||||
}
|
||||
}
|
||||
|
||||
/// 通用占位详情页,用于验证 Tab 内 NavigationStack 跳转。
|
||||
struct PlaceholderDetailView: View {
|
||||
let title: String
|
||||
|
||||
var body: some View {
|
||||
Text(title)
|
||||
.font(.title3.weight(.medium))
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Color(.systemGroupedBackground))
|
||||
.navigationTitle(title)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user