v0.1.0 — initialer Sprint, vollständige Auth-Reise als SwiftUI
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>
This commit is contained in:
commit
0a2cb349b4
29 changed files with 2614 additions and 0 deletions
67
Sources/ManaAuthUI/Components/ManaAuthScaffold.swift
Normal file
67
Sources/ManaAuthUI/Components/ManaAuthScaffold.swift
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import SwiftUI
|
||||
|
||||
/// Gemeinsames Layout-Gerüst für alle Auth-Screens: brand-getöntes
|
||||
/// Background, scrollbarer Content-Stack mit max-width, optional
|
||||
/// ein zentriertes Logo + App-Name + Tagline-Block am Anfang.
|
||||
///
|
||||
/// Apps brauchen keine eigene NavigationStack-Wrapper — das ist die
|
||||
/// Aufgabe der konsumierenden View (Login/SignUp etc. sitzen ggf.
|
||||
/// in einer Sheet oder einem NavigationStack der App).
|
||||
public struct ManaAuthScaffold<Content: View>: View {
|
||||
@Environment(\.manaBrand) private var brand
|
||||
private let showsHeader: Bool
|
||||
private let content: Content
|
||||
|
||||
/// - Parameters:
|
||||
/// - showsHeader: Wenn `true`, wird oben Logo + AppName + Tagline
|
||||
/// gerendert. Default `true`. Auf Account-Sub-Views (Change-
|
||||
/// Password etc.) sinnvollerweise `false`.
|
||||
public init(showsHeader: Bool = true, @ViewBuilder content: () -> Content) {
|
||||
self.showsHeader = showsHeader
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
ZStack {
|
||||
brand.background.ignoresSafeArea()
|
||||
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
if showsHeader {
|
||||
header
|
||||
}
|
||||
content
|
||||
}
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.top, showsHeader ? 64 : 24)
|
||||
.padding(.bottom, 32)
|
||||
.frame(maxWidth: 480)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
#if os(iOS)
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var header: some View {
|
||||
VStack(spacing: 12) {
|
||||
if let symbol = brand.logoSymbol {
|
||||
Image(systemName: symbol)
|
||||
.font(.system(size: 44, weight: .medium))
|
||||
.foregroundStyle(brand.primary)
|
||||
}
|
||||
Text(brand.appName)
|
||||
.font(.system(size: 40, weight: .bold))
|
||||
.foregroundStyle(brand.primary)
|
||||
.multilineTextAlignment(.center)
|
||||
if let tagline = brand.tagline {
|
||||
Text(tagline)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(brand.mutedForeground)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
Sources/ManaAuthUI/Components/ManaFields.swift
Normal file
108
Sources/ManaAuthUI/Components/ManaFields.swift
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
59
Sources/ManaAuthUI/Components/ManaPrimaryButton.swift
Normal file
59
Sources/ManaAuthUI/Components/ManaPrimaryButton.swift
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import SwiftUI
|
||||
|
||||
/// Großer Primary-Button für Auth-Aktionen ("Anmelden", "Registrieren",
|
||||
/// "Passwort setzen"). Brand-getöntes Background, dunkler Text,
|
||||
/// integrierter ProgressView wenn `isLoading == true`.
|
||||
public struct ManaPrimaryButton: View {
|
||||
@Environment(\.manaBrand) private var brand
|
||||
private let title: String
|
||||
private let role: ButtonRole?
|
||||
private let isLoading: Bool
|
||||
private let isEnabled: Bool
|
||||
private let action: () -> Void
|
||||
|
||||
/// - Parameters:
|
||||
/// - title: Label des Buttons.
|
||||
/// - role: Wenn `.destructive`, wird Brand-Error statt Brand-Primary
|
||||
/// genutzt (z.B. für `ManaDeleteAccountView`). Default `nil`.
|
||||
/// - isLoading: Zeigt ProgressView statt Text. Button bleibt disabled.
|
||||
/// - isEnabled: Zusätzliches Disable-Flag (z.B. leere Felder).
|
||||
/// - action: Callback bei Tap.
|
||||
public init(
|
||||
_ title: String,
|
||||
role: ButtonRole? = nil,
|
||||
isLoading: Bool = false,
|
||||
isEnabled: Bool = true,
|
||||
action: @escaping () -> Void
|
||||
) {
|
||||
self.title = title
|
||||
self.role = role
|
||||
self.isLoading = isLoading
|
||||
self.isEnabled = isEnabled
|
||||
self.action = action
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
Button(role: role, action: action) {
|
||||
HStack(spacing: 8) {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.controlSize(.small)
|
||||
.tint(brand.primaryForeground)
|
||||
}
|
||||
Text(title)
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 14)
|
||||
.background(backgroundColor, in: RoundedRectangle(cornerRadius: 10))
|
||||
.foregroundStyle(brand.primaryForeground)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(isLoading || !isEnabled)
|
||||
.opacity((isLoading || !isEnabled) ? 0.6 : 1.0)
|
||||
}
|
||||
|
||||
private var backgroundColor: Color {
|
||||
role == .destructive ? brand.error : brand.primary
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue