// // LockScreenView.swift // Feels // // Lock screen shown when privacy lock is enabled and app needs authentication. // import SwiftUI struct LockScreenView: View { @ObservedObject var authManager: BiometricAuthManager @State private var showError = false var body: some View { ZStack { // Background gradient LinearGradient( colors: [ Color(.systemBackground), Color(.systemGray6) ], startPoint: .top, endPoint: .bottom ) .ignoresSafeArea() VStack(spacing: 40) { Spacer() // App icon / lock icon VStack(spacing: 20) { Image(systemName: "lock.fill") .font(.largeTitle) .foregroundStyle(.secondary) Text("Feels is Locked") .font(.title2) .fontWeight(.semibold) Text("Authenticate to access your mood data") .font(.subheadline) .foregroundStyle(.secondary) .multilineTextAlignment(.center) } Spacer() // Unlock button Button { Task { let success = await authManager.authenticate() if !success { showError = true } } } label: { HStack(spacing: 12) { Image(systemName: authManager.biometricIcon) .font(.title2) Text("Unlock with \(authManager.biometricName)") .fontWeight(.medium) } .frame(maxWidth: .infinity) .padding(.vertical, 16) .background(Color.accentColor) .foregroundColor(.white) .clipShape(RoundedRectangle(cornerRadius: 14)) } .disabled(authManager.isAuthenticating) .padding(.horizontal, 40) // Passcode fallback hint if authManager.canUseDevicePasscode { Text("Or use your device passcode") .font(.caption) .foregroundStyle(.tertiary) } Spacer() .frame(height: 60) } .padding() } .alert("Authentication Failed", isPresented: $showError) { Button("Try Again") { Task { await authManager.authenticate() } } Button("Cancel", role: .cancel) { } } message: { Text("Unable to verify your identity. Please try again.") } .onAppear { // Auto-trigger authentication on appear if !authManager.isUnlocked && !authManager.isAuthenticating { Task { await authManager.authenticate() } } } } }