- Add global IS_DEV flag controlling API endpoint (dev vs biz.payfrit.com), dev ribbon banner, and magic OTP hints - Add diagonal orange DEV ribbon overlay (Widgets/DevRibbon.swift) - Replace app icon with properly centered dark-outline SVG on white background - Fix display name with InfoPlist.strings localization - Redesign business selection cards with initial letter, status pill, task count - Make businesses only tappable when pending tasks > 0 (dimmed otherwise) - Simplify LoginScreen and RootView to use IS_DEV directly - Fix hardcoded dev URLs to respect IS_DEV flag Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
2.1 KiB
Swift
72 lines
2.1 KiB
Swift
import SwiftUI
|
|
import LocalAuthentication
|
|
|
|
struct RootView: View {
|
|
@EnvironmentObject var appState: AppState
|
|
@State private var isCheckingAuth = true
|
|
|
|
var body: some View {
|
|
Group {
|
|
if isCheckingAuth {
|
|
loadingView
|
|
} else if appState.isAuthenticated {
|
|
BusinessSelectionScreen()
|
|
} else {
|
|
LoginScreen()
|
|
}
|
|
}
|
|
.animation(.easeInOut(duration: 0.3), value: appState.isAuthenticated)
|
|
.task {
|
|
await checkAuthWithBiometrics()
|
|
isCheckingAuth = false
|
|
}
|
|
}
|
|
|
|
private var loadingView: some View {
|
|
ZStack {
|
|
Color.white.ignoresSafeArea()
|
|
VStack(spacing: 16) {
|
|
Image("PayfritLogoLight")
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: 200)
|
|
ProgressView()
|
|
.tint(.payfritGreen)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func checkAuthWithBiometrics() async {
|
|
let creds = await AuthStorage.shared.loadAuth()
|
|
guard creds != nil else { return }
|
|
|
|
let context = LAContext()
|
|
context.localizedCancelTitle = "Use Password"
|
|
var error: NSError?
|
|
let canUseBiometrics = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
|
|
|
|
#if targetEnvironment(simulator)
|
|
// Skip biometrics on simulator — test on real device
|
|
await appState.loadSavedAuth()
|
|
return
|
|
#endif
|
|
|
|
guard canUseBiometrics else {
|
|
await appState.loadSavedAuth()
|
|
return
|
|
}
|
|
|
|
do {
|
|
let success = try await context.evaluatePolicy(
|
|
.deviceOwnerAuthenticationWithBiometrics,
|
|
localizedReason: "Sign in to Payfrit Works"
|
|
)
|
|
if success {
|
|
await appState.loadSavedAuth()
|
|
}
|
|
} catch {
|
|
// User tapped "Use Password" or biometrics failed — show login screen
|
|
NSLog("PAYFRIT [biometrics] cancelled/failed: \(error.localizedDescription)")
|
|
}
|
|
}
|
|
}
|