1
- //
2
- // ignore_for_file: lines_longer_than_80_chars
3
-
4
1
import 'package:flutter/material.dart' ;
5
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
6
3
import 'package:go_router/go_router.dart' ;
7
4
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart' ;
8
5
import 'package:ht_dashboard/l10n/l10n.dart' ;
9
6
import 'package:ht_dashboard/router/routes.dart' ;
10
7
import 'package:ht_dashboard/shared/constants/app_spacing.dart' ;
8
+ import 'package:ht_dashboard/shared/theme/app_theme.dart' ;
11
9
12
10
/// {@template authentication_page}
13
11
/// Displays authentication options for the dashboard.
@@ -34,25 +32,27 @@ class AuthenticationPage extends StatelessWidget {
34
32
child: BlocConsumer <AuthenticationBloc , AuthenticationState >(
35
33
// Listener remains crucial for feedback (errors)
36
34
listener: (context, state) {
37
- if (state is AuthenticationFailure ) {
35
+ if (state.status == AuthenticationStatus .failure ) {
38
36
ScaffoldMessenger .of (context)
39
37
..hideCurrentSnackBar ()
40
38
..showSnackBar (
41
39
SnackBar (
42
40
content: Text (
43
41
// Provide a more user-friendly error message if possible
44
- state.errorMessage,
42
+ state.errorMessage! ,
45
43
),
46
44
backgroundColor: colorScheme.error,
47
45
),
48
46
);
49
47
}
50
48
// 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.
53
52
},
54
53
builder: (context, state) {
55
- final isLoading = state is AuthenticationLoading ;
54
+ final isLoading = state.status == AuthenticationStatus .loading ||
55
+ state.status == AuthenticationStatus .requestCodeLoading;
56
56
57
57
return Padding (
58
58
padding: const EdgeInsets .all (AppSpacing .paddingLarge),
@@ -64,14 +64,15 @@ class AuthenticationPage extends StatelessWidget {
64
64
children: [
65
65
// --- Icon ---
66
66
Padding (
67
- padding: const EdgeInsets .only (bottom: AppSpacing .xl),
67
+ padding: const EdgeInsets .only (
68
+ bottom: AppSpacing .xl,
69
+ ),
68
70
child: Icon (
69
71
Icons .newspaper,
70
72
size: AppSpacing .xxl * 2 ,
71
73
color: colorScheme.primary,
72
74
),
73
75
),
74
- // const SizedBox(height: AppSpacing.lg),
75
76
// --- Headline and Subheadline ---
76
77
Text (
77
78
l10n.authenticationPageHeadline,
@@ -111,13 +112,11 @@ class AuthenticationPage extends StatelessWidget {
111
112
const SizedBox (height: AppSpacing .lg),
112
113
113
114
// --- Loading Indicator ---
114
- if (isLoading &&
115
- state is ! AuthenticationRequestCodeLoading ) ...[
115
+ if (isLoading)
116
116
const Padding (
117
117
padding: EdgeInsets .only (top: AppSpacing .xl),
118
118
child: Center (child: CircularProgressIndicator ()),
119
119
),
120
- ],
121
120
],
122
121
),
123
122
),
0 commit comments