Add quick unlock type enum to show custom label in view (#520)

This commit is contained in:
Leendert de Borst
2025-10-19 15:23:40 +02:00
parent ee9f3ca0f9
commit e1318e2147
4 changed files with 42 additions and 10 deletions

View File

@@ -69,8 +69,11 @@ public class CredentialProviderViewController: ASCredentialProviderViewControlle
// Check if we're in quick return mode
// Setup the loading view (actual unlock happens in viewDidAppear)
if isQuickReturnMode {
// Show loading view
let loadingView = QuickUnlockLoadingView()
// Determine the type of credential being retrieved
let type: QuickUnlockType = quickReturnPasskeyRequest != nil ? .passkey : .credential
// Show loading view with appropriate type
let loadingView = QuickUnlockLoadingView(type: type)
let hostingController = UIHostingController(rootView: loadingView)
addChild(hostingController)

View File

@@ -0,0 +1,7 @@
import Foundation
/// Type of credential being retrieved during quick unlock
public enum QuickUnlockType: Hashable {
case credential
case passkey
}

View File

@@ -3,10 +3,22 @@ import SwiftUI
/// Loading view shown during quick unlock (biometric authentication)
public struct QuickUnlockLoadingView: View {
@Environment(\.colorScheme) private var colorScheme
private let locBundle = Bundle.vaultUI
public init() {}
private let locBundle = Bundle.vaultUI
private let type: QuickUnlockType
public init(type: QuickUnlockType) {
self.type = type
}
private var localizedMessage: String {
switch type {
case .credential:
return String(localized: "retrieving_credential", bundle: locBundle)
case .passkey:
return String(localized: "retrieving_passkey", bundle: locBundle)
}
}
public var body: some View {
ZStack {
@@ -15,17 +27,27 @@ public struct QuickUnlockLoadingView: View {
.ignoresSafeArea()
// Loading overlay
LoadingOverlayView(message: String(localized: "retrieving_credential", bundle: locBundle))
LoadingOverlayView(message: localizedMessage)
}
}
}
#Preview("Light Mode") {
QuickUnlockLoadingView()
#Preview("Credential - Light Mode") {
QuickUnlockLoadingView(type: .credential)
.preferredColorScheme(.light)
}
#Preview("Dark Mode") {
QuickUnlockLoadingView()
#Preview("Credential - Dark Mode") {
QuickUnlockLoadingView(type: .credential)
.preferredColorScheme(.dark)
}
#Preview("Passkey - Light Mode") {
QuickUnlockLoadingView(type: .passkey)
.preferredColorScheme(.light)
}
#Preview("Passkey - Dark Mode") {
QuickUnlockLoadingView(type: .passkey)
.preferredColorScheme(.dark)
}

View File

Binary file not shown.