Repository Public MIT
1import SwiftUI2import SPGlassKit34public struct GlassSecureFieldExample: GlassExample {5 public static let componentID = "glass-secure-field"6 @State private var current = ""7 @State private var new = ""8 @State private var pin = ""910 public init() {}1112 public var body: some View {13 ScrollView {14 VStack(alignment: .leading, spacing: 20) {15 GlassSecureField("Current password", text: $current, validation: GlassFieldValidation(.required()))1617 GlassSecureField(18 "New password",19 text: $new,20 prompt: "At least 12 characters",21 helper: "Use a phrase you can remember.",22 content: .newPassword,23 allowsReveal: true,24 validation: GlassFieldValidation(.required(), .minLength(12)),25 validateOn: .always26 )2728 GlassSecureField("Device PIN", text: $pin, allowsReveal: true, errorMessage: pin.isEmpty ? nil : "Demo: this PIN is always rejected.")2930 // Only the length is ever displayed: the example never prints the secret.31 Text("New password length: \(new.count)")32 .font(.callout)33 .foregroundStyle(.secondary)34 }35 .padding()36 }37 }38}3940#Preview("GlassSecureField") { GlassSecureFieldExample() }41