From d50a1a0f8e23462814e53d25af4b91074da0a3b5 Mon Sep 17 00:00:00 2001 From: qzl Date: Thu, 26 Feb 2026 11:40:49 +0800 Subject: [PATCH] fix(auth): show validation error toast on register form --- .../features/auth/ui/screens/register_screen.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/lib/features/auth/ui/screens/register_screen.dart b/apps/lib/features/auth/ui/screens/register_screen.dart index 3af8e76..7afe657 100644 --- a/apps/lib/features/auth/ui/screens/register_screen.dart +++ b/apps/lib/features/auth/ui/screens/register_screen.dart @@ -8,6 +8,7 @@ import '../../../../core/theme/design_tokens.dart'; import '../../../../core/di/injection.dart'; import '../../../../shared/widgets/app_button.dart'; import '../../../../shared/widgets/banner/app_banner.dart'; +import '../../../../shared/widgets/toast/toast.dart'; import '../../../../shared/widgets/toast/toast_type.dart'; import '../../presentation/cubits/register_cubit.dart'; import '../../data/auth_repository.dart'; @@ -52,6 +53,17 @@ class _RegisterViewState extends State { cubit.passwordChanged(_passwordController.text); if (!cubit.state.isStep1Valid || cubit.state.isSending) { + String? errorMsg; + if (!cubit.state.username.isValid) { + errorMsg = '请输入有效的昵称(3-30个字符)'; + } else if (!cubit.state.email.isValid) { + errorMsg = '请输入有效的邮箱地址'; + } else if (!cubit.state.password.isValid) { + errorMsg = '密码至少需要6个字符'; + } + if (errorMsg != null && mounted) { + Toast.show(context, errorMsg, type: ToastType.warning); + } return; }