Phase 2 aus dem Native-Auth-Vollausbau-Plan (Option A, siehe ../mana/docs/MANA_SWIFT.md). Entstanden weil drei Apps fast- byte-identische LoginView.swift hatten und Sign-Up/Forgot-PW komplett fehlten. ManaAuthUI-Library mit: - ManaBrandConfig — App-injizierte Theme-Werte (forest für Cards/ Manaspur, mana-default für Memoro), Environment-Key, View-Modifier - Base-Components: ManaAuthScaffold, ManaPrimaryButton, ManaTextField, ManaSecureField + .manaEmailField()-Modifier - ManaLoginView + LoginViewModel — Email/PW-Login, schaltet bei AuthError.emailNotVerified automatisch auf ManaEmailVerifyGateView - ManaSignUpView + SignUpViewModel — Email/Name/PW + awaiting- Verification-Hinweis-Screen - ManaEmailVerifyGateView + ViewModel — Resend-Verification - ManaForgotPasswordView + ViewModel — Reset-Mail anfordern (immer generischer Hinweis, User-Enumeration-Schutz) - ManaResetPasswordView + ViewModel — neues PW mit Token aus Universal-Link - ManaChangeEmailView, ManaChangePasswordView, ManaDeleteAccountView + internal ViewModels — Account-Bausteine - ManaDeleteAccountView ist zweistufig (Bestätigungs-Wort tippen + Passwort) → App-Store-Guideline 5.1.1(v) Pflicht-Surface 26/26 ViewModel-Tests grün via per-test-ID URLProtocol-Routing (löst Parallel-Pollution zwischen .serialized Suites). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
3.4 KiB
Swift
108 lines
3.4 KiB
Swift
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<String>) {
|
|
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<String>,
|
|
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
|
|
}
|
|
}
|