import 'package:flutter/material.dart'; import 'package:sxchnge_auth/sxchnge_auth.dart'; import '../generated/i18n/app_localizations.dart'; class AuthFeedback extends StatelessWidget { const AuthFeedback({super.key, required this.state, required this.signUp}); final AuthState state; final bool signUp; @override Widget build(BuildContext context) { final l = AppLocalizations.of(context)!; final colors = Theme.of(context).colorScheme; final error = state.error; final message = error == null ? (state.result!.isSimulated ? (signUp ? l.signupPreview : l.loginPreview) : l.authCompleted) : switch (error) { AuthError.invalidCredentials => l.authInvalidCredentials, AuthError.emailInUse => l.authEmailInUse, AuthError.unavailable => l.authUnavailable, AuthError.unexpected => l.authUnexpected, AuthError.factorLocked => l.factorLocked, AuthError.factorCooldown => l.factorWait, AuthError.factorRequired => l.factorRequired, }; return Semantics( liveRegion: true, child: Container( key: ValueKey(error == null ? 'preview-result' : 'auth-error'), padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: error == null ? colors.secondaryContainer : colors.errorContainer, borderRadius: BorderRadius.circular(14), ), child: Text( message, style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: error == null ? colors.onSecondaryContainer : colors.onErrorContainer, ), ), ), ); } }