Skip to content

Commit 7ce06ee

Browse files
committed
refactor(auth): use localized exceptions in auth UI
Updates the authentication pages (`authentication_page`, `request_code_page`, `email_code_verification_page`) to display localized error messages. - Modifies the `BlocConsumer` listeners to use the `exception` field from the `AuthenticationState`. - Uses the `toFriendlyMessage(context)` extension method from the `ht_ui_kit` package to render user-friendly error messages in SnackBars.
1 parent ad99478 commit 7ce06ee

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/authentication/view/authentication_page.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:go_router/go_router.dart';
44
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
55
import 'package:ht_dashboard/l10n/l10n.dart';
6+
import 'package:ht_ui_kit/ht_ui_kit.dart';
67
import 'package:ht_dashboard/router/routes.dart';
78
import 'package:ht_dashboard/shared/constants/app_spacing.dart';
89

@@ -31,15 +32,13 @@ class AuthenticationPage extends StatelessWidget {
3132
child: BlocConsumer<AuthenticationBloc, AuthenticationState>(
3233
// Listener remains crucial for feedback (errors)
3334
listener: (context, state) {
34-
if (state.status == AuthenticationStatus.failure) {
35+
if (state.status == AuthenticationStatus.failure &&
36+
state.exception != null) {
3537
ScaffoldMessenger.of(context)
3638
..hideCurrentSnackBar()
3739
..showSnackBar(
3840
SnackBar(
39-
content: Text(
40-
// Provide a more user-friendly error message if possible
41-
state.errorMessage!,
42-
),
41+
content: Text(state.exception!.toFriendlyMessage(context)),
4342
backgroundColor: colorScheme.error,
4443
),
4544
);

0 commit comments

Comments
 (0)