SPB Git

Repository Public

WelcomeView.swift 3.2 KB 44 lines swift

1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: Features/Account/WelcomeView.swift3// Description: First-launch sign-in screen: sign in with the passkey of note.spboucher.ai (the same Touch ID credential as the web app) to bring the notes to this Mac, or continue without an account.4import SwiftUI5import SPNotesDesign67struct WelcomeView: View {8    @Environment(AppEnvironment.self) private var env9    let dismiss: () -> Void1011    /// macOS ties the passkey domain association to the installed application: a copy run from elsewhere can be refused.12    static var isInstalled: Bool { Bundle.main.bundlePath.hasPrefix("/Applications/") }1314    var body: some View {15        ZStack {16            NVColor.bg.ignoresSafeArea()17            // the signature gradient, as a soft glow behind the card18            Circle().fill(NVColor.lumen).frame(width: 520, height: 520).blur(radius: 140).opacity(0.28).offset(y: -160).accessibilityHidden(true)19            VStack(spacing: NVSpace.lg) {20                Image(nsImage: NSApp.applicationIconImage).resizable().frame(width: 88, height: 88).accessibilityHidden(true)21                Text("Bienvenue dans SP Notes").nvFont(.display).multilineTextAlignment(.center)22                Text("Connecte-toi avec ta clé d'accès — la même que sur note.spboucher.ai, confirmée par Touch ID — pour retrouver toutes tes notes sur ce Mac et les garder synchronisées.")23                    .nvFont(.body).foregroundStyle(NVColor.fgMuted).multilineTextAlignment(.center).frame(maxWidth: 480).fixedSize(horizontal: false, vertical: true)24                Button { Task { await env.account.signIn(); if env.account.isSignedIn { dismiss() } } } label: {25                    Label("Se connecter avec ma clé d'accès", systemImage: "touchid").nvFont(.uiStrong).frame(width: 320).padding(.vertical, NVSpace.xs)26                }27                .buttonStyle(.borderedProminent).controlSize(.large).keyboardShortcut(.defaultAction).disabled(env.account.isWorking)28                .accessibilityIdentifier("welcome-sign-in")29                if env.account.isWorking { NVProgressDots() }30                if let m = env.account.message { notice(m, "exclamationmark.triangle") }31                if !Self.isInstalled { notice("Cette copie n'est pas dans le dossier Applications : macOS peut refuser la clé d'accès. Glisse SP Notes dans Applications et lance-la de là.", "folder.badge.questionmark") }32                Button("Continuer sans compte (notes sur ce Mac seulement)") { dismiss() }.buttonStyle(.link).accessibilityIdentifier("welcome-local")33                Text("Aucun mot de passe n'existe : la clé d'accès est dans ton trousseau iCloud. Tu pourras te connecter plus tard depuis l'état en bas de la barre latérale.")34                    .nvFont(.micro).foregroundStyle(NVColor.fgMuted).multilineTextAlignment(.center).frame(maxWidth: 460)35            }36            .padding(NVSpace.xxxl).nvGlass(radius: NVRadius.xl).padding(NVSpace.xl)37        }38        .accessibilityIdentifier("welcome")39    }40    private func notice(_ text: String, _ symbol: String) -> some View {41        Label(text, systemImage: symbol).nvFont(.ui).foregroundStyle(NVColor.warningText).multilineTextAlignment(.center).frame(maxWidth: 480).fixedSize(horizontal: false, vertical: true)42    }43}44
Files main
Menu

Theme