Files
Reflect/Shared/Views/LockScreenView.swift
Trey t be84825aba Fix widget layout clipping and add comprehensive widget previews
- Fix LargeVotingView mood icons getting clipped at edges by using
  flexible HStack spacing with maxWidth: .infinity
- Fix VotingView medium layout with smaller icons and even distribution
- Add comprehensive #Preview macros for all widget states:
  - Vote widget: small/medium, voted/not voted, all mood states
  - Timeline widget: small/medium/large with various data states
- Reduce icon sizes and padding to fit within widget bounds
- Update accessibility labels and hints across views

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 09:53:40 -06:00

106 lines
3.2 KiB
Swift

//
// 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()
}
}
}
}
}