@@ -21,6 +21,7 @@ class AuthenticationPage extends StatelessWidget {
21
21
required this .headline,
22
22
required this .subHeadline,
23
23
required this .showAnonymousButton,
24
+ required this .isLinkingContext, // Add this parameter
24
25
super .key,
25
26
});
26
27
@@ -33,20 +34,26 @@ class AuthenticationPage extends StatelessWidget {
33
34
/// Whether to show the "Continue Anonymously" button.
34
35
final bool showAnonymousButton;
35
36
37
+ /// Whether this page is being shown in the account linking context.
38
+ final bool isLinkingContext; // Add this field
39
+
36
40
@override
37
41
Widget build (BuildContext context) {
38
42
// Provide the BLoC here if it's not already provided higher up
39
43
// For this refactor, assuming it's provided by the route or App setup
40
44
return BlocProvider (
41
45
// Ensure BLoC is created only once per instance of this page if needed
42
46
// If BLoC needs to persist across navigations, provide it higher up.
43
- create: (context) => AuthenticationBloc (
44
- authenticationRepository: context.read <HtAuthenticationRepository >(),
45
- ),
47
+ create:
48
+ (context) => AuthenticationBloc (
49
+ authenticationRepository:
50
+ context.read <HtAuthenticationRepository >(),
51
+ ),
46
52
child: _AuthenticationView (
47
53
headline: headline,
48
54
subHeadline: subHeadline,
49
55
showAnonymousButton: showAnonymousButton,
56
+ isLinkingContext: isLinkingContext, // Pass down the flag
50
57
),
51
58
);
52
59
}
@@ -58,11 +65,13 @@ class _AuthenticationView extends StatelessWidget {
58
65
required this .headline,
59
66
required this .subHeadline,
60
67
required this .showAnonymousButton,
68
+ required this .isLinkingContext, // Add this parameter
61
69
});
62
70
63
71
final String headline;
64
72
final String subHeadline;
65
73
final bool showAnonymousButton;
74
+ final bool isLinkingContext; // Add this field
66
75
67
76
@override
68
77
Widget build (BuildContext context) {
@@ -71,7 +80,21 @@ class _AuthenticationView extends StatelessWidget {
71
80
final colorScheme = Theme .of (context).colorScheme;
72
81
73
82
return Scaffold (
74
- // Consider adding an AppBar if needed for context/navigation
83
+ appBar: AppBar (
84
+ backgroundColor: Colors .transparent,
85
+ elevation: 0 ,
86
+ // Conditionally add the leading close button only in linking context
87
+ leading: isLinkingContext
88
+ ? IconButton (
89
+ icon: const Icon (Icons .close),
90
+ tooltip: MaterialLocalizations .of (context).closeButtonTooltip, // Accessibility
91
+ onPressed: () {
92
+ // Navigate back to the account page when close is pressed
93
+ context.goNamed (Routes .accountName);
94
+ },
95
+ )
96
+ : null , // No leading button if not linking (relies on system back if pushed)
97
+ ),
75
98
body: SafeArea (
76
99
child: BlocConsumer <AuthenticationBloc , AuthenticationState >(
77
100
// Listener remains crucial for feedback (errors)
@@ -94,14 +117,18 @@ class _AuthenticationView extends StatelessWidget {
94
117
// Email link success is handled in the dedicated email flow pages.
95
118
},
96
119
builder: (context, state) {
97
- final isLoading = state is AuthenticationLoading ; // Simplified loading check
120
+ final isLoading =
121
+ state is AuthenticationLoading ; // Simplified loading check
98
122
99
123
return Padding (
100
- padding: const EdgeInsets .all (AppSpacing .paddingLarge), // Use constant
124
+ padding: const EdgeInsets .all (
125
+ AppSpacing .paddingLarge,
126
+ ), // Use constant
101
127
child: Center (
102
128
child: SingleChildScrollView (
103
129
child: Column (
104
- mainAxisAlignment: MainAxisAlignment .center, // Center vertically
130
+ mainAxisAlignment:
131
+ MainAxisAlignment .center, // Center vertically
105
132
crossAxisAlignment: CrossAxisAlignment .stretch,
106
133
children: [
107
134
// --- Headline and Subheadline ---
@@ -117,41 +144,46 @@ class _AuthenticationView extends StatelessWidget {
117
144
textAlign: TextAlign .center,
118
145
),
119
146
const SizedBox (height: AppSpacing .xxl), // Use constant
120
-
121
147
// --- Google Sign-In Button ---
122
148
ElevatedButton .icon (
123
- icon: const Icon (Icons .g_mobiledata), // Placeholder icon
149
+ icon: const Icon (
150
+ Icons .g_mobiledata,
151
+ ), // Placeholder icon
124
152
label: Text (l10n.authenticationGoogleSignInButton),
125
- onPressed: isLoading
126
- ? null
127
- : () => context.read <AuthenticationBloc >().add (
153
+ onPressed:
154
+ isLoading
155
+ ? null
156
+ : () => context.read <AuthenticationBloc >().add (
128
157
const AuthenticationGoogleSignInRequested (),
129
158
),
130
159
// Style adjustments can be made via ElevatedButtonThemeData
131
160
),
132
161
const SizedBox (height: AppSpacing .lg), // Use constant
133
-
134
162
// --- Email Sign-In Button ---
135
163
ElevatedButton (
136
164
// Consider an email icon
137
165
// icon: const Icon(Icons.email_outlined),
138
- child: Text (l10n.authenticationEmailSignInButton), // New l10n key needed
139
- onPressed: isLoading
140
- ? null
141
- : () {
142
- // Navigate to the dedicated email sign-in page
143
- context.goNamed (Routes .emailSignInName);
144
- },
166
+ child: Text (
167
+ l10n.authenticationEmailSignInButton,
168
+ ), // New l10n key needed
169
+ onPressed:
170
+ isLoading
171
+ ? null
172
+ : () {
173
+ // Navigate to the dedicated email sign-in page
174
+ context.goNamed (Routes .emailSignInName);
175
+ },
145
176
),
146
177
147
178
// --- Anonymous Sign-In Button (Conditional) ---
148
179
if (showAnonymousButton) ...[
149
180
const SizedBox (height: AppSpacing .lg), // Use constant
150
181
OutlinedButton (
151
182
child: Text (l10n.authenticationAnonymousSignInButton),
152
- onPressed: isLoading
153
- ? null
154
- : () => context.read <AuthenticationBloc >().add (
183
+ onPressed:
184
+ isLoading
185
+ ? null
186
+ : () => context.read <AuthenticationBloc >().add (
155
187
const AuthenticationAnonymousSignInRequested (),
156
188
),
157
189
),
@@ -160,9 +192,9 @@ class _AuthenticationView extends StatelessWidget {
160
192
// --- Loading Indicator (Optional, for general loading state) ---
161
193
// If needed, show a general loading indicator when state is AuthenticationLoading
162
194
if (isLoading && state is ! AuthenticationLinkSending ) ...[
163
- const SizedBox (height: AppSpacing .xl),
164
- const Center (child: CircularProgressIndicator ()),
165
- ]
195
+ const SizedBox (height: AppSpacing .xl),
196
+ const Center (child: CircularProgressIndicator ()),
197
+ ],
166
198
],
167
199
),
168
200
),
0 commit comments