SPB Git

Repository Public

RootView.swift 6.2 KB 149 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : Immo-Ka Admin iOS9// File             : ImmoKaAdmin/App/RootView.swift10// Description      : l'outil — onglets sur iPhone, barre latérale sur iPad. Un11//                    `NavigationStack` par section.12// Module           : ImmoKaAdmin13// Repository       : https://git.spboucher.ai/immo-ka-admin-ios14// Project Website  : https://www.immo-ka.com15// Created          : 2026-11-3016// Last Modified    : 2026-11-3017//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author           : Simon-Pierre Boucher23// Position         : Professor of Finance24// Institution      : Université du Québec en Outaouais (UQO)25// Department       : Département des sciences administratives26// Organization     : SP Boucher27//28// Website          : https://spboucher.ai29// Git              : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General          : info@spboucher.ai36// Professional     : contact@spboucher.ai37// Direct           : simon@spboucher.ai38// Research         : research@spboucher.ai39// Development      : dev@spboucher.ai40// Support          : support@spboucher.ai41// Security/Admin   : admin@spboucher.ai42// Notifications    : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification   : Public69// Distribution     : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License          : None specified (no license file in this repository)83// Maintainer       : Simon-Pierre Boucher84// Technical Contact: dev@spboucher.ai85//86// =============================================================================87// END OF SP BOUCHER SOURCE HEADER88// =============================================================================8990import SwiftUI9192enum AdminTab: String, Hashable, CaseIterable {93    case dashboard, traffic, brokers, reports, mail, account94}9596/// Navigation partagée : le tableau de bord envoie vers une section.97@MainActor98@Observable99final class Navigator {100    var tab: AdminTab = .dashboard101    var toast: String?102103    init() {104        if let t = UserDefaults.standard.string(forKey: "IKTab"), let tab = AdminTab(rawValue: t) { self.tab = tab }105    }106107    func show(_ text: String) {108        toast = text109        Task { @MainActor in110            try? await Task.sleep(for: .seconds(2.6))111            if toast == text { toast = nil }112        }113    }114}115116struct RootView: View {117    @Environment(AdminSession.self) private var session118    @State private var nav = Navigator()119120    var body: some View {121        @Bindable var nav = nav122        TabView(selection: $nav.tab) {123            Tab("Accueil", systemImage: "square.grid.2x2", value: AdminTab.dashboard) { NavigationStack { DashboardView() } }124            Tab("Trafic", systemImage: "chart.xyaxis.line", value: AdminTab.traffic) { TrafficView() }125            Tab("Demandes", systemImage: "person.text.rectangle", value: AdminTab.brokers) { NavigationStack { BrokersView() } }126                .badge(session.me?.stats.courtiersEnAttente ?? 0)127            Tab("Signalements", systemImage: "flag", value: AdminTab.reports) { NavigationStack { ReportsView() } }128                .badge(session.me?.stats.signalementsOuverts ?? 0)129            Tab("Courrier", systemImage: "envelope", value: AdminTab.mail) { NavigationStack { MailView() } }130            Tab("Compte", systemImage: "person.badge.key", value: AdminTab.account) { NavigationStack { AccountView() } }131        }132        .tabViewStyle(.sidebarAdaptable)133        .environment(nav)134        .overlay(alignment: .bottom) {135            if let text = nav.toast {136                Text(verbatim: text)137                    .font(.subheadline.weight(.medium)).foregroundStyle(Theme.bg).multilineTextAlignment(.leading)138                    .padding(.horizontal, 16).padding(.vertical, 11)139                    .background(Theme.ink, in: RoundedRectangle(cornerRadius: Theme.radiusSmall, style: .continuous))140                    .padding(.horizontal, 20).padding(.bottom, 70)141                    .transition(.move(edge: .bottom).combined(with: .opacity))142                    .allowsHitTesting(false)   // la confirmation ne doit jamais intercepter un toucher143                    .accessibilityIdentifier("toast")144            }145        }146        .animation(.snappy, value: nav.toast)147    }148}149
Files main
Menu

Theme