Switch to authenticationrequirement instead of flag (#872)

This commit is contained in:
Max Goedjen authored and GitHub committed 2026-11-18 05:19:16 +00:00
1 parent c0562ba50a
commit 479075490d
12 files changed
+411 -410

No files matched your search

@@ -15,7 +15,6 @@ extension Preview {
Attributes(
keyType: .init(algorithm: .ecdsa, size: 256),
authentication: .presenceRequired,
allowWhileLocked: true,
)
}
}
@@ -10,16 +10,15 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
@State private var name = ""
@State private var keyAttribution = ""
@State private var authenticationRequirement: AuthenticationRequirement = .presenceRequired
@State private var allowWhileLocked = false
@State private var keyType: KeyType?
@State var advanced = false
@State var errorText: String?
private var authenticationOptions: [AuthenticationRequirement] {
if advanced || authenticationRequirement == .biometryCurrent {
[.presenceRequired, .notRequired, .biometryCurrent]
[.presenceRequired, .notRequiredWhileUnlocked, .notRequiredAfterFirstUnlock, .biometryCurrent]
} else {
[.presenceRequired, .notRequired]
[.presenceRequired, .notRequiredWhileUnlocked]
}
}
@@ -33,9 +32,12 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
ForEach(authenticationOptions) { option in
HStack {
switch option {
case .notRequired:
case .notRequiredWhileUnlocked:
Image(systemName: "bell")
Text(.createSecretNotifyTitle)
Text(.createSecretWhileUnlockedNotifyTitle)
case .notRequiredAfterFirstUnlock:
Image(systemName: "lock.display")
Text(.createSecretAfterFirstUnlockNotifyTitle)
case .presenceRequired:
Image(systemName: "lock")
Text(.createSecretRequireAuthenticationTitle)
@@ -50,9 +52,11 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
}
}
Group {
switch authenticationRequirement {
case .notRequired:
Text(.createSecretNotifyDescription)
switch authenticationRequirement {
case .notRequiredAfterFirstUnlock:
Text(.createSecretAfterFirstUnlockNotifyDescription)
case .notRequiredWhileUnlocked:
Text(.createSecretWhileUnlockedNotifyDescription)
case .presenceRequired:
Text(.createSecretRequireAuthenticationDescription)
case .biometryCurrent:
@@ -74,12 +78,6 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
}
if advanced {
Section {
Toggle(isOn: $allowWhileLocked) {
Text(.createSecretAllowWhileLockedLabel)
Text(.createSecretAllowWhileLockedDescription)
.font(.subheadline)
.foregroundStyle(.secondary)
}
VStack {
Picker(.createSecretKeyTypeLabel, selection: $keyType) {
ForEach(store.supportedKeyTypes.available, id: \.self) { option in
@@ -153,7 +151,6 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
attributes: .init(
keyType: keyType!,
authentication: authenticationRequirement,
allowWhileLocked: allowWhileLocked,
publicKeyAttribution: attribution
)
)