Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Valo-Plex iOS9// File : ValoPlex/App/Navigation.swift10// Description : onglets, routes et piles de navigation ; ouverture directe11// d'un écran par arguments de lancement (-VXTab, -VXOpen,12// -VXQuery, -VXAnchor, -VXCarte, -VXPlan, -VXOuverture) pour13// les captures et les tests, sans pilotage d'interface.14// Module : ValoPlex15// Repository : https://git.spboucher.ai/valo-plex-ios16// Project Website : https://www.valo-plex.com17// Created : 2026-12-0118// Last Modified : 2026-12-0119//20// =============================================================================21// AUTHOR & PROFESSIONAL AFFILIATION22// =============================================================================23//24// Author : Simon-Pierre Boucher25// Position : Professor of Finance26// Institution : Université du Québec en Outaouais (UQO)27// Department : Département des sciences administratives28// Organization : SP Boucher29//30// Website : https://spboucher.ai31// Git : https://git.spboucher.ai32//33// =============================================================================34// OFFICIAL CONTACT DIRECTORY35// =============================================================================36//37// General : info@spboucher.ai38// Professional : contact@spboucher.ai39// Direct : simon@spboucher.ai40// Research : research@spboucher.ai41// Development : dev@spboucher.ai42// Support : support@spboucher.ai43// Security/Admin : admin@spboucher.ai44// Notifications : notifications@spboucher.ai45//46// Preferred Contact: support@spboucher.ai47//48// =============================================================================49// COPYRIGHT & INTELLECTUAL PROPERTY50// =============================================================================51//52// Copyright (c) 202653// Simon-Pierre Boucher54//55// All rights reserved where applicable.56//57// This file is governed by the applicable project license,58// copyright notices, institutional agreements and relevant law.59//60// Unless expressly authorized by the applicable license or61// rights holder, copying, redistribution, sublicensing,62// publication and commercial exploitation are not permitted.63//64// Existing third-party rights and notices remain unaffected.65//66// =============================================================================67// CONFIDENTIALITY & SECURITY68// =============================================================================69//70// Classification : Public71// Distribution : Public repository; use is governed by the project license72// Security Contact : admin@spboucher.ai73//74// Access to this source does not independently grant permission75// to redistribute or disclose confidential materials.76//77// Do not embed credentials, private keys, access tokens,78// certificates or confidential personal information.79//80// =============================================================================81// LICENSE & MAINTENANCE82// =============================================================================83//84// License : None specified (no license file in this repository)85// Maintainer : Simon-Pierre Boucher86// Technical Contact: dev@spboucher.ai87//88// =============================================================================89// END OF SP BOUCHER SOURCE HEADER90// =============================================================================9192import Foundation93import Observation9495enum Onglet: String, CaseIterable, Identifiable, Sendable {96 case recherche, carte, annonces, marche, calcul, methode97 var id: String { rawValue }98 var libelle: String {99 switch self {100 case .recherche: "Recherche"101 case .carte: "Carte"102 case .annonces: "À vendre"103 case .marche: "Marché"104 case .calcul: "Calcul"105 case .methode: "Méthode"106 }107 }108}109110enum Route: Hashable, Sendable {111 case immeuble(String)112 case region(String)113 case calculateur(Depart)114 case cadre(Cadre)115}116117enum Cadre: String, Hashable, Sendable {118 case conditions, confidentialite, licences119}120121@MainActor122@Observable123final class Navigation {124 var onglet: Onglet = .recherche125 var chemins: [Onglet: [Route]] = [:]126 /// Filtre des plex à vendre, partagé pour que « Plex à vendre en Estrie » ouvre l'onglet déjà filtré.127 var filtre = API.FiltreAnnonces()128 /// Texte de recherche et ancre de défilement imposés au lancement (captures).129 var requeteInitiale = ""130 var ancre: String?131 /// Carte : position de départ « lat,lng,zoom », mode plan, à vendre seulement (captures).132 var carteDepart: (lat: Double, lng: Double, zoom: Double)?133 var cartePlan = false134 /// Geste d'ouverture figé à cet instant, en millisecondes (captures) ; « non » le saute.135 var ouvertureFigee: Double?136 var sansOuverture = false137 /// Geste de l'élévation d'une fiche figé à cet instant (captures).138 var facadeFigee: Double?139140 init(lancement: UserDefaults? = nil) {141 guard let d = lancement else { return }142 if let t = d.string(forKey: "VXTab"), let o = Onglet(rawValue: t) { onglet = o }143 if let q = d.string(forKey: "VXQuery") { requeteInitiale = q }144 ancre = d.string(forKey: "VXAnchor")145 if let r = d.string(forKey: "VXRegion") { filtre.region = r }146 if let c = d.string(forKey: "VXClasse") { filtre.classe = c }147 if let c = d.string(forKey: "VXCarte") {148 let p = c.split(separator: ",").compactMap { Double($0) }149 if p.count == 3 { carteDepart = (p[0], p[1], p[2]) }150 }151 cartePlan = d.bool(forKey: "VXPlan")152 if let f = d.string(forKey: "VXFacade") { facadeFigee = Double(f) }153 if let o = d.string(forKey: "VXOuverture") {154 if let ms = Double(o) { ouvertureFigee = ms } else { sansOuverture = true }155 }156 if let ouvrir = d.string(forKey: "VXOpen"), let route = Self.route(ouvrir) { chemins[onglet] = [route] }157 }158159 /// « immeuble/<id> », « region/<slug> », « calculateur », « cadre/<nom> ».160 static func route(_ s: String) -> Route? {161 let p = s.split(separator: "/", maxSplits: 1).map(String.init)162 switch p.first {163 case "immeuble" where p.count == 2: return .immeuble(p[1])164 case "region" where p.count == 2: return .region(p[1])165 case "calculateur": return .calculateur(.exemple)166 case "cadre" where p.count == 2: return Cadre(rawValue: p[1]).map(Route.cadre)167 default: return nil168 }169 }170171 func chemin(_ o: Onglet) -> [Route] { chemins[o] ?? [] }172173 func ouvrir(_ route: Route, dans o: Onglet? = nil) {174 let cible = o ?? onglet175 chemins[cible, default: []].append(route)176 onglet = cible177 }178179 /// Toucher l'onglet déjà affiché ramène à sa racine.180 func choisir(_ o: Onglet) {181 if onglet == o { chemins[o] = [] } else { onglet = o }182 }183184 func voirAnnonces(region: String) {185 filtre = API.FiltreAnnonces(region: region)186 chemins[.annonces] = []187 onglet = .annonces188 }189}190