Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Lou-Ka iOS9// File : LouKa/Design/Door/DoorMark.swift10// Description : la porte Lou-Ka (symbole « Seuil ») — encadrement orange,11// panneau sur charnières à gauche, poignée, embrasure,12// seuil. Géométrie reprise du système de marque (grille 64 ×13// 64).14// Module : LouKa15// Repository : https://git.spboucher.ai/lou-ka-ios-v316// Project Website : https://www.lou-ka.com17// Created : 2026-11-2518// Last Modified : 2026-11-2819//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 SwiftUI9394/// Géométrie du symbole, d'après `brand/README.md` (viewBox 0 0 64 64). Source unique pour le logo,95/// l'icône et les animations. La boîte de la porte va de x 12,5 à 51,5 et de y 3,5 à 60 (39 × 56,5).96enum DoorGeometry {97 static let boxWidth: CGFloat = 3998 static let boxHeight: CGFloat = 56.599 /// largeur / hauteur de la porte animable (0,69)100 static let aspect: CGFloat = boxWidth / boxHeight101 /// épaisseur du cadre : 12,8 % de la largeur102 static let frame: CGFloat = 5 / boxWidth103 /// rayon de l'axe du cadre aux angles hauts (3 unités)104 static let cornerRadius: CGFloat = 3 / boxWidth105 /// seuil : trait de 3, débord de 4,5 de chaque côté de la boîte, bouts ronds106 static let thresholdHeight: CGFloat = 3 / boxWidth107 static let thresholdOverhang: CGFloat = 4.5 / boxWidth108 /// embrasure : x 17,5–46,5, y 8,5–60 (là où apparaît la photo)109 static let interiorInset: CGFloat = 5 / boxWidth110 /// poignée : diamètre 13 % de la largeur du panneau, à 13 % du bord droit, à mi-hauteur111 static let handle: CGFloat = 3.8 / 29112 static let handleInset: CGFloat = 0.13 + 1.9 / 29113 /// perspective : œil à 4,2 fois la largeur de la porte114 static let eyeDistance: CGFloat = 4.2115116 // angles des états, en degrés117 static let hoverAngle: Double = 16118 static let ajarAngle: Double = 40119 static let openAngle: Double = 96120121 /// Assombrissement du panneau qui pivote (jusqu'à 34 % de noir).122 static func panelShade(angle: Double) -> Double { 0.34 * min(1, max(0, angle / openAngle)) }123 /// Ombre sur l'intérieur : de 90 % (fermée) à 0 (ouverte).124 static func interiorShadow(angle: Double) -> Double { 0.9 * (1 - min(1, max(0, angle / openAngle))) }125}126127/// Encadrement : deux montants et un linteau, sans traverse basse.128struct DoorFrameShape: Shape {129 var radius: CGFloat130 func path(in rect: CGRect) -> Path {131 var p = Path()132 p.move(to: CGPoint(x: rect.minX, y: rect.maxY))133 p.addLine(to: CGPoint(x: rect.minX, y: rect.minY + radius))134 p.addArc(tangent1End: CGPoint(x: rect.minX, y: rect.minY), tangent2End: CGPoint(x: rect.minX + radius, y: rect.minY), radius: radius)135 p.addLine(to: CGPoint(x: rect.maxX - radius, y: rect.minY))136 p.addArc(tangent1End: CGPoint(x: rect.maxX, y: rect.minY), tangent2End: CGPoint(x: rect.maxX, y: rect.minY + radius), radius: radius)137 p.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))138 return p139 }140}141142/// Le symbole complet. `angle` = ouverture du panneau en degrés (0 fermé, 40 entrouvert, 96 ouvert).143struct DoorMark<Interior: View>: View {144 var angle: Double145 var frameColor: Color = Theme.heritageOrange146 /// charbon en thème clair, ivoire en thème sombre147 var panelColor: Color = Theme.doorPanel148 var showsThreshold = true149 /// faux : la porte épouse la taille donnée (transition depuis une photo) ; vrai : proportions du symbole150 var fixedAspect = true151 /// épaisseur du cadre en points ; nil = proportion du symbole152 var frameWidth: CGFloat?153 /// faux : pas de panneau (la photo s'étend sans porte)154 var showsPanel = true155 /// vrai : l'embrasure est assombrie tant que la porte est fermée (photo révélée par la transition) ;156 /// faux pour le symbole, dont l'embrasure laisse voir le fond clair157 var shadesInterior = false158 /// fond de l'embrasure sous l'ombre (visible quand il n'y a pas de photo)159 @ViewBuilder var interior: () -> Interior160161 var body: some View {162 GeometryReader { geo in163 let w = geo.size.width, h = geo.size.height164 let t = frameWidth ?? w * DoorGeometry.frame165 let inner = CGRect(x: t, y: t, width: max(1, w - 2 * t), height: max(1, h - t))166 // micro (≤ 20 pt de haut) : pas de poignée, seuil plus épais167 let micro = h <= 20168 ZStack(alignment: .topLeading) {169 // embrasure : ce que la porte révèle, assombri tant qu'elle est fermée170 interior()171 .frame(width: inner.width, height: inner.height)172 .overlay(Color.black.opacity(shadesInterior ? DoorGeometry.interiorShadow(angle: angle) : 0))173 .clipped()174 .offset(x: inner.minX, y: inner.minY)175 // panneau : pivote autour de son bord gauche, le bord libre s'éloigne et rapetisse176 if showsPanel, angle < 90 {177 ZStack {178 Rectangle().fill(panelColor)179 Rectangle().fill(Color.black.opacity(DoorGeometry.panelShade(angle: angle)))180 if !micro {181 Circle().fill(frameColor)182 .frame(width: inner.width * DoorGeometry.handle, height: inner.width * DoorGeometry.handle)183 .position(x: inner.width * (1 - DoorGeometry.handleInset), y: inner.height / 2)184 }185 }186 .frame(width: inner.width, height: inner.height)187 .rotation3DEffect(.degrees(angle), axis: (x: 0, y: 1, z: 0), anchor: .leading,188 perspective: max(inner.width, inner.height) / (DoorGeometry.eyeDistance * w))189 .offset(x: inner.minX, y: inner.minY)190 }191 // cadre192 DoorFrameShape(radius: w * DoorGeometry.cornerRadius)193 .stroke(frameColor, style: StrokeStyle(lineWidth: micro ? t * 1.3 : t, lineCap: .butt, lineJoin: .round))194 .frame(width: w - t, height: h - t / 2)195 .offset(x: t / 2, y: t / 2)196 // seuil : trait à bouts ronds, de la couleur du panneau197 if showsThreshold {198 let sill = w * DoorGeometry.thresholdHeight * (micro ? 1.33 : 1)199 Capsule().fill(panelColor)200 .frame(width: w * (1 + 2 * DoorGeometry.thresholdOverhang) + sill, height: sill)201 .offset(x: -w * DoorGeometry.thresholdOverhang - sill / 2, y: h - sill / 2)202 }203 }204 }205 // proportions du symbole seulement quand elles sont demandées : un rapport « nil » imposerait le206 // rapport idéal du contenu (un carré) au lieu d'épouser le cadre donné207 .modifier(DoorAspect(fixed: fixedAspect))208 }209}210211private struct DoorAspect: ViewModifier {212 let fixed: Bool213 func body(content: Content) -> some View {214 if fixed { content.aspectRatio(DoorGeometry.aspect, contentMode: .fit) } else { content }215 }216}217218/// L'angle est une donnée animable : pendant une animation, le dessin reçoit les angles intermédiaires219/// (le panneau pivote réellement, il ne saute pas à sa position finale).220extension DoorMark: @MainActor Animatable {221 var animatableData: Double {222 get { angle }223 set { angle = newValue }224 }225}226227extension DoorMark where Interior == Color {228 /// Porte du symbole : l'embrasure laisse voir le fond.229 init(angle: Double, frameColor: Color = Theme.heritageOrange, panelColor: Color = Theme.doorPanel, showsThreshold: Bool = true) {230 self.init(angle: angle, frameColor: frameColor, panelColor: panelColor, showsThreshold: showsThreshold) { Color.clear }231 }232}233234/// Logo : symbole et logotype (« Lou » couleur du texte, trait d'union atténué, « Ka » orange).235struct LouKaLogo: View {236 var height: CGFloat = 30237 var showsWordmark = true238 var body: some View {239 HStack(spacing: height * 0.28 + height * DoorGeometry.aspect * DoorGeometry.thresholdOverhang) {240 DoorMark(angle: DoorGeometry.ajarAngle).frame(height: height)241 if showsWordmark {242 (Text("Lou").foregroundStyle(Theme.ink)243 + Text("-").foregroundStyle(Theme.ink3).fontWeight(.regular)244 + Text("Ka").foregroundStyle(Theme.heritageOrange))245 .font(.editorial(height * 0.8, weight: .medium))246 }247 }248 .accessibilityElement(children: .ignore)249 .accessibilityLabel("Lou-Ka")250 }251}252253/// Indicateur de chargement (attente réelle seulement) : la porte s'entrouvre et se referme.254struct DoorLoader: View {255 var size: CGFloat = 34256 var label: String = "Chargement"257 @State private var open = false258 @Environment(\.accessibilityReduceMotion) private var reduceMotion259260 var body: some View {261 DoorMark(angle: reduceMotion ? DoorGeometry.hoverAngle : (open ? DoorGeometry.ajarAngle + 12 : 4))262 .frame(height: size)263 .padding(.horizontal, size * 0.12)264 .onAppear {265 guard !reduceMotion else { return }266 withAnimation(.easeInOut(duration: 0.8).repeatForever(autoreverses: true)) { open = true }267 }268 .accessibilityElement(children: .ignore)269 .accessibilityLabel(label)270 }271}272273/// Illustrations d'états vides : fermée = aucun résultat, entrouverte = invitation,274/// plusieurs portes = comparer, porte et cœur = favoris vides.275struct DoorIllustration: View {276 enum Kind { case closed, ajar, many, heart }277 let kind: Kind278 var size: CGFloat = 72279 @State private var settled = false280 @Environment(\.accessibilityReduceMotion) private var reduceMotion281282 var body: some View {283 HStack(alignment: .bottom, spacing: size * 0.22) {284 if kind == .many {285 DoorMark(angle: 0).frame(height: size * 0.82).opacity(0.5)286 }287 ZStack(alignment: .topTrailing) {288 DoorMark(angle: kind == .closed ? 0 : (settled || reduceMotion ? DoorGeometry.ajarAngle : 0)).frame(height: size)289 if kind == .heart {290 Image(systemName: "heart.fill").font(.system(size: size * 0.24)).foregroundStyle(Theme.heritageOrange)291 .padding(size * 0.07).background(Theme.bg, in: Circle())292 .offset(x: size * 0.3, y: -size * 0.08)293 }294 }295 if kind == .many {296 DoorMark(angle: DoorGeometry.hoverAngle).frame(height: size * 0.82).opacity(0.5)297 }298 }299 .padding(.horizontal, size * 0.2)300 .onAppear {301 // 520 ms, léger dépassement302 withAnimation(.spring(response: 0.52, dampingFraction: 0.62).delay(0.12)) { settled = true }303 }304 .accessibilityHidden(true)305 }306}307