Repository Public
1//2// Auto-Ka iOS v23// File: AutoKa/App/RootView.swift4// Description: onglets adaptatifs (barre d'onglets sur iPhone, barre latérale sur iPad), destinations partagées,5// message de confirmation et calque du geste d'ouverture.6//7// Author: Simon-Pierre Boucher8// Contact: contact@spboucher.ai9//1011import SwiftUI1213struct RootView: View {14 @Environment(AppModel.self) private var model15 @Environment(Library.self) private var library1617 var body: some View {18 @Bindable var model = model19 TabView(selection: $model.tab) {20 Tab("Accueil", systemImage: "house", value: AppTab.home) {21 stack(.home) { HomeView() }22 }23 Tab("Recherche", systemImage: "magnifyingglass", value: AppTab.search) {24 stack(.search) { SearchView() }25 }26 Tab("Favoris", systemImage: "heart", value: AppTab.favorites) {27 stack(.favorites) { FavoritesView() }28 }29 Tab("Marché", systemImage: "chart.bar.xaxis", value: AppTab.market) {30 stack(.market) { MarketView() }31 }32 Tab("Plus", systemImage: "ellipsis", value: AppTab.more) {33 stack(.more) { MoreView() }34 }35 }36 .tabViewStyle(.sidebarAdaptable)37 .overlay(alignment: .bottom) { toast }38 .overlay { BoardingOverlay() }39 .animation(.snappy, value: model.toast)40 }4142 private func stack<Content: View>(_ tab: AppTab, @ViewBuilder _ content: () -> Content) -> some View {43 NavigationStack(path: model.path(for: tab)) {44 content()45 .navigationDestination(for: Route.self) { route in46 destination(route)47 }48 }49 }5051 @ViewBuilder52 private func destination(_ route: Route) -> some View {53 switch route {54 case .vehicle(let uid): VehicleView(uid: uid)55 case .brands: BrandsView()56 case .brand(let slug): BrandView(slug: slug)57 case .model(let make, let model): ModelView(makeSlug: make, modelSlug: model)58 case .cities: CitiesView()59 case .city(let slug): CityView(slug: slug)60 case .dealers: DealersView()61 case .dealer(let id): DealerView(id: id)62 case .electrics: ElectricsView()63 case .priceDrops: PriceDropsView()64 case .vin(let niv): VINDecoderView(initial: niv)65 case .recalls: RecallsView()66 case .compare: CompareView()67 case .recent: RecentView()68 case .method: MethodView()69 case .about: AboutView()70 case .privacy: LegalView(kind: .privacy)71 case .terms: LegalView(kind: .terms)72 case .settings: SettingsView()73 }74 }7576 @ViewBuilder77 private var toast: some View {78 if let text = model.toast {79 Text(text)80 .font(.subheadline.weight(.medium))81 .foregroundStyle(Theme.bg)82 .padding(.horizontal, 16).padding(.vertical, 12)83 .background(Theme.ink, in: RoundedRectangle(cornerRadius: Theme.radiusControl, style: .continuous))84 .padding(.bottom, 72)85 .transition(.move(edge: .bottom).combined(with: .opacity))86 .accessibilityAddTraits(.isStaticText)87 }88 }89}90