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