Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : MacLustr SMS Gateway9// File : ios/MacLustrSMS/UI/RootView.swift10// Description : Racine : lancement, connexion par clé d'accès, onglets,11// verrou local.12// Module : ios13// Repository : https://git.spboucher.ai/maclustr-sms14// Project Website : https://sms.spboucher.ai15// 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: admin@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 SwiftUI9192struct RootView: View {93 @Environment(AppModel.self) private var model94 var body: some View {95 ZStack {96 Theme.bg.ignoresSafeArea()97 switch model.phase {98 case .launching: LogoMark(size: 72)99 case .signedOut: LoginView()100 case .signedIn: MainTabs()101 }102 if model.locked && model.phase == .signedIn { LockView() }103 }104 }105}106107struct LockView: View {108 @Environment(AppModel.self) private var model109 var body: some View {110 ZStack {111 Theme.bg.ignoresSafeArea()112 VStack(spacing: 18) {113 LogoMark(size: 64)114 Text("MacLustr SMS est verrouillé").font(.headline).foregroundStyle(Theme.text)115 Button("Déverrouiller") { Task { await model.unlock() } }.buttonStyle(QuietButtonStyle())116 }117 }118 .task { await model.unlock() }119 }120}121122struct LoginView: View {123 @Environment(AppModel.self) private var model124 @State private var showEnroll = false125 @State private var link = ""126 var body: some View {127 VStack(spacing: 0) {128 Spacer()129 LogoMark(size: 84)130 Text("MacLustr SMS").font(.largeTitle.weight(.semibold)).foregroundStyle(Theme.text).padding(.top, 14)131 Text("Passerelle SMS privée").font(.subheadline).foregroundStyle(Theme.muted).padding(.top, 2)132 Spacer()133 VStack(spacing: 12) {134 if let e = model.authError { Banner(text: e, tone: .bad, symbol: "exclamationmark.circle").accessibilityIdentifier("authError") }135 Button { Task { await model.login() } } label: { Label("Se connecter avec une clé d'accès", systemImage: "person.badge.key") }136 .buttonStyle(PrimaryButtonStyle()).disabled(model.busy).accessibilityIdentifier("loginButton")137 Button("J'ai un lien d'enrôlement") { link = UIPasteboard.general.hasURLs ? (UIPasteboard.general.url?.absoluteString ?? "") : ""; showEnroll = true }138 .font(.subheadline).foregroundStyle(Theme.muted).padding(.top, 4)139 Text("Accès réservé à l'administrateur de sms.spboucher.ai.").font(.caption).foregroundStyle(Theme.faint).padding(.top, 8)140 }141 .padding(24)142 }143 .sheet(isPresented: $showEnroll) {144 NavigationStack {145 Screen {146 Text("Collez le lien à usage unique reçu de l'opérateur. Une clé d'accès sera créée sur cet iPhone (Face ID ou code), sans mot de passe.").font(.subheadline).foregroundStyle(Theme.muted)147 Card { TextField("https://sms.spboucher.ai/enroll#…", text: $link, axis: .vertical).textInputAutocapitalization(.never).autocorrectionDisabled().font(.callout.monospaced()).lineLimit(2...5).accessibilityIdentifier("enrollLinkField") }148 Button("Créer ma clé d'accès") { Task { await model.enroll(link: link); if model.phase == .signedIn { showEnroll = false } } }149 .buttonStyle(PrimaryButtonStyle()).disabled(model.busy || EnrollmentLink.token(from: link) == nil)150 if let e = model.authError { Banner(text: e, tone: .bad, symbol: "exclamationmark.circle") }151 Text("Vous pouvez aussi ouvrir ce lien dans Safari sur cet iPhone : la clé créée là sera proposée ici à la connexion.").font(.footnote).foregroundStyle(Theme.faint)152 }153 .navigationTitle("Enrôlement").navigationBarTitleDisplayMode(.inline)154 .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Fermer") { showEnroll = false } } }155 }156 }157 }158}159160struct MainTabs: View {161 @Environment(AppModel.self) private var model162 var body: some View {163 @Bindable var model = model164 TabView(selection: $model.selectedTab) {165 ComposeView().tabItem { Label("Composer", systemImage: "square.and.pencil") }.tag(0)166 HistoryView().tabItem { Label("Historique", systemImage: "clock") }.tag(1)167 ConversationsView().tabItem { Label("Conversations", systemImage: "bubble.left.and.bubble.right") }.tag(2)168 GatewayView().tabItem { Label("Passerelle", systemImage: "antenna.radiowaves.left.and.right") }.tag(3)169 SettingsView().tabItem { Label("Réglages", systemImage: "gearshape") }.tag(4)170 }171 }172}173