SPB Git

Repository Public

RootView.swift 7.6 KB 178 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : Vrai-Prix iOS9// File             : VraiPrix/App/RootView.swift10// Description      : onglets adaptatifs (barre d'onglets sur iPhone, barre11//                    latérale sur iPad) et destinations partagées.12// Module           : VraiPrix13// Repository       : https://git.spboucher.ai/vrai-prix-ios-v314// Project Website  : https://www.vrai-prix.com15// Created          : 2026-11-2616// Last Modified    : 2026-11-2817//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author           : Simon-Pierre Boucher23// Position         : Professor of Finance24// Institution      : Université du Québec en Outaouais (UQO)25// Department       : Département des sciences administratives26// Organization     : SP Boucher27//28// Website          : https://spboucher.ai29// Git              : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General          : info@spboucher.ai36// Professional     : contact@spboucher.ai37// Direct           : simon@spboucher.ai38// Research         : research@spboucher.ai39// Development      : dev@spboucher.ai40// Support          : support@spboucher.ai41// Security/Admin   : admin@spboucher.ai42// Notifications    : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification   : Public69// Distribution     : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License          : None specified (no license file in this repository)83// Maintainer       : Simon-Pierre Boucher84// Technical Contact: dev@spboucher.ai85//86// =============================================================================87// END OF SP BOUCHER SOURCE HEADER88// =============================================================================8990import SwiftUI9192struct RootView: View {93    @Environment(AppModel.self) private var model94    @Environment(Library.self) private var library9596    var body: some View {97        @Bindable var model = model98        TabView(selection: $model.tab) {99            Tab("Estimer", systemImage: "magnifyingglass", value: AppTab.home) {100                stack(.home) { if model.isV3 { HomeV3View() } else { HomeView() } }101            }102            Tab("Carte", systemImage: "map", value: AppTab.map) {103                stack(.map) { MapScreen() }104            }105            Tab("Ventes", systemImage: "list.bullet.rectangle", value: AppTab.sales) {106                stack(.sales) { if model.isV3 { SalesV3View(query: SaleQuery(), root: true) } else { SalesRegistryView(filters: SaleFilters(), root: true) } }107            }108            Tab("Marché", systemImage: "chart.xyaxis.line", value: AppTab.market) {109                stack(.market) { if model.isV3 { MarketV3View() } else { MarketView() } }110            }111            Tab("Favoris", systemImage: "heart", value: AppTab.library) {112                stack(.library) { LibraryView() }113            }114        }115        .tabViewStyle(.sidebarAdaptable)116        .task { await model.refreshLevel() }117        .overlay(alignment: .bottom) { toast }118        .animation(.snappy, value: model.toast)119    }120121    private func stack<Content: View>(_ tab: AppTab, @ViewBuilder _ content: () -> Content) -> some View {122        NavigationStack(path: model.path(for: tab)) {123            content()124                .navigationDestination(for: Route.self) { route in125                    destination(route)126                }127        }128    }129130    @ViewBuilder131    private func destination(_ route: Route) -> some View {132        switch route {133        case .property(let id): if model.isV3 { PropertyV3View(id: id) } else { PropertyView(id: id) }134        case .listing(let uid): if model.isV3 { ListingV3View(uid: uid) } else { ListingView(uid: uid) }135        case .sale(let id): SaleV3View(id: id)136        case .territory(let id): TerritoryView(id: id)137        case .streetUnits(let id, let name): StreetUnitsView(id: id, name: name)138        case .indexSeries(let t, let g): IndexV3View(territory: t, genre: g)139        case .rankings: RankingsView()140        case .territories: TerritoriesView()141        case .listingsV3(let q): ListingsV3View(query: q)142        case .registryV3(let q): SalesV3View(query: q, root: false)143        case .municipality(let slug): MunicipalityView(slug: slug)144        case .municipalities: MunicipalitiesView()145        case .registry(let f): SalesRegistryView(filters: f, root: false)146        case .index: IndexView()147        case .marketTest: MarketTestView()148        case .listings(let f): ListingsView(filters: f)149        case .cost(let id, let title): CostView(id: id, title: title)150        case .methodology: if model.isV3 { MethodV3View() } else { MethodologyView() }151        case .manual: if model.isV3 { FreeEstimateView() } else { ManualEstimateView() }152        case .compare: if model.isV3 { CompareV3View() } else { CompareView() }153        case .recents: RecentsView()154        case .settings: SettingsView()155        case .about: AboutView()156        case .privacy: LegalView(kind: .privacy)157        case .terms: LegalView(kind: .terms)158        }159    }160161    @ViewBuilder162    private var toast: some View {163        if let text = model.toast {164            HStack(spacing: 10) {165                BrandSymbol(style: .mono(Theme.bg)).frame(width: 18, height: 18)166                Text(text)167            }168            .font(.subheadline.weight(.medium))169            .foregroundStyle(Theme.bg)170            .padding(.horizontal, 16).padding(.vertical, 12)171            .background(Theme.ink, in: RoundedRectangle(cornerRadius: Theme.radiusSmall, style: .continuous))172            .padding(.bottom, 72)173            .transition(.move(edge: .bottom).combined(with: .opacity))174            .accessibilityAddTraits(.isStaticText)175        }176    }177}178
Files main
Menu

Theme