// // InsightStrip.swift // Prisme // // Author: Simon-Pierre Boucher // import SwiftUI /// The understanding strip: after a page settles, Prisme shows what it /// read — instantly and deterministically (reading time, structure), then /// enriched with the page kind and essence when the local model delivers. /// This is the thesis made visible ("chaque page est comprise avant d'être /// affichée") without the user hunting for a button. One tap opens the /// reader; the × dismisses it for this page. Never a popup, never modal. struct InsightStrip: View { let insight: PageInsight let digest: PageDigest? let accent: Color let onRead: () -> Void let onDismiss: () -> Void /// Single tint for generated content, everywhere in the app (§7). private static let generated = Color(red: 0.55, green: 0.36, blue: 0.96) var body: some View { HStack(spacing: Spacing.m) { Button(action: onRead) { HStack(spacing: Spacing.m) { Image(systemName: "doc.plaintext") .font(.subheadline.weight(.semibold)) .foregroundStyle(accent) VStack(alignment: .leading, spacing: 2) { Text(headline) .font(.footnote.weight(.semibold)) .foregroundStyle(.primary) if let gist = digest?.gist, !gist.isEmpty { HStack(alignment: .top, spacing: Spacing.xs) { Image(systemName: "sparkles") .font(.caption2) .padding(.top, 2) Text(gist) .font(.caption) .italic() .lineLimit(2) } .foregroundStyle(Self.generated) } } Spacer(minLength: Spacing.s) Text("Lire") .font(.footnote.weight(.semibold)) .foregroundStyle(.white) .padding(.horizontal, Spacing.m) .padding(.vertical, Spacing.xs + 2) .background(accent, in: Capsule()) } .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityIdentifier("insight.read") Button(action: onDismiss) { Image(systemName: "xmark") .font(.caption.bold()) .foregroundStyle(.secondary) .frame(width: 28, height: 28) .contentShape(Circle()) } .buttonStyle(.plain) .accessibilityIdentifier("insight.dismiss") } .padding(.horizontal, Spacing.l) .padding(.vertical, Spacing.m) .glassEffect(.regular, in: RoundedRectangle(cornerRadius: Radius.l)) } private var headline: String { var parts: [String] = [] if let kind = digest?.kind { parts.append(kind.label) } parts.append("~\(insight.readingMinutes) min de lecture") if digest == nil, insight.sectionCount > 1 { parts.append("\(insight.sectionCount) sections") } return parts.joined(separator: " · ") } }