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 { selectedTab = .home } .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) }