import SwiftUI

/// Top-level tab container.
///
/// Tab 1: the existing search / connection / where-to-go home screen.
/// Tab 2: the live flight tracker (map + filters + tap-to-detail).
struct RootView: View {
    let database: AirportDatabase
    let loadService: AirlineLoadService
    let routeExplorer: RouteExplorerClient
    let openSky: OpenSkyClient

    @State private var selectedTab: Tab = .search

    enum Tab: Hashable { case search, live }

    var body: some View {
        TabView(selection: $selectedTab) {
            RoutePlannerView(
                database: database,
                client: routeExplorer,
                loadService: loadService
            )
            .tabItem {
                Label("Search", systemImage: "magnifyingglass")
            }
            .tag(Tab.search)

            NavigationStack {
                LiveFlightsView(openSky: openSky, database: database)
                    .navigationTitle("Live Flights")
                    .navigationBarTitleDisplayMode(.inline)
            }
            .tabItem {
                Label("Live", systemImage: "antenna.radiowaves.left.and.right")
            }
            .tag(Tab.live)
        }
        .tint(FlightTheme.accent)
    }
}
