import ManaCore import SwiftUI /// Wird angezeigt, wenn ein Login-Versuch mit /// ``AuthError/emailNotVerified`` gescheitert ist. Bietet einen /// Resend-Mail-Button und einen "Zurück zum Login"-Pfad. /// /// Die Apps bauen das nicht direkt ein — ``ManaLoginView`` schaltet /// automatisch um wenn der Sign-In den entsprechenden Fehler liefert. public struct ManaEmailVerifyGateView: View { @Environment(\.manaBrand) private var brand @State private var model: EmailVerifyGateViewModel private let onBackToLogin: () -> Void public init( email: String, auth: AuthClient, sourceAppUrl: URL? = nil, onBackToLogin: @escaping () -> Void ) { _model = State(initialValue: EmailVerifyGateViewModel( email: email, auth: auth, sourceAppUrl: sourceAppUrl )) self.onBackToLogin = onBackToLogin } public var body: some View { ManaAuthScaffold { VStack(spacing: 16) { Image(systemName: "envelope.badge") .font(.system(size: 56, weight: .light)) .foregroundStyle(brand.primary) .padding(.bottom, 8) Text("Bestätige deine Email") .font(.title2) .fontWeight(.semibold) .foregroundStyle(brand.foreground) .multilineTextAlignment(.center) Text( "Wir haben dir eine Bestätigungs-Mail an **\(model.email)** geschickt. " + "Klicke den Link in der Mail, dann kannst du dich anmelden." ) .font(.subheadline) .foregroundStyle(brand.mutedForeground) .multilineTextAlignment(.center) ManaPrimaryButton( "Bestätigungs-Mail erneut senden", isLoading: model.isResending, isEnabled: model.canResend ) { Task { await model.resend() } } .padding(.top, 8) switch model.status { case let .resent(message): Text(message) .font(.footnote) .foregroundStyle(brand.success) .multilineTextAlignment(.center) case let .error(message): Text(message) .font(.footnote) .foregroundStyle(brand.error) .multilineTextAlignment(.center) default: EmptyView() } Button("Zurück zum Login", action: onBackToLogin) .font(.subheadline) .foregroundStyle(brand.mutedForeground) .padding(.top, 16) } } } }