SPB Git

Repository Public

Navigator.swift 2.7 KB 43 lines swift

1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: App/Navigator.swift3// Description: The sidebar's sections and the current selection. Sections are fixed by the product; what each one offers is decided by what the backend really supports (each screen says so itself).4import SwiftUI56enum Section: String, CaseIterable, Identifiable, Hashable {7    case dashboard, portfolio, assets, send, receive, swap, bridge, nfts, defi, futures, agents, alerts, activity, research, security, settings8    var id: String { rawValue }9    var title: String {10        switch self {11        case .dashboard: "Tableau de bord"; case .portfolio: "Portefeuille"; case .assets: "Actifs"; case .send: "Envoyer"; case .receive: "Recevoir"12        case .swap: "Échanger"; case .bridge: "Pont inter-chaînes"; case .nfts: "NFT"; case .defi: "DeFi"; case .futures: "Contrats à terme"13        case .agents: "Agents de trading"; case .alerts: "Alertes"; case .activity: "Activité"; case .research: "Recherche"; case .security: "Sécurité"; case .settings: "Réglages"14        }15    }16    var symbol: String {17        switch self {18        case .dashboard: "square.grid.2x2"; case .portfolio: "chart.pie"; case .assets: "bitcoinsign.circle"; case .send: "arrow.up.right"; case .receive: "arrow.down.left"19        case .swap: "arrow.left.arrow.right"; case .bridge: "point.topleft.down.to.point.bottomright.curvepath"; case .nfts: "photo.on.rectangle.angled"; case .defi: "building.columns"20        case .futures: "chart.line.uptrend.xyaxis"; case .agents: "cpu"; case .alerts: "bell"; case .activity: "list.bullet.rectangle"; case .research: "magnifyingglass"21        case .security: "lock.shield"; case .settings: "gearshape"22        }23    }24    /// Sections that only read: available in offline consultation.25    var readOnly: Bool { [.dashboard, .portfolio, .assets, .receive, .nfts, .activity].contains(self) }26    static let groups: [(String, [Section])] = [27        ("Portefeuille", [.dashboard, .portfolio, .assets, .send, .receive]),28        ("Opérations", [.swap, .bridge, .nfts, .defi]),29        ("Trading", [.futures, .agents, .research]),30        ("Suivi", [.alerts, .activity, .security, .settings]),31    ]32}3334@MainActor @Observable final class Navigator {35    var section: Section = .dashboard36    /// Deep links between screens: "open the asset page of ETH on Base", "send this asset".37    var assetFocus: String?38    var sendPreset: SendPreset?39    struct SendPreset: Equatable { var network: String; var asset: String }40    func open(asset id: String) { assetFocus = id; section = .assets }41    func send(network: String, asset: String) { sendPreset = SendPreset(network: network, asset: asset); section = .send }42}43
Files main
Menu

Theme