SPB Git

Repository Public

LockScreen.swift 4.5 KB 115 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : QYVORA7// File             : App/Sources/Lock/LockScreen.swift8// Module           : Lock9// 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 QyvoraWallet43import QyvoraUI4445/// Shown while the vault is locked. Nothing of the wallet is displayed: no balance, no address, no name.46struct LockScreen: View {47    @Environment(WalletStore.self) private var wallet48    @State private var erasing = false49    @State private var eraseError: String?50    @State private var confirmErase = false5152    var body: some View {53        ScrollView {54            VStack(spacing: 28) {55                VStack(spacing: 14) {56                    QMark().frame(width: 72, height: 72)57                    Text("QYVORA is locked")58                        .font(QFont.title)59                        .foregroundStyle(QColor.textPrimary)60                        .accessibilityAddTraits(.isHeader)61                }62                .padding(.top, 40)63                if let vault = wallet.snapshot?.vault {64                    if vault.exists {65                        UnlockPanel(vault: vault, biometricPrompt: "Unlock your QYVORA vault") {66                            Task { await wallet.refresh() }67                        }68                    } else {69                        missingVault70                    }71                } else {72                    ProgressView()73                }74            }75            .padding(.horizontal, 24)76            .padding(.bottom, 32)77            .frame(maxWidth: 480)78            .frame(maxWidth: .infinity)79        }80        .scrollBounceBehavior(.basedOnSize)81        .qScreen()82    }8384    /// The profile says a full wallet exists but its vault file is gone (erased after wrong PINs, or removed).85    var missingVault: some View {86        VStack(alignment: .leading, spacing: 16) {87            WarningBanner(.critical, title: "The vault is no longer on this device",88                          message: "It was erased after too many wrong PINs, or its file was removed. The keys cannot be read here any more. Your funds are unaffected: restore the wallet from its recovery phrase.")89            InlineError(message: eraseError)90            LoadingButton("Remove the wallet data and start over", systemImage: "arrow.counterclockwise",91                          state: erasing ? .loading : .idle, prominence: .secondary) {92                confirmErase = true93            }94        }95        .confirmationDialog("Remove the remaining wallet data from this device?", isPresented: $confirmErase, titleVisibility: .visible) {96            Button("Remove and start over", role: .destructive) { erase() }97        } message: {98            Text("Public account data, labels and settings are deleted. You will need the recovery phrase to restore the wallet.")99        }100    }101102    func erase() {103        erasing = true104        Task {105            defer { erasing = false }106            do {107                try await wallet.run { try await $0.deleteWallet() }108                await wallet.refresh()109            } catch {110                eraseError = WalletStore.message(for: error)111            }112        }113    }114}115
Files main
Menu

Theme