Skip to content

Commit d172c21

Browse files
committed
fix(auth): Improve error handling and UI
- Improved error message display. - Updated loading indicator logic. - Refined UI layout and spacing. - Enhanced code readability. - Used AppTheme for color consistency.
1 parent 67b91d4 commit d172c21

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lib/authentication/view/authentication_page.dart

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
//
2-
// ignore_for_file: lines_longer_than_80_chars
3-
41
import 'package:flutter/material.dart';
52
import 'package:flutter_bloc/flutter_bloc.dart';
63
import 'package:go_router/go_router.dart';
74
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
85
import 'package:ht_dashboard/l10n/l10n.dart';
96
import 'package:ht_dashboard/router/routes.dart';
107
import 'package:ht_dashboard/shared/constants/app_spacing.dart';
8+
import 'package:ht_dashboard/shared/theme/app_theme.dart';
119

1210
/// {@template authentication_page}
1311
/// Displays authentication options for the dashboard.
@@ -34,25 +32,27 @@ class AuthenticationPage extends StatelessWidget {
3432
child: BlocConsumer<AuthenticationBloc, AuthenticationState>(
3533
// Listener remains crucial for feedback (errors)
3634
listener: (context, state) {
37-
if (state is AuthenticationFailure) {
35+
if (state.status == AuthenticationStatus.failure) {
3836
ScaffoldMessenger.of(context)
3937
..hideCurrentSnackBar()
4038
..showSnackBar(
4139
SnackBar(
4240
content: Text(
4341
// Provide a more user-friendly error message if possible
44-
state.errorMessage,
42+
state.errorMessage!,
4543
),
4644
backgroundColor: colorScheme.error,
4745
),
4846
);
4947
}
5048
// Success states (Google/Anonymous) are typically handled by
51-
// the AppBloc listening to repository changes and triggering redirects.
52-
// Email link success is handled in the dedicated email flow pages.
49+
// the AppBloc listening to repository changes and triggering
50+
// redirects. Email link success is handled in the dedicated
51+
// email flow pages.
5352
},
5453
builder: (context, state) {
55-
final isLoading = state is AuthenticationLoading;
54+
final isLoading = state.status == AuthenticationStatus.loading ||
55+
state.status == AuthenticationStatus.requestCodeLoading;
5656

5757
return Padding(
5858
padding: const EdgeInsets.all(AppSpacing.paddingLarge),
@@ -64,14 +64,15 @@ class AuthenticationPage extends StatelessWidget {
6464
children: [
6565
// --- Icon ---
6666
Padding(
67-
padding: const EdgeInsets.only(bottom: AppSpacing.xl),
67+
padding: const EdgeInsets.only(
68+
bottom: AppSpacing.xl,
69+
),
6870
child: Icon(
6971
Icons.newspaper,
7072
size: AppSpacing.xxl * 2,
7173
color: colorScheme.primary,
7274
),
7375
),
74-
// const SizedBox(height: AppSpacing.lg),
7576
// --- Headline and Subheadline ---
7677
Text(
7778
l10n.authenticationPageHeadline,
@@ -111,13 +112,11 @@ class AuthenticationPage extends StatelessWidget {
111112
const SizedBox(height: AppSpacing.lg),
112113

113114
// --- Loading Indicator ---
114-
if (isLoading &&
115-
state is! AuthenticationRequestCodeLoading) ...[
115+
if (isLoading)
116116
const Padding(
117117
padding: EdgeInsets.only(top: AppSpacing.xl),
118118
child: Center(child: CircularProgressIndicator()),
119119
),
120-
],
121120
],
122121
),
123122
),

0 commit comments

Comments
 (0)