| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import SwiftUI
- import SwiftData
- // MARK: - ContentView
- /// Root navigation container for the CelestiaTrace app.
- /// Uses a TabView with three tabs: Home, History, and Settings.
- struct ContentView: View {
- /// Currently selected tab.
- @State private var selectedTab: Tab = .home
- var body: some View {
- TabView(selection: $selectedTab) {
- HomeView()
- .tabItem {
- Label(Tab.home.title, systemImage: Tab.home.icon)
- }
- .tag(Tab.home)
- SessionListView()
- .tabItem {
- Label(Tab.history.title, systemImage: Tab.history.icon)
- }
- .tag(Tab.history)
- SettingsView()
- .tabItem {
- Label(Tab.settings.title, systemImage: Tab.settings.icon)
- }
- .tag(Tab.settings)
- ProfileView()
- .tabItem {
- Label(Tab.profile.title, systemImage: Tab.profile.icon)
- }
- .tag(Tab.profile)
- }
- .tint(.celestiaCyan)
- }
- }
- // MARK: - Tab Definition
- extension ContentView {
- /// Defines the available tabs in the app's root navigation.
- enum Tab: Hashable {
- case home
- case history
- case settings
- case profile
- var title: String {
- switch self {
- case .home: "首页"
- case .history: "历史记录"
- case .settings: "设置"
- case .profile: "个人中心"
- }
- }
- var icon: String {
- switch self {
- case .home: "house.fill"
- case .history: "clock.arrow.circlepath"
- case .settings: "gearshape.fill"
- case .profile: "person.crop.circle.fill"
- }
- }
- }
- }
- // MARK: - Preview
- #Preview {
- ContentView()
- .modelContainer(for: CelestiaSession.self, inMemory: true)
- }
|