SPB Git

Repository Public

ChatView.swift 27.2 KB 450 lines swift

1//2//  SP Chat iOS3//  File: SPChat-iOS/Features/Chat/ChatView.swift4//  Description: The conversation screen: message list with smart scrolling, banners, composer, toolbar and message sheets.5//6//  Author: Simon-Pierre Boucher7//  Contact: contact@spboucher.ai8//910import QuickLook11import SwiftUI12import UIKit13import UniformTypeIdentifiers1415struct ChatView: View {16    let session: ChatSession17    @Environment(AppEnvironment.self) private var env18    @Environment(\.scenePhase) private var scenePhase19    @Environment(\.accessibilityReduceMotion) private var reduceMotion2021    /// One contextual panel at a time (sheet on iPhone, form sheet on iPad).22    enum Panel: Identifiable {23        case models, regenerate(ChatMessage), options, prompts, variables(SavedPrompt)24        case edit(ChatMessage), select(ChatMessage), details(ChatMessage), lens(ChatMessage)25        case timeline, branches, context26        var id: String {27            switch self {28            case .models: "models"; case .regenerate(let m): "regen-\(m.id)"; case .options: "options"; case .prompts: "prompts"; case .variables(let p): "vars-\(p.id)"29            case .edit(let m): "edit-\(m.id)"; case .select(let m): "select-\(m.id)"; case .details(let m): "details-\(m.id)"; case .lens(let m): "lens-\(m.id)"30            case .timeline: "timeline"; case .branches: "branches"; case .context: "context"31            }32        }33    }3435    @State private var isNearBottom = true36    @State private var panel: Panel?37    @State private var previewURL: URL?38    @State private var artifactId: String?39    @State private var exportURL: URL?40    @State private var renameText = ""41    @State private var showRename = false42    @State private var confirmDelete = false43    @State private var dropTargeted = false44    @State private var isPreparingFile = false45    @State private var forking: ChatMessage?46    @State private var forkLabel = ""47    @State private var scrollTarget: String?4849    var body: some View {50        ScrollViewReader { proxy in51            ScrollView {52                LazyVStack(alignment: .leading, spacing: 24) {53                    if session.messages.isEmpty && session.pending.isEmpty { emptyState } else { thread }54                    Color.clear.frame(height: 1).id(Self.bottomID)55                }56                .padding(.horizontal, 16).padding(.top, 12)57                .frame(maxWidth: 760)58                .frame(maxWidth: .infinity)59            }60            // Conversation Flow: an empty conversation starts at the top (welcome screen); a thread stays anchored to61            // its last message, so streaming never shifts what is being read62            .defaultScrollAnchor(session.messages.isEmpty && session.pending.isEmpty ? .top : .bottom)63            .scrollDismissesKeyboard(.interactively)64            .onScrollGeometryChange(for: Bool.self) { g in65                g.contentSize.height - g.contentOffset.y - g.containerSize.height + g.contentInsets.bottom < 14066            } action: { _, near in isNearBottom = near }67            // follow the answer while it is written — but only if the reader has not scrolled away68            .onChange(of: session.revision) {69                guard isNearBottom else { return }70                proxy.scrollTo(Self.bottomID, anchor: .bottom)71                // content that arrives in one block after the answer (sources, follow-ups) is laid out a frame later72                Task { @MainActor in try? await Task.sleep(for: .milliseconds(80)); proxy.scrollTo(Self.bottomID, anchor: .bottom) }73            }74            .onChange(of: session.messages.count) { old, new in if new > old { withAnimation(Motion.snappy(reduceMotion)) { proxy.scrollTo(Self.bottomID, anchor: .bottom) } } }75            // first display of a loaded thread: land on its last message (rows above are lazy, their heights are estimates)76            .onChange(of: session.isLoading) { _, loading in77                guard !loading, !session.messages.isEmpty else { return }78                Task { @MainActor in try? await Task.sleep(for: .milliseconds(60)); proxy.scrollTo(Self.bottomID, anchor: .bottom); isNearBottom = true }79            }80            .onChange(of: scrollTarget) { _, id in81                guard let id else { return }82                scrollTarget = nil83                withAnimation(Motion.smooth(reduceMotion)) { proxy.scrollTo(id, anchor: .top) }84            }85            .overlay(alignment: .bottom) {86                if !isNearBottom && !session.messages.isEmpty {87                    Button { env.haptics.soften(); withAnimation(Motion.snappy(reduceMotion)) { proxy.scrollTo(Self.bottomID, anchor: .bottom) } } label: {88                        HStack(spacing: 6) {89                            Image(systemName: "arrow.down").font(.system(size: 11, weight: .bold))90                            Text(session.isBusy ? "Réponse en cours" : "Aller au dernier").font(.spCaption)91                        }92                        .foregroundStyle(Color.textPrimary).padding(.horizontal, 14).frame(minHeight: 36)93                        .floatSurface(cornerRadius: 18)94                        .frame(minHeight: 44).contentShape(.rect)95                    }96                    .buttonStyle(PressScale())97                    .padding(.bottom, 6).transition(.offset(y: 10).combined(with: .opacity))98                    .accessibilityLabel(String(localized: "Aller au dernier message"))99                    .accessibilityIdentifier("chat.jumpToLatest")100                }101            }102            .animation(Motion.snappy(reduceMotion), value: isNearBottom)103        }104        .background(Color.appBackground)105        .safeAreaInset(edge: .bottom, spacing: 0) {106            VStack(spacing: 6) {107                banners108                ChatComposer(session: session, onSend: send, onShowPrompts: { panel = .prompts }, onShowModels: { panel = .models }, onShowOptions: { panel = .options },109                             onUsePrompt: use, focusToken: env.router.focusComposerToken, dropTargeted: dropTargeted)110            }111        }112        .onDrop(of: [UTType.image, .pdf, .fileURL, .plainText], isTargeted: $dropTargeted) { providers in113            env.haptics.soften()114            AttachmentIntake(session: session, compress: env.preferences.compressImages).add(providers: providers); return true115        }116        .navigationBarTitleDisplayMode(.inline)117        .toolbar { toolbar }118        .task(id: session.id) { await session.load(); consumePendingText() }119        .onChange(of: env.router.pendingComposerText) { consumePendingText() }120        .onChange(of: env.router.pendingPanel, initial: true) { consumePendingPanel() }121        .onChange(of: session.messages.isEmpty) { consumePendingPanel() }122        .onChange(of: scenePhase) { _, phase in if phase == .active { Task { await session.resume() } } }123        .sheet(item: $panel) { p in panelView(p) }124        .sheet(item: Binding(get: { artifactId.map(IdentifiedString.init) }, set: { artifactId = $0?.value })) { a in ArtifactSheet(artifactId: a.value) }125        .sheet(item: Binding(get: { exportURL.map(IdentifiedURL.init) }, set: { exportURL = $0?.url })) { u in ActivityView(items: [u.url]) }126        .quickLookPreview($previewURL)127        .alert("Renommer la conversation", isPresented: $showRename) {128            TextField("Titre", text: $renameText)129            Button("Annuler", role: .cancel) {}130            Button("Renommer") { let t = renameText.trimmingCharacters(in: .whitespacesAndNewlines); if !t.isEmpty { Task { await session.update(ConversationPatch(title: String(t.prefix(200)))) } } }131        }132        .alert("Bifurquer à partir d’ici", isPresented: Binding(get: { forking != nil }, set: { if !$0 { forking = nil } })) {133            TextField("Nom de la branche (facultatif)", text: $forkLabel)134            Button("Annuler", role: .cancel) { forking = nil }135            Button("Créer la branche") {136                guard let m = forking else { return }137                let label = forkLabel; forking = nil138                Task { if let id = await session.fork(at: m, label: label) { env.haptics.success(); env.open(id) } }139            }140        } message: { Text("Une nouvelle conversation reprend le fil jusqu’à ce message. L’originale n’est pas modifiée.") }141        .confirmationDialog("Supprimer cette conversation ?", isPresented: $confirmDelete, titleVisibility: .visible) {142            Button("Supprimer", role: .destructive) { if let c = session.conversation { Task { await env.conversations.delete(c) } } }143        } message: { Text("Ses messages et ses fichiers seront supprimés du serveur, sur tous tes appareils.") }144    }145146    private static let bottomID = "thread.bottom"147    private var options: SendOptions { env.sendOptions }148149    @ViewBuilder private func panelView(_ p: Panel) -> some View {150        switch p {151        case .models: ModelSheet(purpose: .select).presentationDetents([.large])152        case .regenerate(let m):153            ModelSheet(purpose: .pick(title: String(localized: "Régénérer avec…"), current: m.modelId) { model in regenerate(m, with: model.id) }).presentationDetents([.large])154        case .options: TurnOptionsSheet().presentationDetents([.medium, .large])155        case .prompts: PromptLibraryView { p in use(p) }.presentationDetents([.medium, .large])156        case .variables(let prompt): PromptVariablesSheet(prompt: prompt) { text in insert(text) }.presentationDetents([.medium, .large])157        case .edit(let m): EditMessageSheet(message: m) { text in session.edit(m, text: text, options: options) }158        case .select(let m): SelectTextSheet(text: m.text)159        case .details(let m): MessageDetailsSheet(message: m, model: env.catalog.model(m.modelId)).presentationDetents([.medium, .large])160        case .lens(let m): LensSheet(message: m).presentationDetents([.medium, .large])161        case .timeline: TimelineSheet(session: session) { id in scrollTarget = id }.presentationDetents([.medium, .large])162        case .branches: BranchesSheet(session: session).presentationDetents([.medium, .large])163        case .context: ContextSheet(session: session).presentationDetents([.medium, .large])164        }165    }166167    private func send() {168        guard session.canSend else { return }169        env.haptics.tap()170        session.sendComposer(options: options)171        isNearBottom = true172    }173174    /// A saved prompt is inserted as is, or after its `{{variables}}` were filled.175    private func use(_ p: SavedPrompt) {176        env.prompts.markUsed(p)177        if p.variables.isEmpty { insert(p.body) }178        else { panel = nil; Task { try? await Task.sleep(for: .milliseconds(350)); panel = .variables(p) } }179    }180    private func insert(_ text: String) {181        session.composerText += (session.composerText.isEmpty ? "" : "\n") + text182        env.router.focusComposerToken += 1183    }184185    private func regenerate(_ m: ChatMessage, with modelId: String) {186        var o = options187        o.routingMode = .manual; o.presetId = nil; o.modelId = modelId188        // an effort the other model does not list would only come back as « ignoré »189        if let e = o.effort, let levels = env.catalog.model(modelId)?.effortLevels, !levels.isEmpty, !levels.contains(e.rawValue) { o.effort = nil }190        env.haptics.tap()191        session.regenerate(m, options: o)192    }193194    /// Opens the panel a deep link or the command center asked for, once the conversation is on screen.195    private func consumePendingPanel() {196        guard env.router.current === session, let name = env.router.pendingPanel else { return }197        let next: Panel?198        switch name {199        case "models": next = .models200        case "timeline": next = session.conversationId == nil ? nil : .timeline201        case "branches": next = session.conversationId == nil ? nil : .branches202        case "context": next = session.conversationId == nil ? nil : .context203        case "lens": next = session.messages.last(where: { $0.role == .assistant && !$0.text.isEmpty && !$0.isStreaming }).map(Panel.lens)204        default: next = nil; env.router.pendingPanel = nil205        }206        guard let next else { return }            // not loaded yet: retried when the messages arrive207        env.router.pendingPanel = nil208        panel = next209    }210211    private func consumePendingText() {212        guard env.router.current === session, let text = env.router.pendingComposerText else { return }213        env.router.pendingComposerText = nil214        session.composerText += (session.composerText.isEmpty ? "" : "\n") + text215    }216217    // MARK: thread218219    @ViewBuilder private var thread: some View {220        // sibling versions per (parent, role), computed once per render221        let versions = Dictionary(grouping: session.allMessages.sorted { $0.createdAt < $1.createdAt }, by: { "\($0.parentId ?? "∅")|\($0.role.rawValue)" }).mapValues { $0.map(\.id) }222        let lastId = session.messages.last?.id223        let quick = quickModels224        ForEach(session.messages) { m in225            ChatBubble(message: m, versions: versions["\(m.parentId ?? "∅")|\(m.role.rawValue)"] ?? [m.id],226                       identity: ModelIdentity(model: env.catalog.model(m.modelId), modelId: m.modelId, provider: m.provider),227                       quickModels: m.role == .assistant ? quick.filter { $0.id != m.modelId } : [],228                       isLast: m.id == lastId, canAct: !session.isBusy && !session.isShowingCache,229                       showReasoning: env.preferences.showReasoning, showStats: env.preferences.showMessageStats, showFollowUps: env.settings.followUpsEnabled,230                       isSpeaking: env.speech.isActive(m.id), actions: actions)231                .equatable()232                .id(m.id)233                // Conversation Flow: a new message rises 8 pt and fades in234                .transition(reduceMotion ? .opacity : .asymmetric(insertion: .offset(y: 8).combined(with: .opacity), removal: .opacity))235        }236        .animation(Motion.snappy(reduceMotion), value: session.messages.map(\.id))237        ForEach(session.pending) { item in PendingBubble(item: item, online: env.network.isOnline, retry: { session.sendQueued(item) }, recall: { session.recall(item) }, discard: { session.discard(item) }) }238        if session.phase == .sending || (session.phase == .reconnecting && session.messages.last?.role == .user) {239            HStack(spacing: 8) { PresenceDots(); if session.phase == .reconnecting { Text("Reconnexion…").font(.footnote).foregroundStyle(Color.muted) } }240        }241    }242243    /// Models offered in « régénérer avec » : the dock, then favourites, then recents (5 at most).244    private var quickModels: [ChatBubble.QuickModel] {245        var seen = Set<String>(); var out: [ChatBubble.QuickModel] = []246        for m in env.catalog.dockModels + env.catalog.favorites + env.catalog.recents where seen.insert(m.id).inserted {247            out.append(.init(id: m.id, name: m.displayName, route: m.route)); if out.count == 5 { break }248        }249        return out250    }251252    private var actions: MessageActions {253        MessageActions(254            copy: { m in UIPasteboard.general.string = m.text; env.haptics.soften() },255            regenerate: { m in env.haptics.tap(); session.regenerate(m, options: options) },256            regenerateWith: { m, id in if let id { regenerate(m, with: id) } else { panel = .regenerate(m) } },257            edit: { m in panel = .edit(m) },258            selectText: { m in panel = .select(m) },259            speak: { m in env.speech.toggle(messageId: m.id, text: m.text, voice: env.preferences.ttsVoice) },260            fork: { m in forkLabel = ""; forking = m },261            lens: { m in panel = .lens(m) },262            details: { m in panel = .details(m) },263            followUp: { text in264                guard !session.isBusy else { return }265                env.haptics.tap()266                session.send(text: text, attachments: [], options: options, requestId: ChatAPI.requestId()); isNearBottom = true267            },268            switchVersion: { id in env.haptics.selection(); Task { await session.switchBranch(to: id) } },269            resolveTools: { m, approve, deny in session.resolveToolCalls(on: m, approve: approve, deny: deny) },270            openAttachment: { id, name in open(attachment: id, name: name) },271            openArtifact: { id in artifactId = id })272    }273274    private func open(attachment id: String, name: String) {275        guard !isPreparingFile else { return }276        isPreparingFile = true277        Task {278            defer { isPreparingFile = false }279            do { previewURL = try await env.files.fileURL(for: id, filename: name) }280            catch { session.error = (error as? APIError)?.message ?? String(localized: "Fichier indisponible.") }281        }282    }283284    // MARK: empty state285286    private var emptyState: some View {287        VStack(spacing: 16) {288            if session.isLoading { ProgressView().controlSize(.large).padding(.top, 120) }289            else if let e = session.loadError {290                ContentUnavailableView { Label("Conversation indisponible", systemImage: "exclamationmark.bubble") } description: { Text(e) } actions: { Button("Réessayer") { Task { await session.load() } } }291            } else {292                BrandMark(size: 64).padding(.top, 44)293                Text("Que veux-tu explorer ?").font(.spDisplay).tracking(-0.4).foregroundStyle(Color.textPrimary)294                if let p = env.catalog.project(session.projectId) { Label(p.name, systemImage: "folder").font(.subheadline).foregroundStyle(Color.muted) }295                VStack(spacing: 8) {296                    ForEach(Array(Self.suggestions.enumerated()), id: \.element.title) { _, s in297                        Button { session.composerText = s.prompt; env.router.focusComposerToken += 1 } label: {298                            HStack(spacing: 12) {299                                Image(systemName: s.symbol).font(.subheadline).foregroundStyle(Color.accentColor).frame(width: 24)300                                Text(s.title).font(.subheadline).foregroundStyle(Color.textPrimary).multilineTextAlignment(.leading)301                                Spacer(minLength: 0)302                            }303                            .padding(.horizontal, 14).padding(.vertical, 12).frame(minHeight: 48)304                            .cardSurface()305                        }306                        .buttonStyle(PressScale(scale: 0.98))307                    }308                }309                .frame(maxWidth: 460).padding(.top, 4)310            }311        }312        .frame(maxWidth: .infinity)313    }314315    private static let suggestions: [(title: String, symbol: String, prompt: String)] = [316        (String(localized: "Expliquer un concept, pas à pas"), "lightbulb", String(localized: "Explique-moi, pas à pas et avec un exemple concret : ")),317        (String(localized: "Relire et améliorer un texte"), "text.badge.checkmark", String(localized: "Relis ce texte, corrige-le et propose une version plus claire :\n\n")),318        (String(localized: "Écrire ou déboguer du code"), "chevron.left.forwardslash.chevron.right", String(localized: "Aide-moi avec ce code. Voici ce que je veux obtenir : ")),319        (String(localized: "Analyser un document ou une image"), "doc.viewfinder", String(localized: "Analyse le fichier joint et résume les points essentiels.")),320    ]321322    // MARK: banners323324    @ViewBuilder private var banners: some View {325        VStack(spacing: 6) {326            if !env.network.isOnline {327                Banner(kind: .info, text: String(localized: "Hors ligne. Les conversations déjà téléchargées restent lisibles ; les nouveaux messages attendront le réseau."), systemImage: "wifi.slash")328            } else if session.isShowingCache, session.conversationId != nil {329                Banner(kind: .info, text: String(localized: "Copie locale\(session.cacheDate.map { " du " + $0.formatted(date: .abbreviated, time: .shortened) } ?? "") : serveur injoignable."), systemImage: "externaldrive.badge.xmark")330            }331            if let w = session.warning { Banner(kind: .warning, text: w) { session.warning = nil } }332            if let e = session.error { Banner(kind: .error, text: e) { session.error = nil } }333            if let e = env.speech.lastError { Banner(kind: .error, text: e) { env.speech.lastError = nil } }334        }335        .padding(.horizontal, 12).frame(maxWidth: 760)336        .animation(.snappy(duration: 0.2), value: session.error)337        .animation(.snappy(duration: 0.2), value: session.warning)338    }339340    // MARK: toolbar — title · command center · conversation menu · new341342    @ToolbarContentBuilder private var toolbar: some ToolbarContent {343        ToolbarItem(placement: .principal) {344            VStack(spacing: 0) {345                Text(session.conversationId == nil ? String(localized: "Nouvelle conversation") : session.title).font(.subheadline.weight(.semibold)).foregroundStyle(Color.textPrimary).lineLimit(1)346                if let label = session.conversation?.branchLabel, !label.isEmpty {347                    Label(label, systemImage: "arrow.triangle.branch").font(.caption2).foregroundStyle(Color.muted).lineLimit(1)348                }349            }350            .frame(maxWidth: 260)351            .accessibilityElement(children: .combine)352            .accessibilityAddTraits(.isHeader)353            .accessibilityIdentifier("chat.title")354        }355        ToolbarItemGroup(placement: .topBarTrailing) {356            Button { env.router.sheet = .commandCenter } label: { Image(systemName: "command") }357                .accessibilityLabel(String(localized: "Centre de commandes"))358                .accessibilityIdentifier("chat.commandCenter")359            if session.conversationId != nil {360                Menu {361                    if let c = session.conversation {362                        Section(c.title) {363                            Button { renameText = c.title; showRename = true } label: { Label("Renommer", systemImage: "pencil") }364                            Button { Task { await session.update(ConversationPatch(pinned: !c.pinned)) } } label: { Label(c.pinned ? "Désépingler" : "Épingler", systemImage: c.pinned ? "pin.slash" : "pin") }365                            Button { Task { await session.update(ConversationPatch(favorite: !c.favorite)) } } label: { Label(c.favorite ? "Retirer des favoris" : "Ajouter aux favoris", systemImage: c.favorite ? "star.slash" : "star") }366                            Menu { projectPicker(c) } label: { Label("Projet", systemImage: "folder") }367                        }368                        Section {369                            Button { panel = .timeline } label: { Label("Chronologie et relecture", systemImage: "clock.arrow.circlepath") }370                            Button { panel = .branches } label: { Label("Branches", systemImage: "arrow.triangle.branch") }371                            Button { panel = .context } label: { Label("Inspecteur de contexte", systemImage: "gauge.with.dots.needle.33percent") }372                            Button {373                                env.router.arenaSeed = ArenaSeed(prompt: session.messages.last(where: { $0.role == .user })?.text ?? "", conversationId: session.conversationId, projectId: c.projectId)374                                env.router.sheet = .arena375                            } label: { Label("Comparer dans l’Arène", systemImage: "square.split.2x1") }376                        }377                        Section {378                            Button { export("md") } label: { Label("Exporter en Markdown", systemImage: "square.and.arrow.up") }379                            Button { export("json") } label: { Label("Exporter en JSON", systemImage: "curlybraces") }380                        }381                        Section {382                            Button { Task { await session.update(ConversationPatch(archived: !c.isArchived)) } } label: { Label(c.isArchived ? "Désarchiver" : "Archiver", systemImage: "archivebox") }383                            Button(role: .destructive) { confirmDelete = true } label: { Label("Supprimer", systemImage: "trash") }384                        }385                    }386                } label: { Image(systemName: "ellipsis.circle") }387                .disabled(session.conversation == nil || !env.network.isOnline)388                .accessibilityLabel(String(localized: "Actions de la conversation"))389                .accessibilityIdentifier("chat.menu")390            }391            Button { env.startNewConversation() } label: { Image(systemName: "square.and.pencil") }392                .accessibilityLabel(String(localized: "Nouvelle conversation"))393                .accessibilityIdentifier("chat.new")394        }395    }396397    @ViewBuilder private func projectPicker(_ c: Conversation) -> some View {398        Button { Task { await session.update(ConversationPatch(projectId: .some(nil))) } } label: { Label("Aucun projet", systemImage: c.projectId == nil ? "checkmark" : "") }399        ForEach(env.catalog.projects) { p in400            Button { Task { await session.update(ConversationPatch(projectId: .some(p.id))) } } label: { Label(p.name, systemImage: c.projectId == p.id ? "checkmark" : "") }401        }402    }403404    private func export(_ format: String) {405        guard let id = session.conversationId else { return }406        Task {407            do {408                let data = try await env.api.export(conversation: id, format: format)409                let name = session.title.replacingOccurrences(of: "/", with: "-").prefix(80)410                let dir = FileManager.default.temporaryDirectory.appendingPathComponent("spchat-preview/export", isDirectory: true)411                try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)412                let url = dir.appendingPathComponent("\(name).\(format)")413                try data.write(to: url, options: [.atomic, .completeFileProtectionUnlessOpen])414                exportURL = url415            } catch { session.error = (error as? APIError)?.message ?? String(localized: "Export impossible.") }416        }417    }418}419420struct IdentifiedString: Identifiable { let value: String; var id: String { value } }421struct IdentifiedURL: Identifiable { let url: URL; var id: URL { url } }422423/// A message waiting in the outbox: visibly not sent.424struct PendingBubble: View {425    let item: OutboxItem426    let online: Bool427    let retry: () -> Void428    let recall: () -> Void429    let discard: () -> Void430431    var body: some View {432        VStack(alignment: .trailing, spacing: 6) {433            Text(item.text.isEmpty ? String(localized: "\(item.attachments.count) fichier(s)") : item.text)434                .font(.body).foregroundStyle(Color.textSecondary)435                .padding(.horizontal, 14).padding(.vertical, 10)436                .background(Color.surface2.opacity(0.7), in: .rect(cornerRadius: 20, style: .continuous))437                .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).strokeBorder(Color.muted.opacity(0.5), style: StrokeStyle(lineWidth: 1, dash: [5, 4])))438            HStack(spacing: 12) {439                Label(online ? "Non envoyé" : "En attente du réseau", systemImage: "clock.arrow.circlepath").font(.caption).foregroundStyle(Color.warning)440                if online { Button("Envoyer", action: retry).font(.caption.weight(.semibold)) }441                Button("Modifier", action: recall).font(.caption.weight(.semibold))442                Button("Supprimer", role: .destructive, action: discard).font(.caption.weight(.semibold))443            }444        }445        .frame(maxWidth: .infinity, alignment: .trailing).padding(.leading, 44)446        .accessibilityElement(children: .contain)447        .accessibilityLabel(String(localized: "Message non envoyé : \(item.text)"))448    }449}450
Files main
Menu

Theme