SPB Git

Repository Public

AnalysisSections.swift 28.5 KB 560 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : Lou-Ka iOS9// File             : LouKa/Features/Listing/AnalysisSections.swift10// Description      : analyses du loyer de la fiche (API v3) — estimation avec11//                    son intervalle et ses facteurs, logements comparables,12//                    coût réel poste par poste avec vos hypothèses, même13//                    logement ailleurs. Chaque valeur dit d'où elle vient :14//                    observée, incluse, estimée, saisie ou inconnue.15// Module           : LouKa16// Repository       : https://git.spboucher.ai/lou-ka-ios-v317// Project Website  : https://www.lou-ka.com18// Created          : 2026-11-2819// Last Modified    : 2026-11-2820//21// =============================================================================22// AUTHOR & PROFESSIONAL AFFILIATION23// =============================================================================24//25// Author           : Simon-Pierre Boucher26// Position         : Professor of Finance27// Institution      : Université du Québec en Outaouais (UQO)28// Department       : Département des sciences administratives29// Organization     : SP Boucher30//31// Website          : https://spboucher.ai32// Git              : https://git.spboucher.ai33//34// =============================================================================35// OFFICIAL CONTACT DIRECTORY36// =============================================================================37//38// General          : info@spboucher.ai39// Professional     : contact@spboucher.ai40// Direct           : simon@spboucher.ai41// Research         : research@spboucher.ai42// Development      : dev@spboucher.ai43// Support          : support@spboucher.ai44// Security/Admin   : admin@spboucher.ai45// Notifications    : notifications@spboucher.ai46//47// Preferred Contact: support@spboucher.ai48//49// =============================================================================50// COPYRIGHT & INTELLECTUAL PROPERTY51// =============================================================================52//53// Copyright (c) 202654// Simon-Pierre Boucher55//56// All rights reserved where applicable.57//58// This file is governed by the applicable project license,59// copyright notices, institutional agreements and relevant law.60//61// Unless expressly authorized by the applicable license or62// rights holder, copying, redistribution, sublicensing,63// publication and commercial exploitation are not permitted.64//65// Existing third-party rights and notices remain unaffected.66//67// =============================================================================68// CONFIDENTIALITY & SECURITY69// =============================================================================70//71// Classification   : Public72// Distribution     : Public repository; use is governed by the project license73// Security Contact : admin@spboucher.ai74//75// Access to this source does not independently grant permission76// to redistribute or disclose confidential materials.77//78// Do not embed credentials, private keys, access tokens,79// certificates or confidential personal information.80//81// =============================================================================82// LICENSE & MAINTENANCE83// =============================================================================84//85// License          : None specified (no license file in this repository)86// Maintainer       : Simon-Pierre Boucher87// Technical Contact: dev@spboucher.ai88//89// =============================================================================90// END OF SP BOUCHER SOURCE HEADER91// =============================================================================9293import SwiftUI9495/// Chargement d'un bloc d'analyse : squelette pendant l'attente, rien si la donnée n'existe pas,96/// message et reprise en cas de panne. Aucun bloc ne s'affiche avec des valeurs inventées.97struct AnalysisLoad<T: Sendable, Content: View>: View {98    enum Phase { case loading, loaded(T), absent, failed(Error) }99    let id: String100    let title: String101    let load: @Sendable () async throws -> T102    @ViewBuilder let content: (T) -> Content103    @State private var phase: Phase = .loading104105    var body: some View {106        Group {107            switch phase {108            case .loading:109                VStack(alignment: .leading, spacing: 10) {110                    Text(title).font(.editorial(20)).foregroundStyle(Theme.ink)111                    Skeleton(height: 96)112                }113                .padding(.bottom, 30)114                .accessibilityLabel("\(title), chargement")115            case .loaded(let v):116                content(v).padding(.bottom, 30).transition(.opacity)117            case .absent:118                Color.clear.frame(height: 1)119            case .failed(let e):120                VStack(alignment: .leading, spacing: 8) {121                    Text(title).font(.editorial(20)).foregroundStyle(Theme.ink)122                    Label(e.localizedDescription, systemImage: "exclamationmark.triangle").font(.footnote).foregroundStyle(Theme.ink2)123                    Button("Réessayer") { Task { await run() } }.font(.subheadline.weight(.semibold))124                }125                .padding(.bottom, 30)126            }127        }128        .task(id: id) { await run() }129    }130131    private func run() async {132        do {133            let v = try await load()134            withAnimation(.easeOut(duration: Theme.durStd)) { phase = .loaded(v) }135        } catch is CancellationError {136        } catch let e as APIError {137            switch e {138            case .notFound, .gone: phase = .absent139            case .api(let status, _, _, _, _) where status == 404: phase = .absent   // no_estimate140            default: phase = .failed(e)141            }142        } catch {143            phase = .failed(error)144        }145    }146}147148/// Marque de provenance : une forme par statut, jamais la couleur seule.149struct ProvenanceMark: View {150    let status: String151    var body: some View {152        let (icon, color): (String, Color) = switch status {153        case "observe": ("circle.fill", Theme.ink2)154        case "inclus": ("checkmark", Theme.brand)155        case "estime": ("circle.dotted", Theme.dataEstimate)156        case "saisi": ("pencil", Theme.info)157        default: ("questionmark", Theme.ink3)158        }159        Image(systemName: icon).font(.system(size: 9, weight: .bold)).foregroundStyle(color).frame(width: 14)160            .accessibilityHidden(true)161    }162}163164// MARK: - Estimation165166struct ValuationSection: View {167    let listing: Listing168    @State private var showLimits = false169170    var body: some View {171        let uid = listing.uid172        AnalysisLoad(id: "val-\(uid)", title: "Estimation du loyer") { try await APIClient.shared.valuation(uid) } content: { v in173            VStack(alignment: .leading, spacing: 14) {174                SectionHeader(eyebrow: "Analyse", title: "Estimation du loyer",175                              subtitle: v.definition ?? "Loyer de marché affiché : ni expertise officielle, ni loyer signé.") {176                    NavigationLink(value: Route.fairValueGuide) { Image(systemName: "info.circle").foregroundStyle(Theme.ink3).frame(width: 44, height: 44) }177                        .accessibilityLabel("Comment l'estimation est calculée")178                }179                VStack(alignment: .leading, spacing: 14) {180                    VStack(alignment: .leading, spacing: 8) {181                        VStack(alignment: .leading, spacing: 2) {182                            Text("Loyer estimé").font(.caption).foregroundStyle(Theme.ink3)183                            Text("≈ \(Fmt.money(v.estimate))").font(.display(28, weight: .semibold)).num().foregroundStyle(Theme.ink)184                                .lineLimit(1).minimumScaleFactor(0.7)185                        }186                        if let verdict = v.verdict {187                            VerdictPill(verdict: verdict, deviation: v.deviationPct.map { $0 / 100 }, large: true)188                        } else {189                            Text("Sans verdict").font(.system(size: 14, weight: .semibold)).foregroundStyle(Theme.ink3)190                                .padding(.horizontal, 12).padding(.vertical, 7)191                                .overlay(RoundedRectangle(cornerRadius: Theme.radiusTag, style: .continuous).strokeBorder(Theme.ink3, style: StrokeStyle(lineWidth: 1, dash: [3, 3])))192                        }193                    }194                    if let price = v.price ?? listing.plausiblePrice {195                        FairValueGauge(price: price, fv: v.estimate, low: v.low, high: v.high, verdict: v.verdict)196                    }197                    Text("Environ \(Int((v.level * 10).rounded())) annonces comparables sur 10 sont affichées entre \(Fmt.money(v.low)) et \(Fmt.money(v.high)).")198                        .font(.footnote).num().foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)199                    if let t = v.verdictText {200                        Text(t).font(.footnote.weight(.medium)).foregroundStyle(Theme.color(for: v.verdict)).fixedSize(horizontal: false, vertical: true)201                    } else if !v.noVerdictReasons.isEmpty {202                        Text("Pas de verdict : " + v.noVerdictReasons.joined(separator: " ; ") + ".")203                            .font(.footnote).foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)204                    }205                    HStack(spacing: 14) {206                        if let c = v.confidenceLabel { Label(c, systemImage: confidenceIcon(v.confidence)).font(.caption.weight(.medium)).foregroundStyle(Theme.ink2) }207                        if let n = v.comparables { Text(Fmt.plural(n, "comparable proche", "comparables proches")).font(.caption).num().foregroundStyle(Theme.ink3) }208                    }209                }210                .cardStyle()211212                if !v.factors.isEmpty { factors(v) }213214                DisclosureGroup(isExpanded: $showLimits) {215                    VStack(alignment: .leading, spacing: 8) {216                        ForEach(v.limits, id: \.self) { l in217                            Text("· " + l).font(.caption).foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)218                        }219                        if let m = v.modelVersion {220                            Text("Modèle \(m)\(v.trainedAt.map { ", calibré le \(Fmt.isoDay($0, year: true))" } ?? "")\(v.mae.map { ". Erreur moyenne hors échantillon : \(Fmt.money($0))" } ?? "")\(v.coverage.map { ", couverture mesurée de la fourchette : \(Fmt.dec($0, 1)) %" } ?? "").")221                                .font(.caption).num().foregroundStyle(Theme.ink3).fixedSize(horizontal: false, vertical: true)222                        }223                    }224                    .padding(.top, 8)225                } label: {226                    Text("Limites de l'estimation").font(.subheadline.weight(.semibold)).foregroundStyle(Theme.ink)227                }228                .tint(Theme.ink2)229            }230        }231    }232233    private func confidenceIcon(_ c: String?) -> String {234        switch c {235        case "haute": "chart.bar.fill"236        case "moyenne": "chart.bar"237        default: "chart.bar.xaxis"238        }239    }240241    /// Facteurs explicatifs : effet de chaque groupe de variables, en dollars par mois, autour d'un logement type.242    private func factors(_ v: Valuation) -> some View {243        let shown = v.factors.filter { abs($0.effect) >= 1 }244        let maxAbs = max(shown.map { abs($0.effect) }.max() ?? 1, 1)245        return VStack(alignment: .leading, spacing: 10) {246            Text("Ce qui explique l'estimation").font(.subheadline.weight(.semibold)).foregroundStyle(Theme.ink)247            if let r = v.referenceEstimate {248                Text("Point de départ : \(Fmt.money(r)) pour un \(v.referenceDescription ?? "logement type"). Chaque ligne ajoute ou retire des dollars par mois.")249                    .font(.caption).num().foregroundStyle(Theme.ink3).fixedSize(horizontal: false, vertical: true)250            }251            VStack(spacing: 0) {252                ForEach(shown) { f in253                    VStack(alignment: .leading, spacing: 5) {254                        HStack(alignment: .firstTextBaseline) {255                            Text(f.label).font(.footnote.weight(.medium)).foregroundStyle(Theme.ink)256                            Spacer(minLength: 8)257                            Text("\(f.effect > 0 ? "+" : "−")\(Fmt.int(abs(f.effect))) $").font(.footnote.weight(.semibold)).num()258                                .foregroundStyle(Theme.ink)259                        }260                        // barre divergente : à droite ce qui hausse l'estimation, à gauche ce qui la baisse261                        GeometryReader { geo in262                            let half = geo.size.width / 2263                            let w = max(2, half * CGFloat(abs(f.effect) / maxAbs))264                            ZStack(alignment: .leading) {265                                Rectangle().fill(Theme.line).frame(height: 1).offset(y: 3)266                                Rectangle().fill(Theme.line2).frame(width: 1, height: 9).offset(x: half)267                                RoundedRectangle(cornerRadius: 1.5).fill(f.effect > 0 ? Theme.data2 : Theme.good)268                                    .frame(width: w, height: 7).offset(x: f.effect > 0 ? half : half - w, y: 1)269                            }270                        }271                        .frame(height: 9)272                        if let val = f.value { Text(val).font(.caption2).foregroundStyle(Theme.ink3).lineLimit(2) }273                    }274                    .padding(.vertical, 9)275                    .accessibilityElement(children: .ignore)276                    .accessibilityLabel("\(f.label) : \(f.effect > 0 ? "plus" : "moins") \(Fmt.int(abs(f.effect))) dollars par mois. \(f.value ?? "")")277                    Divider().overlay(Theme.line)278                }279            }280            let neutral = v.factors.filter { abs($0.effect) < 1 }.map(\.label)281            if !neutral.isEmpty {282                Text("Sans effet mesurable ici : \(neutral.joined(separator: ", ").lowercased()).").font(.caption).foregroundStyle(Theme.ink3)283                    .fixedSize(horizontal: false, vertical: true)284            }285        }286    }287}288289// MARK: - Comparables290291struct ComparablesSection: View {292    let listing: Listing293    @State private var expanded: String?294295    var body: some View {296        let uid = listing.uid297        AnalysisLoad(id: "cmp-\(uid)", title: "Logements comparables") {298            let c = try await APIClient.shared.comparables(uid, k: 6)299            if c.items.isEmpty { throw APIError.notFound }300            return c301        } content: { c in302            VStack(alignment: .leading, spacing: 12) {303                SectionHeader(eyebrow: "Analyse", title: "Logements comparables",304                              subtitle: "Annonces actives proches, de même grandeur. Le loyer ajusté ramène chaque comparable aux caractéristiques de ce logement.")305                VStack(spacing: 0) {306                    ForEach(c.items) { item in307                        row(item)308                        Divider().overlay(Theme.line)309                    }310                }311                if let l = c.limits { Text(l).font(.caption).foregroundStyle(Theme.ink3).fixedSize(horizontal: false, vertical: true) }312            }313        }314    }315316    private func row(_ c: Comparables.Item) -> some View {317        VStack(alignment: .leading, spacing: 6) {318            HStack(alignment: .firstTextBaseline, spacing: 8) {319                NavigationLink(value: Route.listing(c.uid)) {320                    VStack(alignment: .leading, spacing: 2) {321                        Text(c.place).font(.subheadline.weight(.medium)).foregroundStyle(Theme.ink).lineLimit(1)322                        Text([c.unit, c.areaSqft.map { "\(Fmt.int($0)) pi²" },323                              c.sameBuilding ? "même immeuble" : c.distanceKm.map { Fmt.distance($0 * 1000) }, c.levelLabel?.lowercased()]324                            .compactMap { $0 }.joined(separator: " · "))325                            .font(.caption).num().foregroundStyle(Theme.ink3).lineLimit(2)326                    }327                }328                .buttonStyle(.plain)329                Spacer(minLength: 8)330                VStack(alignment: .trailing, spacing: 2) {331                    Text(Fmt.money(c.price)).font(.subheadline.weight(.semibold)).num().foregroundStyle(Theme.ink)332                    if let a = c.adjustedPrice, let p = c.price, abs(a - p) >= 1 {333                        Text("ajusté ≈ \(Fmt.money(a))").font(.caption).num().foregroundStyle(Theme.dataEstimate)334                    }335                }336            }337            if !c.adjustments.isEmpty || !c.different.isEmpty {338                Button {339                    withAnimation(.easeOut(duration: Theme.durStd)) { expanded = expanded == c.uid ? nil : c.uid }340                } label: {341                    Label(expanded == c.uid ? "Masquer le détail" : "Voir les ajustements", systemImage: expanded == c.uid ? "chevron.up" : "chevron.down")342                        .font(.caption.weight(.semibold))343                }344                .frame(minHeight: 32)345                if expanded == c.uid {346                    VStack(alignment: .leading, spacing: 6) {347                        ForEach(c.adjustments) { a in348                            Text("\(a.label) : \(a.amount > 0 ? "+" : "−")\(Fmt.int(abs(a.amount))) $. \(a.reason ?? "")")349                                .font(.caption).num().foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)350                        }351                        if !c.different.isEmpty {352                            Text("Différences : \(c.different.joined(separator: ", ")).").font(.caption).foregroundStyle(Theme.ink3)353                                .fixedSize(horizontal: false, vertical: true)354                        }355                    }356                }357            }358        }359        .padding(.vertical, 10)360    }361}362363// MARK: - Coût réel364365struct TrueCostSection: View {366    let listing: Listing367    @Environment(AppModel.self) private var app368    @State private var editing = false369370    var body: some View {371        let uid = listing.uid372        let a = app.costAssumptions373        AnalysisLoad(id: "tc-\(uid)-\(a.hashValue)", title: "Coût réel mensuel") { try await APIClient.shared.trueCost(uid, assumptions: a) } content: { c in374            VStack(alignment: .leading, spacing: 14) {375                SectionHeader(eyebrow: "Analyse", title: "Coût réel mensuel",376                              subtitle: "Le loyer et les services, poste par poste. Un poste inconnu n'est jamais chiffré : le total est alors un minimum.")377                VStack(spacing: 0) {378                    ForEach(c.lines) { l in379                        HStack(alignment: .firstTextBaseline, spacing: 8) {380                            ProvenanceMark(status: l.status)381                            VStack(alignment: .leading, spacing: 3) {382                                Text(l.label).font(.subheadline).foregroundStyle(Theme.ink)383                                Text(l.note.map { "\(l.statusLabel). \($0)" } ?? l.statusLabel).font(.caption2).foregroundStyle(Theme.ink3)384                                    .fixedSize(horizontal: false, vertical: true)385                            }386                            Spacer(minLength: 8)387                            VStack(alignment: .trailing, spacing: 2) {388                                Text(amount(l)).font(.subheadline.weight(.semibold)).num()389                                    .foregroundStyle(l.status == "inconnu" ? Theme.ink3 : Theme.ink)390                                if l.hasRange, l.status == "estime" {391                                    Text("\(Fmt.int(l.low)) à \(Fmt.money(l.high))").font(.caption2).num().foregroundStyle(Theme.ink3)392                                }393                            }394                        }395                        .padding(.vertical, 9)396                        .accessibilityElement(children: .combine)397                        Divider().overlay(Theme.line)398                    }399                    HStack(alignment: .firstTextBaseline) {400                        Text(c.complete ? "Coût réel" : "Coût réel, au minimum").font(.subheadline.weight(.semibold)).foregroundStyle(Theme.ink)401                        Spacer()402                        Text(Fmt.money(c.monthly?.amount)).font(.display(22, weight: .semibold)).num().foregroundStyle(Theme.ink)403                        Text("/ mois").font(.caption).foregroundStyle(Theme.ink3)404                    }405                    .padding(.top, 12)406                    VStack(alignment: .leading, spacing: 4) {407                        if let m = c.monthly, let lo = m.low, let hi = m.high, hi - lo >= 1 {408                            Text("Fourchette : \(Fmt.int(lo)) à \(Fmt.money(hi)) par mois.").font(.caption).num().foregroundStyle(Theme.ink2)409                        }410                        if let an = c.annual?.amount {411                            Text("Sur 12 mois : \(Fmt.money(an))\(c.oneTime.flatMap { $0 > 0 ? ", plus \(Fmt.money($0)) de frais uniques" : nil } ?? "").")412                                .font(.caption).num().foregroundStyle(Theme.ink2)413                        }414                        if let e = c.extraAmount, e > 0 {415                            Text("Soit \(Fmt.money(e)) de plus que le loyer affiché\(c.extraPct.map { " (\(Fmt.points($0, signed: false)))" } ?? "").")416                                .font(.caption).num().foregroundStyle(Theme.ink2)417                        }418                        if !c.unknown.isEmpty {419                            Text("Non chiffré faute de donnée : \(c.unknown.joined(separator: ", ").lowercased()).").font(.caption).foregroundStyle(Theme.ink3)420                        }421                    }422                    .frame(maxWidth: .infinity, alignment: .leading)423                    .padding(.top, 8)424                }425                .cardStyle()426                Button { editing = true } label: {427                    Label(a.isEmpty ? "Saisir mes propres montants" : "Modifier mes montants (\(a.values.count))", systemImage: "pencil")428                }429                .buttonStyle(SoftButtonStyle())430                .accessibilityIdentifier("truecost.edit")431            }432        }433        .sheet(isPresented: $editing) { AssumptionsSheet() }434    }435436    private func amount(_ l: TrueCost.Line) -> String {437        switch l.status {438        case "inclus": "inclus"439        case "inconnu": "inconnu"440        default: (l.status == "estime" ? "≈ " : "") + Fmt.money(l.amount)441        }442    }443}444445/// Vos hypothèses de coût, appliquées à tous les logements et au comparateur. Gardées sur l'appareil.446struct AssumptionsSheet: View {447    @Environment(AppModel.self) private var app448    @Environment(\.dismiss) private var dismiss449    @State private var texts: [String: String] = [:]450451    var body: some View {452        NavigationStack {453            Form {454                Section {455                    ForEach(CostAssumptions.keys, id: \.self) { key in456                        HStack {457                            Text(CostAssumptions.labels[key] ?? key)458                            Spacer()459                            TextField("—", text: Binding(get: { texts[key] ?? "" }, set: { texts[key] = $0.filter(\.isNumber) }))460                                .keyboardType(.numberPad).multilineTextAlignment(.trailing).monospacedDigit().frame(width: 90)461                                .accessibilityLabel(CostAssumptions.labels[key] ?? key)462                            Text(key == "one_time" ? "$" : "$/mois").font(.footnote).foregroundStyle(Theme.ink3)463                        }464                    }465                } header: {466                    Text("Vos montants")467                } footer: {468                    Text("Jusqu'à 5 000 $ par mois par poste. Un champ vide laisse l'estimation ou l'information de l'annonce. Vos montants remplacent les estimations pour tous les logements et restent sur cet appareil ; ils sont envoyés au serveur seulement comme paramètres du calcul.")469                }470                Section {471                    Button("Effacer mes montants", role: .destructive) { texts = [:] }.disabled(texts.values.allSatisfy(\.isEmpty))472                }473            }474            .navigationTitle("Mes hypothèses")475            .navigationBarTitleDisplayMode(.inline)476            .toolbar {477                ToolbarItem(placement: .topBarLeading) { Button("Annuler") { dismiss() } }478                ToolbarItem(placement: .topBarTrailing) {479                    Button("Appliquer") {480                        var a = CostAssumptions()481                        // au-delà des bornes du serveur, le montant est ramené à la borne plutôt que refusé en silence482                        for (k, t) in texts { if let v = Double(t) { a.values[k] = min(v, CostAssumptions.limit(k)) } }483                        app.costAssumptions = a484                        dismiss()485                    }486                    .fontWeight(.semibold)487                }488            }489            .onAppear { texts = app.costAssumptions.values.mapValues { String(Int($0)) } }490        }491        .presentationDetents([.large])492    }493}494495// MARK: - Même logement ailleurs, immeuble496497struct ElsewhereSection: View {498    let listing: Listing499    @Environment(AppModel.self) private var app500501    var body: some View {502        let uid = listing.uid503        AnalysisLoad(id: "lnk-\(uid)", title: "Même logement ailleurs") {504            let l = try await APIClient.shared.links(uid)505            if l.isEmpty, l.building == nil { throw APIError.notFound }506            return l507        } content: { l in508            VStack(alignment: .leading, spacing: 12) {509                if !l.isEmpty {510                    SectionHeader(eyebrow: "Analyse", title: "Même logement ailleurs",511                                  subtitle: "Autres publications rapprochées de cette annonce. Un lien « probable » n'est pas une certitude.")512                    VStack(spacing: 0) {513                        group("Même logement, autre site", l.sameUnit)514                        group("Rapprochement probable", l.probable)515                        group("Republication dans la même source", l.republications)516                    }517                }518                if let b = l.building {519                    NavigationLink(value: Route.building(id: b.id)) {520                        HStack(spacing: 12) {521                            Image(systemName: "building.columns").foregroundStyle(Theme.brand).frame(width: 28)522                            VStack(alignment: .leading, spacing: 2) {523                                Text("Passeport de l'immeuble").font(.subheadline.weight(.semibold)).foregroundStyle(Theme.ink)524                                Text([b.address, b.city, b.certainty == "certain" ? "immeuble identifié" : b.certainty == "probable" ? "rapprochement probable" : nil]525                                    .compactMap { $0 }.joined(separator: " · ")).font(.caption).foregroundStyle(Theme.ink3)526                            }527                            Spacer()528                            Image(systemName: "chevron.right").font(.footnote.weight(.semibold)).foregroundStyle(Theme.ink3)529                        }530                        .cardStyle(padding: 14)531                    }532                    .buttonStyle(.plain)533                    .accessibilityIdentifier("listing.building")534                }535            }536        }537    }538539    @ViewBuilder540    private func group(_ title: String, _ links: [ListingLinks.Link]) -> some View {541        ForEach(links) { k in542            NavigationLink(value: Route.listing(k.uid)) {543                HStack(alignment: .firstTextBaseline) {544                    VStack(alignment: .leading, spacing: 2) {545                        Text(app.sourceName(k.source)).font(.subheadline.weight(.medium)).foregroundStyle(Theme.ink)546                        Text(title + (k.probability.map { " · probabilité \(Fmt.points($0 * 100, digits: 0, signed: false))" } ?? ""))547                            .font(.caption).num().foregroundStyle(Theme.ink3)548                    }549                    Spacer()550                    if let p = k.price { Text(Fmt.money(p)).font(.subheadline.weight(.semibold)).num().foregroundStyle(Theme.ink) }551                    Image(systemName: "chevron.right").font(.caption.weight(.semibold)).foregroundStyle(Theme.ink3)552                }553                .padding(.vertical, 10)554            }555            .buttonStyle(.plain)556            Divider().overlay(Theme.line)557        }558    }559}560
Files main
Menu

Theme