SPB Git

Repository Public

MainShellView.swift 4.0 KB 100 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP ID & Card Vault7// File             : SPVault/Features/Shell/MainShellView.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 SwiftUI4243/// The unlocked app. It exists only while the vault is unlocked: `RootView`44/// removes it, with its router and everything it presents, at lock.45struct MainShellView: View {46    @Environment(Vault.self) private var vault47    @Environment(AppEnvironment.self) private var environment48    @State private var router = AppRouter()49    @State private var pendingDraft: PendingDraft?50    @Namespace private var cardNamespace5152    private struct PendingDraft: Identifiable {53        let id = UUID()54        var draft: ScanDraft55    }5657    var body: some View {58        @Bindable var router = router59        TabView(selection: $router.tab) {60            Tab("Wallet", systemImage: "wallet.bifold.fill", value: AppTab.wallet) { WalletView() }61            Tab("Expiry", systemImage: "calendar.badge.clock", value: AppTab.expirations) { ExpirationDashboardView() }62            Tab("Security", systemImage: "lock.shield.fill", value: AppTab.security) { SecurityCenterView() }63            Tab("Settings", systemImage: "gearshape.fill", value: AppTab.settings) { SettingsView() }64            Tab("Search", systemImage: "magnifyingglass", value: AppTab.search, role: .search) { SearchView() }65        }66        .tabBarMinimizeBehavior(.onScrollDown)67        .environment(router)68        .environment(\.cardTransitionNamespace, cardNamespace)69        .overlay(alignment: .top) { ScreenshotNoticeBanner() }70        .fullScreenCover(item: $router.openCardID) { id in71            CardDetailView(cardID: id)72                .navigationTransition(.zoom(sourceID: id, in: cardNamespace))73                .environment(router)74        }75        .fullScreenCover(isPresented: $router.showsScanner) {76            ScannerFlowView { draft in pendingDraft = PendingDraft(draft: draft) }77        }78        .sheet(item: $pendingDraft) { pending in79            CardEditorView(mode: .new(pending.draft)) { id in80                router.tab = .wallet81                Task {82                    try? await Task.sleep(for: .milliseconds(450))83                    router.open(card: id)84                }85            }86        }87        .onChange(of: router.tab) { _, _ in Haptics.shared.play(.select) }88        .task {89            Haptics.shared.play(.unlock)90            #if DEBUG91            router.apply(screen: environment.launch.screen, firstCard: vault.cards.first?.id)92            #endif93        }94    }95}9697extension UUID: @retroactive Identifiable {98    public var id: UUID { self }99}100
Files main
Menu

Theme