SPB Git

Repository Public

AppRouter.swift 3.2 KB 96 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP ID & Card Vault7// File             : SPVault/App/AppRouter.swift8// Module           : SPVault9// Repository       : https://git.spboucher.ai/sp-id-card-vault10// Project Website  : Not specified11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//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 Observation42import SwiftUI4344enum AppTab: String, Hashable, CaseIterable, Sendable {45    case wallet, expirations, security, settings, search46}4748enum SettingsRoute: String, Hashable, Sendable {49    case backup, categories, about50}5152/// Navigation state of the unlocked shell. It is created with the shell and53/// discarded with it, so nothing survives a lock.54@MainActor55@Observable56final class AppRouter {57    var tab: AppTab = .wallet58    /// Card shown in the detail screen (presented over the current tab).59    var openCardID: UUID?60    var showsScanner = false61    /// Pushed inside Settings.62    var settingsPath: [SettingsRoute] = []6364    func open(card id: UUID) {65        Haptics.shared.play(.select)66        openCardID = id67    }6869    func startScan() {70        Haptics.shared.play(.select)71        showsScanner = true72    }7374    func show(_ route: SettingsRoute) {75        tab = .settings76        settingsPath = [route]77    }7879    /// Debug launches (`-screen <name>`) jump straight to a screen for the80    /// visual audit. `firstCard` is used for the card screens.81    func apply(screen: String?, firstCard: UUID?) {82        switch screen {83        case "expirations": tab = .expirations84        case "security": tab = .security85        case "settings": tab = .settings86        case "search": tab = .search87        case "backup": show(.backup)88        case "categories": show(.categories)89        case "about": show(.about)90        case "scanner": showsScanner = true91        case "detail", "back", "fullscreen", "editor", "reveal": openCardID = firstCard92        default: break93        }94    }95}96
Files main
Menu

Theme