Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Immo-Ka iOS9// File : ImmoKa/Features/Messages/MessagesView.swift10// Description : messagerie — boîte des conversations (et archives), fil de11// discussion, réponse, archiver, fermer, effacer, signaler.12// Relève au premier plan seulement ; rien n'est gardé sur13// disque. Les messages sont du texte brut14// (`Text(verbatim:)`).15// Module : ImmoKa16// Repository : https://git.spboucher.ai/immo-ka-ios-v317// Project Website : https://www.immo-ka.com18// Created : 2026-11-3019// Last Modified : 2026-11-3020//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/// « il y a 5 min », « hier », « 12 nov. ».96private func messageDate(_ ms: Int64) -> String {97 guard ms > 0 else { return "" }98 let d = Ms.date(ms)99 if Calendar.current.isDateInToday(d) { return d.formatted(.dateTime.hour().minute().locale(Fmt.locale)) }100 if Calendar.current.isDateInYesterday(d) { return "hier" }101 return d.formatted(.dateTime.day().month(.abbreviated).locale(Fmt.locale))102}103104// MARK: - Boîte105106struct MessagesView: View {107 @Environment(Account.self) private var account108 @Environment(AppModel.self) private var app109 @Environment(\.scenePhase) private var scenePhase110 @State private var archives = false111 @State private var items: [Conversation]?112 @State private var failure: String?113114 private var isBroker: Bool { account.user?.isBroker == true }115116 var body: some View {117 Group {118 if let user = account.user {119 if user.canUseMessaging { inbox } else { unavailable(user) }120 } else {121 EmptyStateView(door: .ajar, title: "Connectez-vous pour voir vos messages",122 message: "Les conversations avec les courtiers sont liées à votre compte.",123 actionTitle: "Se connecter") { app.accountSheet = true }124 .frame(maxWidth: .infinity, maxHeight: .infinity)125 }126 }127 .background(Theme.bg)128 .navigationTitle("Messages")129 .navigationBarTitleDisplayMode(.inline)130 }131132 private func unavailable(_ user: AccountUser) -> some View {133 EmptyStateView(icon: "hourglass", title: user.isBroker ? "Accès de courtier en attente" : "Confirmez votre adresse courriel",134 message: user.isBroker ? "La boîte de messages s'ouvrira quand votre accès sera approuvé. L'état de votre demande est dans Mon compte."135 : "La messagerie s'ouvre une fois l'adresse du compte confirmée.")136 .frame(maxWidth: .infinity, maxHeight: .infinity)137 }138139 private var inbox: some View {140 ScrollView {141 LazyVStack(alignment: .leading, spacing: 14) {142 SlidingSegmented(selection: $archives, options: [(false, "Boîte"), (true, "Archives")], label: "Conversations affichées")143 if isBroker {144 Text("Boîte partagée de votre accès de courtier. L'éditeur de fiche et l'inventaire sont sur le site, à immo-ka.com/pro.")145 .font(.footnote).foregroundStyle(Theme.ink3).fixedSize(horizontal: false, vertical: true)146 }147 if let failure, items == nil {148 EmptyStateView(icon: "wifi.exclamationmark", title: "Chargement impossible", message: failure, actionTitle: "Réessayer") { Task { await load() } }149 } else if let items {150 if items.isEmpty {151 EmptyStateView(door: archives ? .closed : .ajar, title: archives ? "Aucune conversation archivée" : "Aucun message pour l'instant",152 message: archives ? nil : isBroker ? "Les messages des acheteurs arriveront ici."153 : "Sur la fiche d'une propriété inscrite par un courtier vérifié, touchez « Écrire au courtier ».")154 } else {155 ForEach(items) { c in156 NavigationLink(value: Route.conversation(c.id)) { ConversationRow(conversation: c, forBroker: isBroker) }157 .buttonStyle(.plain)158 .accessibilityIdentifier("messages.row")159 }160 }161 } else {162 ForEach(0..<3, id: \.self) { _ in Skeleton(height: 84, radius: Theme.radius) }163 }164 Label(account.user?.isPhoneAccount == true165 ? "Pas de notification sur l'appareil pour l'instant, ni de courriel pour un compte lié à un numéro de cellulaire : les nouveaux messages s'affichent ici quand l'app est ouverte."166 : "Pas de notification sur l'appareil pour l'instant : un avis vous est envoyé par courriel, et la boîte se met à jour quand l'app est ouverte.", systemImage: "bell.slash")167 .font(.caption).foregroundStyle(Theme.ink3).padding(.top, 6)168 }169 .padding(20)170 .frame(maxWidth: 760).frame(maxWidth: .infinity)171 }172 .refreshable { await load() }173 // retour d'un fil (lu, archivé, effacé) : la boîte est relue tout de suite, sans attendre la minute174 .onAppear { if items != nil { Task { await load() } } }175 // au changement d'onglet (boîte, archives) et à chaque retour sur l'écran, puis toutes les 60 s au premier plan176 .task(id: archives) {177 items = nil178 await load()179 while !Task.isCancelled {180 try? await Task.sleep(for: .seconds(MessagingPolicy.inboxInterval))181 if Task.isCancelled { return }182 if MessagingPolicy.canPoll(user: account.user, active: Foreground.isActive) { await load() }183 }184 }185 }186187 private func load() async {188 guard account.user?.canUseMessaging == true else { return }189 do {190 items = try await account.messaging.conversations(archived: archives)191 failure = nil192 } catch {193 failure = AccountFailure(error).message194 }195 }196}197198private struct ConversationRow: View {199 let conversation: Conversation200 let forBroker: Bool201202 var body: some View {203 let c = conversation204 HStack(alignment: .top, spacing: 12) {205 Circle().fill(c.unread ? Theme.accent : Color.clear).frame(width: 9, height: 9).padding(.top, 6).accessibilityHidden(true)206 VStack(alignment: .leading, spacing: 4) {207 HStack(alignment: .firstTextBaseline) {208 Text(verbatim: c.counterpart(forBroker: forBroker)).font(.subheadline.weight(c.unread ? .bold : .semibold)).foregroundStyle(Theme.ink).lineLimit(1)209 Spacer(minLength: 8)210 Text(messageDate(c.updatedAt)).font(.caption).num().foregroundStyle(Theme.ink3)211 }212 if let l = c.listingLine {213 Label { Text(verbatim: l) } icon: { Image(systemName: "house") }.font(.caption).foregroundStyle(Theme.ink3).lineLimit(1)214 }215 Text(verbatim: c.lastMessage.replacingOccurrences(of: "\n", with: " ")).font(.subheadline).foregroundStyle(c.unread ? Theme.ink : Theme.ink2).lineLimit(2)216 if c.isClosed || c.isBlocked {217 Label(c.isBlocked ? "Conversation bloquée" : "Conversation fermée", systemImage: "lock").font(.caption.weight(.medium)).foregroundStyle(Theme.ink3)218 }219 }220 Image(systemName: "chevron.right").font(.footnote.weight(.semibold)).foregroundStyle(Theme.ink3).padding(.top, 4).accessibilityHidden(true)221 }222 .cardStyle(padding: 14)223 .accessibilityElement(children: .combine)224 .accessibilityLabel("\(c.unread ? "Non lu. " : "")\(c.counterpart(forBroker: forBroker))\(c.listingLine.map { ", \($0)" } ?? ""). \(c.lastMessage)")225 }226}227228// MARK: - Fil229230struct ThreadView: View {231 let id: String232 @Environment(Account.self) private var account233 @Environment(AppModel.self) private var app234 @Environment(\.scenePhase) private var scenePhase235 @Environment(\.dismiss) private var dismiss236 @State private var model: ThreadModel?237 @State private var draft = ""238 @State private var sendError: String?239 @State private var actionError: String?240 @State private var confirmDelete = false241 @State private var confirmClose = false242 @State private var reporting = false243 @FocusState private var focused: Bool244245 private var isBroker: Bool { account.user?.isBroker == true }246247 var body: some View {248 Group {249 if account.user == nil {250 EmptyStateView(door: .ajar, title: "Connectez-vous pour lire cette conversation",251 message: "Les messages sont liés à votre compte.", actionTitle: "Se connecter") { app.accountSheet = true }252 .frame(maxWidth: .infinity, maxHeight: .infinity)253 } else if let m = model {254 if m.gone {255 EmptyStateView(door: .closed, title: "Cette conversation n'existe plus", message: "Elle a été effacée.")256 .frame(maxWidth: .infinity, maxHeight: .infinity)257 } else if let c = m.conversation {258 thread(m, c)259 } else if let f = m.failure {260 EmptyStateView(icon: "wifi.exclamationmark", title: "Chargement impossible", message: f, actionTitle: "Réessayer") { Task { await m.load() } }261 .frame(maxWidth: .infinity, maxHeight: .infinity)262 } else {263 ProgressView().frame(maxWidth: .infinity, maxHeight: .infinity)264 }265 } else {266 ProgressView().frame(maxWidth: .infinity, maxHeight: .infinity)267 }268 }269 .background(Theme.bg)270 .navigationTitle(model?.conversation?.counterpart(forBroker: isBroker) ?? "Conversation")271 .navigationBarTitleDisplayMode(.inline)272 .toolbar { if let m = model, let c = m.conversation, !m.gone { ToolbarItem(placement: .primaryAction) { menu(m, c) } } }273 // chargement, puis relève toutes les 18 s tant que le fil est à l'écran et l'app au premier plan274 .task(id: account.user?.id) {275 guard account.user != nil else { model = nil; return }276 let m = model ?? ThreadModel(id: id, messaging: account.messaging)277 model = m278 await m.load()279 while !Task.isCancelled {280 try? await Task.sleep(for: .seconds(MessagingPolicy.threadInterval))281 if Task.isCancelled { return }282 await m.poll(active: Foreground.isActive)283 }284 }285 .onChange(of: scenePhase) { _, phase in286 if phase == .active, let m = model { Task { await m.poll(active: true) } }287 }288 .sheet(isPresented: $reporting) {289 ReportSheet { reason in290 try await account.messaging.report(id, reason: reason)291 app.showToast("Signalement transmis à l'équipe d'Immo-Ka")292 }293 }294 }295296 private func thread(_ m: ThreadModel, _ c: Conversation) -> some View {297 ScrollViewReader { proxy in298 ScrollView {299 LazyVStack(alignment: .leading, spacing: 10) {300 if let line = c.listingLine {301 Button { if let uid = c.uid { app.open(.listing(uid)) } } label: {302 HStack(spacing: 10) {303 Image(systemName: "house").foregroundStyle(Theme.brand).accessibilityHidden(true)304 VStack(alignment: .leading, spacing: 1) {305 Text("À propos de").font(.caption).foregroundStyle(Theme.ink3)306 Text(verbatim: line).font(.subheadline.weight(.medium)).foregroundStyle(Theme.ink).lineLimit(2).multilineTextAlignment(.leading)307 }308 Spacer(minLength: 8)309 if c.uid != nil { Image(systemName: "chevron.right").font(.footnote.weight(.semibold)).foregroundStyle(Theme.ink3).accessibilityHidden(true) }310 }311 .cardStyle(padding: 12)312 }313 .buttonStyle(.plain)314 .disabled(c.uid == nil)315 .accessibilityIdentifier("thread.listing")316 .padding(.bottom, 6)317 }318 if let actionError { AccountBanner(text: actionError) }319 ForEach(m.messages) { msg in320 MessageBubble(message: msg, brokerName: c.brokerName).id(msg.id)321 }322 Color.clear.frame(height: 1).id("fin")323 }324 .padding(.horizontal, 16).padding(.vertical, 14)325 .frame(maxWidth: 760).frame(maxWidth: .infinity)326 }327 .scrollDismissesKeyboard(.interactively)328 .onChange(of: m.messages.count) { _, _ in withAnimation(.easeOut(duration: 0.2)) { proxy.scrollTo("fin", anchor: .bottom) } }329 .onAppear { proxy.scrollTo("fin", anchor: .bottom) }330 .onChange(of: focused) { _, f in if f { withAnimation { proxy.scrollTo("fin", anchor: .bottom) } } }331 }332 .safeAreaInset(edge: .bottom, spacing: 0) { composer(m, c) }333 // alertes plutôt que feuilles d'actions : sur iPad, une feuille d'actions devient une bulle ancrée au334 // milieu du fil, facile à manquer pour une action irréversible335 .alert("Effacer cette conversation ?", isPresented: $confirmDelete) {336 Button("Effacer la conversation", role: .destructive) { act { try await account.messaging.delete(id); app.showToast("Conversation effacée"); dismiss() } }337 Button("Annuler", role: .cancel) {}338 } message: {339 Text("Elle sera effacée pour vous et pour le courtier. Cette action ne peut pas être annulée.")340 }341 .alert("Fermer cette conversation ?", isPresented: $confirmClose) {342 Button("Fermer la conversation") { act { m.apply(try await account.messaging.close(id)); app.showToast("Conversation fermée") } }343 Button("Annuler", role: .cancel) {}344 } message: {345 Text("Plus personne ne pourra y répondre. Les messages restent lisibles.")346 }347 }348349 @ViewBuilder350 private func composer(_ m: ThreadModel, _ c: Conversation) -> some View {351 VStack(alignment: .leading, spacing: 6) {352 Divider().overlay(Theme.line)353 if c.acceptsReplies {354 if let sendError { Label(sendError, systemImage: "exclamationmark.circle").font(.footnote).foregroundStyle(Theme.bad).padding(.horizontal, 16) }355 HStack(alignment: .bottom, spacing: 10) {356 TextField("Votre réponse", text: $draft, axis: .vertical)357 .lineLimit(1...5)358 .focused($focused)359 .padding(.horizontal, 12).padding(.vertical, 10)360 .background(Theme.surface, in: RoundedRectangle(cornerRadius: Theme.radiusSmall, style: .continuous))361 .overlay(RoundedRectangle(cornerRadius: Theme.radiusSmall, style: .continuous).strokeBorder(Theme.lineControl, lineWidth: 1))362 .accessibilityIdentifier("thread.reply")363 .onChange(of: draft) { _, v in if v.count > MessagingPolicy.maxLength { draft = String(v.prefix(MessagingPolicy.maxLength)) } }364 Button {365 let text = draft366 Task {367 sendError = await m.send(text)368 if sendError == nil { draft = ""; Haptics.tap() }369 }370 } label: {371 Group { if m.sending { ProgressView().tint(Theme.brandInk) } else { Image(systemName: "arrow.up").font(.system(size: 16, weight: .bold)) } }372 .foregroundStyle(Theme.brandInk).frame(width: 44, height: 44)373 .background(Theme.brand, in: RoundedRectangle(cornerRadius: Theme.radiusSmall, style: .continuous))374 }375 .buttonStyle(.plain)376 .disabled(MessagingPolicy.clean(draft) == nil || m.sending)377 .opacity(MessagingPolicy.clean(draft) == nil ? 0.5 : 1)378 .accessibilityLabel("Envoyer")379 .accessibilityIdentifier("thread.send")380 }381 .padding(.horizontal, 16)382 } else {383 Label(c.isBlocked ? "Cette conversation a été bloquée : il n'est plus possible d'y répondre."384 : c.isClosed ? "Cette conversation est fermée : il n'est plus possible d'y répondre. Les messages restent lisibles."385 : "Il n'est pas possible de répondre à cette conversation pour l'instant.",386 systemImage: "lock")387 .font(.footnote).foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)388 .padding(.horizontal, 16).padding(.vertical, 6)389 .accessibilityIdentifier("thread.closed")390 }391 }392 .padding(.bottom, 8)393 .frame(maxWidth: 760).frame(maxWidth: .infinity)394 .background(Theme.bg)395 }396397 private func menu(_ m: ThreadModel, _ c: Conversation) -> some View {398 Menu {399 Button { act { m.apply(try await account.messaging.setArchived(id, !c.archived)); app.showToast(c.archived ? "Conversation remise dans la boîte" : "Conversation archivée") } } label: {400 Label(c.archived ? "Remettre dans la boîte" : "Archiver", systemImage: c.archived ? "tray.and.arrow.up" : "archivebox")401 }402 if !c.isClosed && !c.isBlocked {403 Button { afterMenu { confirmClose = true } } label: { Label("Fermer la conversation", systemImage: "lock") }404 }405 Button { afterMenu { reporting = true } } label: { Label("Signaler", systemImage: "flag") }406 if !isBroker {407 Button(role: .destructive) { afterMenu { confirmDelete = true } } label: { Label("Effacer la conversation", systemImage: "trash") }408 }409 } label: {410 Image(systemName: "ellipsis.circle")411 }412 .accessibilityLabel("Actions de la conversation")413 .accessibilityIdentifier("thread.menu")414 }415416 /// Une alerte ou une feuille demandée depuis un menu n'est présentée qu'une fois le menu refermé : présentée417 /// pendant sa fermeture, elle s'affiche mais reste hors de l'arbre d'accessibilité (constaté sur iPad).418 private func afterMenu(_ present: @escaping @MainActor () -> Void) {419 focused = false420 Task { @MainActor in421 try? await Task.sleep(for: .milliseconds(450))422 present()423 }424 }425426 private func act(_ work: @escaping @MainActor () async throws -> Void) {427 actionError = nil428 Task { @MainActor in429 do { try await work() } catch { actionError = AccountFailure(error).message }430 }431 }432}433434/// Bulle sobre : mes messages à droite sur ardoise, les autres à gauche sur surface ; une réponse435/// automatique est une note centrée, dite comme telle.436private struct MessageBubble: View {437 let message: ChatMessage438 let brokerName: String439440 var body: some View {441 let m = message442 if m.isAutomatic {443 VStack(alignment: .leading, spacing: 4) {444 Label("Réponse automatique\(brokerName.isEmpty ? "" : " de \(brokerName)")", systemImage: "clock.arrow.2.circlepath")445 .font(.caption.weight(.semibold)).foregroundStyle(Theme.ink3)446 Text(verbatim: m.text).font(.subheadline).foregroundStyle(Theme.ink2).fixedSize(horizontal: false, vertical: true)447 }448 .padding(12)449 .frame(maxWidth: .infinity, alignment: .leading)450 .overlay(RoundedRectangle(cornerRadius: Theme.radius, style: .continuous).strokeBorder(Theme.line2, style: StrokeStyle(lineWidth: 1, dash: [4, 3])))451 .accessibilityElement(children: .combine)452 .accessibilityIdentifier("thread.auto")453 } else {454 VStack(alignment: m.mine ? .trailing : .leading, spacing: 3) {455 Text(verbatim: m.text)456 .font(.body)457 .foregroundStyle(m.mine ? Theme.brandInk : Theme.ink)458 .textSelection(.enabled)459 .padding(.horizontal, 13).padding(.vertical, 9)460 .background(m.mine ? Theme.brand : Theme.surface, in: RoundedRectangle(cornerRadius: Theme.radius, style: .continuous))461 .overlay(RoundedRectangle(cornerRadius: Theme.radius, style: .continuous).strokeBorder(m.mine ? Color.clear : Theme.line, lineWidth: 1))462 Text(verbatim: [m.mine ? "Vous" : m.author, messageDate(m.createdAt)].filter { !$0.isEmpty }.joined(separator: " · "))463 .font(.caption2).num().foregroundStyle(Theme.ink3)464 }465 .frame(maxWidth: 520, alignment: m.mine ? .trailing : .leading)466 .frame(maxWidth: .infinity, alignment: m.mine ? .trailing : .leading)467 .padding(m.mine ? .leading : .trailing, 44)468 .accessibilityElement(children: .ignore)469 .accessibilityLabel("\(m.mine ? "Vous" : m.author), \(messageDate(m.createdAt)) : \(m.text)")470 .accessibilityIdentifier(m.mine ? "thread.mine" : "thread.theirs")471 }472 }473}474475// MARK: - Signalement476477private struct ReportSheet: View {478 var submit: (String) async throws -> Void479 @Environment(\.dismiss) private var dismiss480 static let reasons = ["Pourriel ou sollicitation", "Fraude ou demande d'argent", "Propos déplacés ou harcèlement", "Autre"]481 @State private var reason = ReportSheet.reasons[0]482 @State private var details = ""483 @State private var busy = false484 @State private var failure: String?485486 var body: some View {487 NavigationStack {488 Form {489 if let failure { Section { Label(failure, systemImage: "exclamationmark.triangle").font(.subheadline).foregroundStyle(Theme.bad) } }490 Section {491 Picker("Motif", selection: $reason) { ForEach(ReportSheet.reasons, id: \.self) { Text($0).tag($0) } }492 .pickerStyle(.inline).labelsHidden()493 } header: {494 Text("Motif")495 }496 Section {497 TextField("Précisions (facultatif)", text: $details, axis: .vertical).lineLimit(3...6)498 .accessibilityIdentifier("report.details")499 } footer: {500 Text("Le signalement est transmis à l'équipe d'Immo-Ka avec les derniers messages de la conversation. L'autre personne n'en est pas avisée.")501 }502 }503 .scrollContentBackground(.hidden)504 .background(Theme.bg)505 .navigationTitle("Signaler")506 .navigationBarTitleDisplayMode(.inline)507 .toolbar {508 ToolbarItem(placement: .cancellationAction) { Button("Annuler") { dismiss() } }509 // dans la barre : toujours visible, quelle que soit la hauteur de la feuille510 ToolbarItem(placement: .confirmationAction) {511 Button {512 busy = true; failure = nil513 let d = details.trimmingCharacters(in: .whitespacesAndNewlines)514 Task {515 defer { busy = false }516 do { try await submit(d.isEmpty ? reason : "\(reason) : \(d)"); dismiss() } catch { failure = AccountFailure(error).message }517 }518 } label: {519 if busy { ProgressView() } else { Text("Envoyer").fontWeight(.semibold) }520 }521 .disabled(busy)522 .accessibilityLabel("Envoyer le signalement")523 .accessibilityIdentifier("report.submit")524 }525 }526 }527 .tint(Theme.brand)528 .presentationDetents([.medium, .large])529 }530}531532/// Ligne « Messages » avec la pastille des non-lus (Réglages, Favoris, Mon compte).533struct MessagesEntryRow: View {534 @Environment(Account.self) private var account535 var body: some View {536 let n = account.messaging.unread537 HStack(spacing: 12) {538 Image(systemName: "bubble.left.and.bubble.right").foregroundStyle(Theme.brand).frame(width: 28).accessibilityHidden(true)539 Text("Messages").foregroundStyle(Theme.ink)540 Spacer()541 if n > 0 {542 Text(Fmt.int(n)).font(.caption.weight(.bold)).num().foregroundStyle(.white)543 .padding(.horizontal, 7).frame(minWidth: 22, minHeight: 22)544 .background(Theme.accent, in: Capsule())545 .accessibilityIdentifier("messages.badge")546 }547 }548 .accessibilityElement(children: .ignore)549 .accessibilityLabel(n > 0 ? "Messages, \(Fmt.plural(n, "conversation non lue", "conversations non lues"))" : "Messages")550 }551}552