Skip to content

Commit e9a9f35

Browse files
committed
style: code cleanup and formatting
- Applied minor formatting changes - Removed unnecessary comments - Improved code readability
1 parent 12e727e commit e9a9f35

File tree

8 files changed

+114
-105
lines changed

8 files changed

+114
-105
lines changed

lib/account/view/account_page.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ class _AccountView extends StatelessWidget {
110110
const SizedBox(height: 4),
111111
Text(
112112
// Convert enum to user-friendly string
113-
_authenticationStatusToString(
114-
context,
115-
user.authenticationStatus,
116-
),
113+
_authenticationStatusToString(context, user.authenticationStatus),
117114
style: textTheme.bodyMedium?.copyWith(
118115
color: theme.colorScheme.secondary,
119116
),

lib/authentication/bloc/authentication_event.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ final class AuthenticationSendSignInLinkRequested extends AuthenticationEvent {
3232
/// {@endtemplate}
3333
final class AuthenticationSignInWithLinkAttempted extends AuthenticationEvent {
3434
/// {@macro authentication_sign_in_with_link_attempted}
35-
const AuthenticationSignInWithLinkAttempted({
36-
required this.emailLink,
37-
});
35+
const AuthenticationSignInWithLinkAttempted({required this.emailLink});
3836

3937
/// The sign-in link received by the app.
4038
final String emailLink;

lib/authentication/view/authentication_page.dart

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//
12
// ignore_for_file: lines_longer_than_80_chars
23

34
import 'package:flutter/material.dart';
@@ -7,7 +8,7 @@ import 'package:ht_authentication_repository/ht_authentication_repository.dart';
78
import 'package:ht_main/authentication/bloc/authentication_bloc.dart';
89
import 'package:ht_main/l10n/l10n.dart';
910
import 'package:ht_main/router/routes.dart';
10-
import 'package:ht_main/shared/constants/app_spacing.dart';
11+
import 'package:ht_main/shared/constants/app_spacing.dart';
1112

1213
/// {@template authentication_page}
1314
/// Displays authentication options (Google, Email, Anonymous) based on context.
@@ -83,16 +84,20 @@ class _AuthenticationView extends StatelessWidget {
8384
backgroundColor: Colors.transparent,
8485
elevation: 0,
8586
// Conditionally add the leading close button only in linking context
86-
leading: isLinkingContext
87-
? IconButton(
88-
icon: const Icon(Icons.close),
89-
tooltip: MaterialLocalizations.of(context).closeButtonTooltip, // Accessibility
90-
onPressed: () {
91-
// Navigate back to the account page when close is pressed
92-
context.goNamed(Routes.accountName);
93-
},
94-
)
95-
: null, // No leading button if not linking (relies on system back if pushed)
87+
leading:
88+
isLinkingContext
89+
? IconButton(
90+
icon: const Icon(Icons.close),
91+
tooltip:
92+
MaterialLocalizations.of(
93+
context,
94+
).closeButtonTooltip, // Accessibility
95+
onPressed: () {
96+
// Navigate back to the account page when close is pressed
97+
context.goNamed(Routes.accountName);
98+
},
99+
)
100+
: null, // No leading button if not linking (relies on system back if pushed)
96101
),
97102
body: SafeArea(
98103
child: BlocConsumer<AuthenticationBloc, AuthenticationState>(
@@ -120,9 +125,7 @@ class _AuthenticationView extends StatelessWidget {
120125
state is AuthenticationLoading; // Simplified loading check
121126

122127
return Padding(
123-
padding: const EdgeInsets.all(
124-
AppSpacing.paddingLarge,
125-
),
128+
padding: const EdgeInsets.all(AppSpacing.paddingLarge),
126129
child: Center(
127130
child: SingleChildScrollView(
128131
child: Column(
@@ -137,27 +140,29 @@ class _AuthenticationView extends StatelessWidget {
137140
), // Spacing below icon
138141
child: Icon(
139142
Icons.security, // Hardcode the icon
140-
size: (Theme.of(context).iconTheme.size ?? AppSpacing.xl) *
141-
3.0,
142-
color: Theme.of(context)
143-
.colorScheme
144-
.primary,
143+
size:
144+
(Theme.of(context).iconTheme.size ??
145+
AppSpacing.xl) *
146+
3.0,
147+
color: Theme.of(context).colorScheme.primary,
145148
),
146149
),
147-
const SizedBox(height: AppSpacing.lg), // Space between icon and headline
150+
const SizedBox(
151+
height: AppSpacing.lg,
152+
), // Space between icon and headline
148153
// --- Headline and Subheadline ---
149154
Text(
150155
headline,
151156
style: textTheme.headlineMedium,
152157
textAlign: TextAlign.center,
153158
),
154-
const SizedBox(height: AppSpacing.sm),
159+
const SizedBox(height: AppSpacing.sm),
155160
Text(
156161
subHeadline,
157162
style: textTheme.bodyLarge,
158163
textAlign: TextAlign.center,
159164
),
160-
const SizedBox(height: AppSpacing.xxl),
165+
const SizedBox(height: AppSpacing.xxl),
161166
// --- Google Sign-In Button ---
162167
ElevatedButton.icon(
163168
icon: const Icon(
@@ -172,14 +177,11 @@ class _AuthenticationView extends StatelessWidget {
172177
),
173178
// Style adjustments can be made via ElevatedButtonThemeData
174179
),
175-
const SizedBox(height: AppSpacing.lg),
180+
const SizedBox(height: AppSpacing.lg),
176181
// --- Email Sign-In Button ---
177182
ElevatedButton(
178183
// Consider an email icon
179184
// icon: const Icon(Icons.email_outlined),
180-
child: Text(
181-
l10n.authenticationEmailSignInButton,
182-
),
183185
onPressed:
184186
isLoading
185187
? null
@@ -191,19 +193,22 @@ class _AuthenticationView extends StatelessWidget {
191193
extra: isLinkingContext,
192194
);
193195
},
196+
// Consider an email icon
197+
// icon: const Icon(Icons.email_outlined),
198+
child: Text(l10n.authenticationEmailSignInButton),
194199
),
195200

196201
// --- Anonymous Sign-In Button (Conditional) ---
197202
if (showAnonymousButton) ...[
198-
const SizedBox(height: AppSpacing.lg),
203+
const SizedBox(height: AppSpacing.lg),
199204
OutlinedButton(
200-
child: Text(l10n.authenticationAnonymousSignInButton),
201205
onPressed:
202206
isLoading
203207
? null
204208
: () => context.read<AuthenticationBloc>().add(
205209
const AuthenticationAnonymousSignInRequested(),
206210
),
211+
child: Text(l10n.authenticationAnonymousSignInButton),
207212
),
208213
],
209214

lib/authentication/view/email_link_sent_page.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:ht_main/l10n/l10n.dart';
33
import 'package:ht_main/shared/constants/app_spacing.dart';
44

55
/// {@template email_link_sent_page}
6-
/// Confirmation page shown after a sign-in link has been sent to the user's email.
7-
/// Instructs the user to check their inbox.
6+
/// Confirmation page shown after a sign-in link has been sent to
7+
/// the user's email. Instructs the user to check their inbox.
88
/// {@endtemplate}
99
class EmailLinkSentPage extends StatelessWidget {
1010
/// {@macro email_link_sent_page}
@@ -25,7 +25,6 @@ class EmailLinkSentPage extends StatelessWidget {
2525
child: Center(
2626
child: Column(
2727
mainAxisAlignment: MainAxisAlignment.center,
28-
crossAxisAlignment: CrossAxisAlignment.center,
2928
children: [
3029
const Icon(
3130
Icons.mark_email_read_outlined, // Suggestive icon

lib/authentication/view/email_sign_in_page.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//
2+
// ignore_for_file: lines_longer_than_80_chars
3+
14
import 'package:flutter/material.dart';
25
import 'package:flutter_bloc/flutter_bloc.dart';
36
import 'package:go_router/go_router.dart';
@@ -42,7 +45,7 @@ class _EmailSignInView extends StatelessWidget {
4245

4346
return Scaffold(
4447
appBar: AppBar(
45-
title: Text(l10n.emailSignInPageTitle),
48+
title: Text(l10n.emailSignInPageTitle),
4649
// Add a custom leading back button to control navigation based on context.
4750
leading: IconButton(
4851
icon: const Icon(Icons.arrow_back),
@@ -110,19 +113,16 @@ class _EmailSignInView extends StatelessWidget {
110113
size:
111114
(Theme.of(context).iconTheme.size ??
112115
AppSpacing.xl) *
113-
3.0,
114-
color:
115-
Theme.of(
116-
context,
117-
).colorScheme.primary,
116+
3.0,
117+
color: Theme.of(context).colorScheme.primary,
118118
),
119119
),
120120
const SizedBox(
121121
height: AppSpacing.lg,
122122
), // Space between icon and text
123123
// --- Explanation Text ---
124124
Text(
125-
l10n.emailSignInExplanation,
125+
l10n.emailSignInExplanation,
126126
style: Theme.of(context).textTheme.bodyLarge,
127127
textAlign: TextAlign.center,
128128
),
@@ -183,7 +183,7 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
183183
TextFormField(
184184
controller: _emailController,
185185
decoration: InputDecoration(
186-
labelText: l10n.authenticationEmailLabel,
186+
labelText: l10n.authenticationEmailLabel,
187187
border: const OutlineInputBorder(),
188188
// Consider adding hint text if needed
189189
),
@@ -193,8 +193,7 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
193193
enabled: !widget.isLoading,
194194
validator: (value) {
195195
if (value == null || value.isEmpty || !value.contains('@')) {
196-
return l10n
197-
.accountLinkingEmailValidationError;
196+
return l10n.accountLinkingEmailValidationError;
198197
}
199198
return null;
200199
},
@@ -211,9 +210,7 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
211210
width: 24,
212211
child: CircularProgressIndicator(strokeWidth: 2),
213212
)
214-
: Text(
215-
l10n.authenticationSendLinkButton,
216-
),
213+
: Text(l10n.authenticationSendLinkButton),
217214
),
218215
],
219216
),

lib/headline-details/view/headline_details_page.dart

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//
12
// ignore_for_file: avoid_redundant_argument_values
23

34
import 'package:flutter/material.dart';
@@ -6,9 +7,7 @@ import 'package:ht_headlines_client/ht_headlines_client.dart';
67
import 'package:ht_headlines_repository/ht_headlines_repository.dart';
78
import 'package:ht_main/headline-details/bloc/headline_details_bloc.dart';
89
import 'package:ht_main/l10n/l10n.dart';
9-
import 'package:ht_main/shared/widgets/failure_state_widget.dart';
10-
import 'package:ht_main/l10n/l10n.dart';
11-
import 'package:ht_main/shared/shared.dart';
10+
import 'package:ht_main/shared/shared.dart';
1211
import 'package:intl/intl.dart';
1312
import 'package:url_launcher/url_launcher_string.dart';
1413

@@ -42,7 +41,7 @@ class _HeadlineDetailsView extends StatelessWidget {
4241
Widget build(BuildContext context) {
4342
final l10n = context.l10n;
4443
return Scaffold(
45-
// Body contains the BlocBuilder which returns either state widgets
44+
// Body contains the BlocBuilder which returns either state widgets
4645
// or the scroll view
4746
body: BlocBuilder<HeadlineDetailsBloc, HeadlineDetailsState>(
4847
builder: (context, state) {
@@ -67,8 +66,10 @@ class _HeadlineDetailsView extends StatelessWidget {
6766
);
6867
},
6968
),
70-
final HeadlineDetailsLoaded state =>
71-
_buildLoadedContent(context, state.headline),
69+
final HeadlineDetailsLoaded state => _buildLoadedContent(
70+
context,
71+
state.headline,
72+
),
7273
_ => const SizedBox.shrink(), // Should not happen in practice
7374
};
7475
},
@@ -126,10 +127,7 @@ class _HeadlineDetailsView extends StatelessWidget {
126127
SliverPadding(
127128
padding: horizontalPadding.copyWith(top: AppSpacing.lg),
128129
sliver: SliverToBoxAdapter(
129-
child: Text(
130-
headline.title,
131-
style: textTheme.headlineMedium,
132-
),
130+
child: Text(headline.title, style: textTheme.headlineMedium),
133131
),
134132
),
135133

@@ -154,20 +152,21 @@ class _HeadlineDetailsView extends StatelessWidget {
154152
return Container(
155153
width: double.infinity,
156154
height: 200,
157-
color: colorScheme.surfaceVariant,
155+
color: colorScheme.surfaceContainerHighest,
158156
child: const Center(child: CircularProgressIndicator()),
159157
);
160158
},
161-
errorBuilder: (context, error, stackTrace) => Container(
162-
width: double.infinity,
163-
height: 200,
164-
color: colorScheme.surfaceVariant,
165-
child: Icon(
166-
Icons.broken_image,
167-
color: colorScheme.onSurfaceVariant,
168-
size: AppSpacing.xxl,
169-
),
170-
),
159+
errorBuilder:
160+
(context, error, stackTrace) => Container(
161+
width: double.infinity,
162+
height: 200,
163+
color: colorScheme.surfaceContainerHighest,
164+
child: Icon(
165+
Icons.broken_image,
166+
color: colorScheme.onSurfaceVariant,
167+
size: AppSpacing.xxl,
168+
),
169+
),
171170
),
172171
),
173172
),
@@ -190,10 +189,7 @@ class _HeadlineDetailsView extends StatelessWidget {
190189
SliverPadding(
191190
padding: horizontalPadding.copyWith(top: AppSpacing.lg),
192191
sliver: SliverToBoxAdapter(
193-
child: Text(
194-
headline.description!,
195-
style: textTheme.bodyLarge,
196-
),
192+
child: Text(headline.description!, style: textTheme.bodyLarge),
197193
),
198194
),
199195

@@ -221,9 +217,9 @@ class _HeadlineDetailsView extends StatelessWidget {
221217

222218
// Add some bottom space if no button exists
223219
if (headline.url == null)
224-
SliverPadding(
225-
padding: const EdgeInsets.only(bottom: AppSpacing.paddingLarge),
226-
sliver: const SliverToBoxAdapter(child: SizedBox.shrink()),
220+
const SliverPadding(
221+
padding: EdgeInsets.only(bottom: AppSpacing.paddingLarge),
222+
sliver: SliverToBoxAdapter(child: SizedBox.shrink()),
227223
),
228224
],
229225
);
@@ -233,8 +229,8 @@ class _HeadlineDetailsView extends StatelessWidget {
233229
List<Widget> _buildMetadataChips(BuildContext context, Headline headline) {
234230
final theme = Theme.of(context);
235231
final textTheme = theme.textTheme;
236-
final chipLabelStyle = textTheme.labelSmall;
237-
final chipBackgroundColor = theme.colorScheme.surfaceVariant;
232+
final chipLabelStyle = textTheme.labelSmall;
233+
final chipBackgroundColor = theme.colorScheme.surfaceContainerHighest;
238234
final chipAvatarColor = theme.colorScheme.onSurfaceVariant;
239235
const chipAvatarSize = 14.0;
240236
const chipPadding = EdgeInsets.symmetric(
@@ -268,7 +264,9 @@ class _HeadlineDetailsView extends StatelessWidget {
268264

269265
// Date Chip
270266
if (headline.publishedAt != null) {
271-
final formattedDate = DateFormat('MMM d, yyyy').format(headline.publishedAt!);
267+
final formattedDate = DateFormat(
268+
'MMM d, yyyy',
269+
).format(headline.publishedAt!);
272270
chips.add(
273271
Chip(
274272
avatar: Icon(
@@ -324,4 +322,4 @@ class _HeadlineDetailsView extends StatelessWidget {
324322

325323
return chips;
326324
}
327-
}
325+
}

0 commit comments

Comments
 (0)