-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathView+AuthIdentifierConfig.swift
More file actions
52 lines (45 loc) · 1.83 KB
/
View+AuthIdentifierConfig.swift
File metadata and controls
52 lines (45 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// View+AuthIdentifierConfig.swift
// Clerk
//
#if os(iOS)
import SwiftUI
extension EnvironmentValues {
@Entry var clerkInitialIdentifier: String?
@Entry var clerkInitialPhoneNumber: String?
@Entry var clerkPersistsIdentifiers: Bool = true
}
extension View {
/// Sets the initial value for the email or username field on the auth screen.
///
/// Use this to pre-fill the identifier field when presenting `AuthView`.
///
/// - Parameter identifier: The email address or username to pre-fill.
/// - Returns: A view with the initial identifier configured.
public func clerkInitialIdentifier(_ identifier: String) -> some View {
environment(\.clerkInitialIdentifier, identifier)
}
/// Sets the initial value for the phone number field on the auth screen.
///
/// Use this to pre-fill the phone number field when presenting `AuthView`.
///
/// - Parameter phoneNumber: The phone number to pre-fill (e.g. `"15555550100"`).
/// - Returns: A view with the initial phone number configured.
public func clerkInitialPhoneNumber(_ phoneNumber: String) -> some View {
environment(\.clerkInitialPhoneNumber, phoneNumber)
}
/// Controls whether auth identifier values are persisted between sessions.
///
/// When set to `false`, any previously stored identifiers are cleared and
/// future changes will not be saved. This is useful on shared devices where
/// the previous user's information should not appear after sign-out.
///
/// The default value is `true`, which preserves the existing persistence behavior.
///
/// - Parameter persists: Whether to persist identifier values to storage.
/// - Returns: A view with the identifier persistence behavior configured.
public func clerkPersistsIdentifiers(_ persists: Bool) -> some View {
environment(\.clerkPersistsIdentifiers, persists)
}
}
#endif