@@ -7,6 +7,7 @@ import 'package:ht_main/account/bloc/account_bloc.dart';
7
7
import 'package:ht_main/app/bloc/app_bloc.dart' ;
8
8
import 'package:ht_main/l10n/l10n.dart' ;
9
9
import 'package:ht_main/router/routes.dart' ;
10
+ import 'package:ht_main/shared/constants/app_spacing.dart' ;
10
11
11
12
/// {@template account_page}
12
13
/// Page widget for the Account feature.
@@ -54,20 +55,15 @@ class _AccountView extends StatelessWidget {
54
55
appBar: AppBar (title: Text (l10n.accountPageTitle)),
55
56
body: ListView (
56
57
// Use ListView for potential scrolling if content grows
57
- padding: const EdgeInsets .all (16 ),
58
+ padding: const EdgeInsets .all (AppSpacing .lg), // Use AppSpacing
58
59
children: [
59
60
// --- User Header ---
60
61
_buildUserHeader (context, user, isAnonymous),
61
- const SizedBox (height: 24 ),
62
-
62
+ const SizedBox (height: AppSpacing .xl), // Use AppSpacing
63
63
// --- Action Tiles ---
64
+ // Settings Tile is now the first actionable item below the header
64
65
_buildSettingsTile (context),
65
- const Divider (),
66
- if (isAnonymous)
67
- _buildBackupTile (context) // Show Backup CTA for anonymous
68
- else
69
- _buildLogoutTile (context), // Show Logout for authenticated
70
- const Divider (),
66
+ const Divider (), // Divider after settings
71
67
],
72
68
),
73
69
);
@@ -99,89 +95,74 @@ class _AccountView extends StatelessWidget {
99
95
)
100
96
: null ,
101
97
),
102
- const SizedBox (height: 16 ),
98
+ const SizedBox (height: AppSpacing .lg), // Use AppSpacing
103
99
Text (
104
100
isAnonymous
105
101
? l10n.accountAnonymousUser
106
102
: user.displayName ?? l10n.accountNoNameUser,
107
103
style: textTheme.titleLarge,
108
104
textAlign: TextAlign .center,
109
105
),
110
- const SizedBox (height: 4 ),
111
- Text (
112
- // Convert enum to user-friendly string
113
- _authenticationStatusToString (context, user.authenticationStatus),
114
- style: textTheme.bodyMedium? .copyWith (
115
- color: theme.colorScheme.secondary,
116
- ),
117
- textAlign: TextAlign .center,
118
- ),
106
+ // Conditionally display Sign In or Logout button
107
+ if (isAnonymous)
108
+ _buildSignInButton (context)
109
+ else
110
+ _buildLogoutButton (context),
119
111
],
120
112
);
121
113
}
122
114
123
- /// Builds the ListTile for navigating to Settings .
124
- Widget _buildSettingsTile (BuildContext context) {
115
+ /// Builds the sign-in button for anonymous users .
116
+ Widget _buildSignInButton (BuildContext context) {
125
117
final l10n = context.l10n;
126
- return ListTile (
127
- leading: const Icon (Icons .settings_outlined),
128
- title: Text (l10n.accountSettingsTile),
129
- trailing: const Icon (Icons .chevron_right),
130
- onTap: () {
131
- // Navigate to the existing settings route
132
- context.goNamed (Routes .settingsName);
133
- },
118
+ return Padding (
119
+ padding: const EdgeInsets .only (top: AppSpacing .sm),
120
+ child: TextButton (
121
+ onPressed: () {
122
+ // Navigate to the authentication page in linking mode
123
+ context.goNamed (
124
+ Routes .authenticationName,
125
+ queryParameters: {'context' : 'linking' },
126
+ );
127
+ },
128
+ child: Text (l10n.accountSignInPromptButton),
129
+ ),
134
130
);
135
131
}
136
132
137
- /// Builds the ListTile for logging out ( for authenticated users) .
138
- Widget _buildLogoutTile (BuildContext context) {
133
+ /// Builds the logout button for authenticated users.
134
+ Widget _buildLogoutButton (BuildContext context) {
139
135
final l10n = context.l10n;
140
- return ListTile (
141
- leading: Icon (Icons .logout, color: Theme .of (context).colorScheme.error),
142
- title: Text (
143
- l10n.accountSignOutTile,
144
- style: TextStyle (color: Theme .of (context).colorScheme.error),
136
+ final theme = Theme .of (context);
137
+ return Padding (
138
+ padding: const EdgeInsets .only (top: AppSpacing .sm),
139
+ child: OutlinedButton (
140
+ style: OutlinedButton .styleFrom (
141
+ foregroundColor: theme.colorScheme.error,
142
+ side: BorderSide (color: theme.colorScheme.error),
143
+ ),
144
+ onPressed: () {
145
+ context.read <AccountBloc >().add (const AccountLogoutRequested ());
146
+ // Global redirect will be handled by AppBloc/GoRouter
147
+ },
148
+ // Assuming l10n.accountSignOutButton exists or will be added
149
+ // Reusing existing tile text for now as button text might differ
150
+ child: Text (l10n.accountSignOutTile),
145
151
),
146
- onTap: () {
147
- context.read <AccountBloc >().add (const AccountLogoutRequested ());
148
- // Global redirect will be handled by AppBloc/GoRouter
149
- },
150
152
);
151
153
}
152
154
153
- /// Builds the ListTile prompting anonymous users to sign in/connect .
154
- Widget _buildBackupTile (BuildContext context) {
155
+ /// Builds the ListTile for navigating to Settings .
156
+ Widget _buildSettingsTile (BuildContext context) {
155
157
final l10n = context.l10n;
156
158
return ListTile (
157
- leading: const Icon (Icons .link),
158
- title: Text (l10n.accountConnectPrompt),
159
- subtitle: Text (l10n.accountConnectBenefit),
160
- isThreeLine: true , // Allow more space for subtitle
159
+ leading: const Icon (Icons .settings_outlined),
160
+ title: Text (l10n.accountSettingsTile),
161
161
trailing: const Icon (Icons .chevron_right),
162
162
onTap: () {
163
- // Navigate to the authentication page in linking mode
164
- context.goNamed (
165
- Routes .authenticationName,
166
- queryParameters: {'context' : 'linking' },
167
- );
163
+ // Navigate to the existing settings route
164
+ context.goNamed (Routes .settingsName);
168
165
},
169
166
);
170
167
}
171
-
172
- /// Helper to convert AuthenticationStatus enum to a display string.
173
- String _authenticationStatusToString (
174
- BuildContext context,
175
- AuthenticationStatus status,
176
- ) {
177
- final l10n = context.l10n;
178
- switch (status) {
179
- case AuthenticationStatus .authenticated:
180
- return l10n.accountStatusAuthenticated;
181
- case AuthenticationStatus .anonymous:
182
- return l10n.accountStatusAnonymous;
183
- case AuthenticationStatus .unauthenticated:
184
- return l10n.accountStatusUnauthenticated;
185
- }
186
- }
187
168
}
0 commit comments