SPB Git

Repository Public License

ORIXSecureApp.swift 6.0 KB 150 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : ORIX Secure9// File             : App/Sources/Core/ORIXSecureApp.swift10// Description      : App entry point: builds the store and the app model,11//                    routes incoming links and files, applies App Lock.12// Module           : Core13// Repository       : https://git.spboucher.ai/orix-secure14// Created          : 2026-11-2115// Last Modified    : 2026-11-2116//17// =============================================================================18// AUTHOR & PROFESSIONAL AFFILIATION19// =============================================================================20//21// Author           : Simon-Pierre Boucher22// Position         : Professor of Finance23// Institution      : Université du Québec en Outaouais (UQO)24// Department       : Département des sciences administratives25// Organization     : SP Boucher26//27// Website          : https://spboucher.ai28// Git              : https://git.spboucher.ai29//30// =============================================================================31// OFFICIAL CONTACT DIRECTORY32// =============================================================================33//34// General          : info@spboucher.ai35// Professional     : contact@spboucher.ai36// Direct           : simon@spboucher.ai37// Research         : research@spboucher.ai38// Development      : dev@spboucher.ai39// Support          : support@spboucher.ai40// Security/Admin   : admin@spboucher.ai41// Notifications    : notifications@spboucher.ai42//43// Preferred Contact: support@spboucher.ai44//45// =============================================================================46// COPYRIGHT & INTELLECTUAL PROPERTY47// =============================================================================48//49// Copyright (c) 202650// Simon-Pierre Boucher51//52// All rights reserved where applicable.53//54// This file is governed by the applicable project license,55// copyright notices, institutional agreements and relevant law.56//57// Unless expressly authorized by the applicable license or58// rights holder, copying, redistribution, sublicensing,59// publication and commercial exploitation are not permitted.60//61// Existing third-party rights and notices remain unaffected.62//63// =============================================================================64// CONFIDENTIALITY & SECURITY65// =============================================================================66//67// Classification   : Public68// Distribution     : Public repository; use is governed by the project license69// Security Contact : admin@spboucher.ai70//71// Access to this source does not independently grant permission72// to redistribute or disclose confidential materials.73//74// Do not embed credentials, private keys, access tokens,75// certificates or confidential personal information.76//77// =============================================================================78// LICENSE & MAINTENANCE79// =============================================================================80//81// License          : Proprietary, all rights reserved (see license file)82// License File     : LICENSE83// Maintainer       : Simon-Pierre Boucher84// Technical Contact: dev@spboucher.ai85//86// =============================================================================87// END OF SP BOUCHER SOURCE HEADER88// =============================================================================8990import ORIXDesign91import ORIXSecureModel92import SwiftUI9394@main95struct ORIXSecureApp: App {96    @State private var model: AppModel97    @Environment(\.scenePhase) private var scenePhase9899    init() {100        // Engine text is translated by the app's string catalog.101        ORIXLocalization.bundle = .main102        let launch = LaunchOptions.current103        let settings = AppSettings(defaults: launch.defaults)104        if launch.reset { settings.reset() }105        let store: LocalStore106        do {107            store = try LocalStore(inMemory: launch.inMemory)108        } catch {109            // A store that cannot be opened must not make the diagnostics unusable: continue without persistence.110            store = (try? LocalStore(inMemory: true)) ?? { fatalError("SwiftData is unavailable: \(error)") }()111        }112        let model = AppModel(store: store, settings: settings)113        launch.apply(to: model)114        _model = State(initialValue: model)115    }116117    var body: some Scene {118        WindowGroup {119            RootView()120                .environment(model)121                .environment(model.router)122                .environment(model.settings)123                .environment(\.orixAccent, .secure)124                .tint(ORIXAccent.secure.primary)125                .preferredColorScheme(model.settings.appearance.colorScheme)126                .overlay { if model.lock.isLocked { LockScreen(lock: model.lock) } }127                .onOpenURL { handle($0) }128                .onChange(of: scenePhase) { _, phase in129                    switch phase {130                    case .background: model.lock.lockIfEnabled()131                    case .active: model.refresh()132                    default: break133                    }134                }135        }136    }137138    /// `orixsecure://analyze?url=…` opens the link analyser; a file URL ("Open in ORIX Secure") opens the file scanner.139    private func handle(_ url: URL) {140        if url.isFileURL {141            model.router.pendingFile = url142            model.router.open(.fileScanner)143        } else if url.scheme == "orixsecure", url.host() == "analyze", let components = URLComponents(url: url, resolvingAgainstBaseURL: false),144                  let link = components.queryItems?.first(where: { $0.name == "url" })?.value {145            model.router.pendingLink = link146            model.router.open(.linkAnalyzer)147        }148    }149}150
Files main
Menu

Theme