Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : App/Sources/Wallet/WarningAcknowledgement.swift8// Module : Wallet9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0512// Last Modified : 2026-12-0513//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 SwiftUI42import QyvoraWallet43import QyvoraUI4445/// The warnings of a review, each with the sentence the service wrote. A critical warning carries its own46/// acknowledgement control, off until the user turns it on: the identifiers collected in `acknowledged` are what the47/// service asks for before it signs (`signAndBroadcast(_:acknowledged:)`, `signColdTransaction(…acknowledged:)`), so a48/// screen that forgot a control could not sign either (QYV-APP-020, 041, 060, 082).49struct WarningAcknowledgementList: View {50 let warnings: [SendWarning]51 @Binding var acknowledged: Set<String>52 /// False where nothing is signed on this device (a watch-only wallet exports the transaction): the warnings are53 /// shown, the controls are on the device that signs.54 var showsControls = true55 /// Identifiers shown as information rather than as a warning.56 var informative: Set<String> = []5758 var body: some View {59 if !warnings.isEmpty {60 VStack(alignment: .leading, spacing: QSpace.m) {61 ForEach(warnings) { warning in62 if warning.isCritical {63 VStack(alignment: .leading, spacing: 0) {64 WarningBanner(.critical, message: warning.message)65 if showsControls {66 Toggle(isOn: Binding(get: { acknowledged.contains(warning.id) }, set: { on in67 if on { acknowledged.insert(warning.id) } else { acknowledged.remove(warning.id) }68 })) {69 Text("I have read this and want to continue").font(QFont.callout).foregroundStyle(QColor.textPrimary)70 }71 .tint(QColor.violet)72 .padding(.horizontal, QMetric.padding)73 .frame(minHeight: QMetric.minTap + 8)74 .accessibilityHint("Acknowledges this warning. Signing stays unavailable until every critical warning is acknowledged.")75 }76 }77 .id("warning-" + warning.id)78 } else {79 WarningBanner(informative.contains(warning.id) ? .info : .warning, message: warning.message)80 .id("warning-" + warning.id)81 }82 }83 }84 .qHaptic(.toggled, trigger: acknowledged)85 }86 }8788 /// True when every critical warning of the list is in `acknowledged`.89 static func isComplete(_ warnings: [SendWarning], _ acknowledged: Set<String>) -> Bool {90 warnings.allSatisfy { !$0.isCritical || acknowledged.contains($0.id) }91 }92}9394/// One explicit confirmation, drawn as a box to tick: off until the user turns it on, never set by the screen.95struct AcknowledgementCheck: View {96 let text: String97 @Binding var isOn: Bool9899 var body: some View {100 Button { isOn.toggle() } label: {101 HStack(alignment: .top, spacing: QSpace.m) {102 Image(systemName: isOn ? "checkmark.square.fill" : "square")103 .font(.title2)104 .foregroundStyle(isOn ? QColor.violet : QColor.strokeStrong)105 .accessibilityHidden(true)106 Text(text).font(QFont.callout).foregroundStyle(QColor.textPrimary).multilineTextAlignment(.leading)107 .fixedSize(horizontal: false, vertical: true)108 Spacer(minLength: 0)109 }110 .padding(QMetric.padding)111 .frame(minHeight: QMetric.minTap)112 .background(QColor.surface, in: RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous))113 .overlay(RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous).strokeBorder(isOn ? QColor.violet : QColor.stroke, lineWidth: isOn ? 1.5 : 1))114 .contentShape(Rectangle())115 }116 .buttonStyle(.plain)117 .accessibilityLabel(text)118 .accessibilityValue(isOn ? "Confirmed" : "Not confirmed")119 .accessibilityAddTraits(isOn ? .isSelected : [])120 .sensoryFeedback(.selection, trigger: isOn)121 }122}123