Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : SP Search iOS9// File : Components/KindBadge.swift10// Description : Page-type badge (glyph and label, never colour alone) and11// the resolution-level mark.12// Module : Components13// Repository : https://git.spboucher.ai/sp-search-ios14// Project Website : https://search.spboucher.ai15// Created : 2026-12-0116// Last Modified : 2026-12-0117//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 SPSearchKit91import SwiftUI9293extension PageKind {94 var label: String {95 switch self {96 case .encyclopedia: String(localized: "Encyclopédie")97 case .documentation: String(localized: "Documentation")98 case .news: String(localized: "Actualité")99 case .article: String(localized: "Article")100 case .blog: String(localized: "Blogue")101 case .forum: String(localized: "Forum")102 case .shop: String(localized: "Boutique")103 case .government: String(localized: "Gouvernement")104 case .university: String(localized: "Université")105 case .organisation: String(localized: "Organisme")106 case .home: String(localized: "Accueil du site")107 case .page: String(localized: "Page")108 }109 }110111 var symbol: String {112 switch self {113 case .encyclopedia: "book"114 case .documentation: "doc.text"115 case .news: "newspaper"116 case .article: "text.alignleft"117 case .blog: "pencil.line"118 case .forum: "bubble.left.and.bubble.right"119 case .shop: "bag"120 case .government: "building.columns"121 case .university: "graduationcap"122 case .organisation: "building.2"123 case .home: "house"124 case .page: "doc"125 }126 }127128 /// Restrained tints of the search site (`--k-*` in web/search/src/app.css): background, then text.129 var tint: (background: Color, foreground: Color) {130 switch self {131 case .encyclopedia: (Color(light: 0xE6E2EE, dark: 0x29253D), Color(light: 0x40356E, dark: 0xCBC3EE))132 case .documentation: (Color(light: 0xDDE6EE, dark: 0x1A2938), Color(light: 0x22456A, dark: 0xA9C6E6))133 case .news: (Color(light: 0xF4DCCF, dark: 0x3A2219), Color(light: 0x8A2A12, dark: 0xF2A688))134 case .article: (Color(light: 0xEFE4D6, dark: 0x33251A), Color(light: 0x6A3C1A, dark: 0xE3BFA0))135 case .blog: (Color(light: 0xF0DEE5, dark: 0x371A26), Color(light: 0x77294A, dark: 0xECB6CB))136 case .forum: (Color(light: 0xE1EBDD, dark: 0x1D2C1B), Color(light: 0x2D5728, dark: 0xB4D6AE))137 case .shop: (Color(light: 0xF3E4CC, dark: 0x38280F), Color(light: 0x774406, dark: 0xECC690))138 case .government: (Color(light: 0xDBE8E7, dark: 0x152B2C), Color(light: 0x164D50, dark: 0xA4D2D3))139 case .university: (Color(light: 0xEAE4D0, dark: 0x2E2812), Color(light: 0x5A4810, dark: 0xDCCB90))140 case .organisation: (Color(light: 0xDFE5E9, dark: 0x1E2932), Color(light: 0x33485A, dark: 0xB7C9D8))141 case .home: (Color(light: 0xE4E3DB, dark: 0x2A2B26), Color(light: 0x3B3B33, dark: 0xD5D3C9))142 case .page: (Color(light: 0xEBE8DF, dark: 0x242520), Color(light: 0x56544B, dark: 0xB6B4A9))143 }144 }145}146147struct KindBadge: View {148 let kind: PageKind149 var body: some View {150 HStack(spacing: 5) {151 Image(systemName: kind.symbol).imageScale(.small)152 Text(verbatim: kind.label).lineLimit(1)153 }154 .font(.caption.weight(.semibold))155 .foregroundStyle(kind.tint.foreground)156 .padding(.horizontal, 7).padding(.vertical, 3)157 .background(kind.tint.background, in: RoundedRectangle(cornerRadius: 3))158 .accessibilityElement(children: .ignore)159 .accessibilityLabel(Text("Type de page : \(kind.label)"))160 }161}162163extension ResolutionTier {164 /// Only the levels where the index keeps the page's text carry a mark.165 var label: String? {166 switch self {167 case .standard: String(localized: "Standard")168 case .premium: String(localized: "Premium")169 default: nil170 }171 }172}173174struct TierMark: View {175 let tier: ResolutionTier176 var body: some View {177 if let label = tier.label {178 Text(verbatim: label)179 .font(.eyebrow).textCase(.uppercase).tracking(0.8)180 .foregroundStyle(tier == .premium ? Theme.accent : Theme.muted)181 .padding(.horizontal, 5).padding(.vertical, 2)182 .overlay(RoundedRectangle(cornerRadius: 2).stroke(tier == .premium ? Theme.accent : Theme.ruleStrong, lineWidth: 1))183 .accessibilityLabel(Text("Niveau de résolution \(label)"))184 }185 }186}187