SPB Git

Repository Public

ShieldMigrationPlanView.swift 5.7 KB 119 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : QYVORA7// File             : App/Sources/Security/ShieldMigrationPlanView.swift8// Module           : Security9// 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 SwiftUI42import QyvoraQuantumShield43import QyvoraMigration44import QyvoraWallet45import QyvoraUI4647/// The migration plan built from what the Quantum Shield measured: steps the user can take now, and steps that stay48/// blocked until a network changes, each with the requirement written out.49struct ShieldMigrationPlanView: View {50    @Environment(WalletStore.self) private var store51    @State private var shield: WalletShieldReport?5253    var body: some View {54        SecurityScroll {55            WarningBanner(.info, message: shield?.disclaimer ?? QuantumShield.localCryptographyDisclaimer)56            if let additional = shield?.additionalDisclaimer {57                WarningBanner(.info, title: "Every other chain of this wallet", message: additional)58            }59            if store.snapshot?.hasWallet != true {60                EmptyStateView(systemImage: "list.bullet.clipboard", title: "No wallet on this device",61                               message: "A migration plan is built from a wallet's measured exposure.")62            } else if let plan = shield?.migrationPlan {63                QListSection("You can act on these now · \(plan.actionable.count)",64                             footnote: "Uses only what the networks validate today. Exposure that was not measured is not counted: synchronize from the Shield to measure it.",65                             separatorInset: SecShield.findingInset) {66                    if plan.actionable.isEmpty {67                        SecTextRow(text: "Nothing to do with what has been measured so far.")68                    }69                    ForEach(plan.actionable) { step in70                        stepRow(step, systemImage: "checkmark.circle", tint: QColor.positive)71                    }72                }73                .id("actionable")74                QListSection("Blocked by a protocol · \(plan.blocked.count)", footnote: "Cannot be enabled from the application: each step waits for the change named under it.",75                             separatorInset: SecShield.findingInset) {76                    if plan.blocked.isEmpty {77                        SecTextRow(text: "No blocked step.")78                    }79                    ForEach(plan.blocked) { step in80                        stepRow(step, systemImage: "lock", tint: QColor.textSecondary)81                            .accessibilityHint("Blocked, awaiting a protocol change")82                    }83                }84                .id("blocked")85                QListSection {86                    SecLinkRow(title: "Quantum Migration Engine", subtitle: "The full registry, per network", systemImage: "arrow.triangle.branch", value: EngineRoute.migration)87                }88            } else {89                SecSkeletonSection(title: "You can act on these now", rows: 2)90                SecSkeletonSection(title: "Blocked by a protocol", rows: 3)91            }92        }93        .debugScroll()94        .navigationTitle("Migration plan")95        .navigationBarTitleDisplayMode(.inline)96        .task(id: store.snapshot) {97            guard let service = store.service, store.snapshot?.hasWallet == true else { return }98            shield = await service.shieldReport()99        }100    }101102    func stepRow(_ step: MigrationPlan.Step, systemImage: String, tint: Color) -> some View {103        HStack(alignment: .firstTextBaseline, spacing: QSpace.m) {104            Image(systemName: systemImage).foregroundStyle(tint).frame(width: 22).accessibilityHidden(true)105            VStack(alignment: .leading, spacing: 4) {106                Text(step.title).font(QFont.headline).foregroundStyle(step.isActionable ? QColor.textPrimary : QColor.textSecondary)107                Text(step.detail).font(QFont.callout).foregroundStyle(QColor.textSecondary)108                if let requirement = step.blockedBy {109                    Text("Requires: \(requirement)").font(QFont.callout).foregroundStyle(QColor.textPrimary)110                }111            }112            .fixedSize(horizontal: false, vertical: true)113        }114        .frame(maxWidth: .infinity, alignment: .leading)115        .padding(.vertical, QSpace.m)116        .accessibilityElement(children: .combine)117    }118}119
Files main
Menu

Theme