Repository Public
1// SP Notes iOS2// File: Features/Root/LockScreen.swift3// Description: The opaque screen shown above everything while the app lock is closed, and the cover that hides the notes in4// the app switcher when the lock is enabled.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import SwiftUI910struct LockScreen: View {11 @Environment(AppModel.self) private var app12 @Environment(\.scenePhase) private var scenePhase1314 var body: some View {15 VStack(spacing: 22) {16 Spacer()17 BrandMark(size: 96)18 Text("SP Notes est verrouillé").font(.title2.weight(.semibold)).foregroundStyle(Color.spText)19 if let error = app.lock.lastError {20 Text(error).font(.footnote).foregroundStyle(Color.spTextSecondary).multilineTextAlignment(.center)21 }22 Spacer()23 Button {24 Task { await app.lock.unlock() }25 } label: {26 Label("Déverrouiller avec \(app.lock.biometryName)", systemImage: app.lock.biometrySymbol)27 }28 .buttonStyle(PrimaryButtonStyle())29 .frame(maxWidth: 380)30 .accessibilityIdentifier("unlock")31 }32 .padding(28)33 .frame(maxWidth: .infinity, maxHeight: .infinity)34 .background(Color.spBackground.ignoresSafeArea())35 .task(id: scenePhase) {36 // Ask as soon as the window is in front; a cancelled prompt leaves the button.37 if scenePhase == .active { await app.lock.unlock() }38 }39 }40}4142/// Hides the content while the window is not active (app switcher snapshot), without any interaction.43struct PrivacyCover: View {44 var body: some View {45 ZStack {46 Color.spBackground.ignoresSafeArea()47 BrandMark(size: 88)48 }49 .accessibilityHidden(true)50 }51}52