mana-swift-ui/Sources/ManaAuthUI/Components/ManaPrimaryButton.swift
Till JS 0a2cb349b4 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>
2026-05-13 19:22:42 +02:00

59 lines
2 KiB
Swift

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
}
}