Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : Sources/QyvoraUI/Privacy.swift8// Module : Qyvora UI9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0412// Last Modified : 2026-12-0413//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI4243/// Full-screen brand cover shown while the application is inactive or in the app switcher, so that balances,44/// addresses and recovery material never appear in the system snapshot.45public struct PrivacyCover: View {46 public init() {}4748 public var body: some View {49 ZStack {50 QColor.background.ignoresSafeArea()51 VStack(spacing: 18) {52 QMark().frame(width: 96, height: 96)53 Text("QYVORA")54 .font(.system(.title3, design: .default, weight: .semibold))55 .kerning(6)56 .foregroundStyle(QColor.textPrimary)57 }58 .accessibilityElement(children: .ignore)59 .accessibilityLabel("QYVORA, content hidden")60 }61 }62}6364struct PrivacyCoverModifier: ViewModifier {65 let isActive: Bool66 @Environment(\.accessibilityReduceMotion) private var reduceMotion6768 func body(content: Content) -> some View {69 content70 .overlay {71 if isActive {72 PrivacyCover().transition(.opacity)73 }74 }75 // The cover must be in place before the system takes its snapshot: no animation on the way in.76 .animation(isActive || reduceMotion ? nil : .easeOut(duration: 0.18), value: isActive)77 }78}7980/// Replaces sensitive content by a placeholder when the caller hides it or when SwiftUI redacts for privacy81/// (lock-screen widgets, always-on display, `.redacted(reason: .privacy)`).82struct SensitiveModifier: ViewModifier {83 let hidden: Bool84 let placeholder: String85 @Environment(\.redactionReasons) private var redaction8687 func body(content: Content) -> some View {88 let concealed = hidden || redaction.contains(.privacy)89 content90 .opacity(concealed ? 0 : 1)91 .accessibilityHidden(concealed)92 .overlay(alignment: .leading) {93 if concealed {94 Text(placeholder)95 .foregroundStyle(QColor.textSecondary)96 .accessibilityLabel("Hidden")97 }98 }99 .privacySensitive()100 }101}102103public extension View {104 /// Covers the view with `PrivacyCover` while `isActive` is true (scene inactive or in background).105 func qPrivacyCover(isActive: Bool) -> some View { modifier(PrivacyCoverModifier(isActive: isActive)) }106107 /// Marks the view as privacy-sensitive and conceals it behind `placeholder` when `hidden` is true or when108 /// the environment redacts for privacy. The layout does not change when the content is concealed.109 func qSensitive(hidden: Bool = false, placeholder: String = "••••") -> some View {110 modifier(SensitiveModifier(hidden: hidden, placeholder: placeholder))111 }112}113114#if DEBUG115#Preview("Privacy cover") { PrivacyCover() }116#endif117