import SwiftUI /// Brand-gepflegtes Eingabefeld für Email/Name/Token. SecureField- /// Variante darunter (`ManaSecureField`). /// /// Settings für Email-Input (Keyboard-Type, no autocap/autocorrect) /// können via `.manaEmailField()`-Modifier convenience gesetzt werden. public struct ManaTextField: View { @Environment(\.manaBrand) private var brand private let placeholder: String @Binding private var text: String public init(_ placeholder: String, text: Binding) { self.placeholder = placeholder _text = text } public var body: some View { TextField(placeholder, text: $text) .padding(.vertical, 12) .padding(.horizontal, 16) .background(brand.surface, in: RoundedRectangle(cornerRadius: 10)) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(brand.border, lineWidth: 0.5) ) .foregroundStyle(brand.foreground) } } /// Passwort-Feld. Gleiche Optik wie ``ManaTextField``, aber maskiert. public struct ManaSecureField: View { @Environment(\.manaBrand) private var brand private let placeholder: String @Binding private var text: String private let textContentType: TextContentType /// - Parameter textContentType: `.password` für Login-Eingabe, /// `.newPassword` für Sign-Up oder Reset (löst iOS-Passwort- /// Vorschlag-Sheet aus). public init( _ placeholder: String, text: Binding, textContentType: TextContentType = .password ) { self.placeholder = placeholder _text = text self.textContentType = textContentType } public var body: some View { SecureField(placeholder, text: $text) #if os(iOS) .textContentType(uiTextContentType) #elseif os(macOS) .textContentType(nsTextContentType) #endif .padding(.vertical, 12) .padding(.horizontal, 16) .background(brand.surface, in: RoundedRectangle(cornerRadius: 10)) .overlay( RoundedRectangle(cornerRadius: 10) .stroke(brand.border, lineWidth: 0.5) ) .foregroundStyle(brand.foreground) } public enum TextContentType: Sendable { case password case newPassword } #if os(iOS) private var uiTextContentType: UITextContentType { switch textContentType { case .password: .password case .newPassword: .newPassword } } #elseif os(macOS) private var nsTextContentType: NSTextContentType { switch textContentType { case .password: .password case .newPassword: .newPassword } } #endif } public extension View { /// Convenience-Modifier für Email-Felder: kein Autocaps, kein /// Autocorrect, Email-Keyboard auf iOS, Email-textContentType. func manaEmailField() -> some View { modifier(EmailFieldModifier()) } } private struct EmailFieldModifier: ViewModifier { func body(content: Content) -> some View { content .textContentType(.emailAddress) .autocorrectionDisabled() #if os(iOS) .keyboardType(.emailAddress) .textInputAutocapitalization(.never) #endif } }