Skip to content

Commit d41a7c8

Browse files
committed
style: misc fix
1 parent 253a83c commit d41a7c8

14 files changed

+205
-177
lines changed

lib/account/view/account_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:ht_main/l10n/l10n.dart';
88
import 'package:ht_main/router/routes.dart';
99
import 'package:ht_main/shared/constants/app_spacing.dart';
1010

11-
1211
/// {@template account_view}
1312
/// Displays the user's account information and actions.
1413
/// Adapts UI based on authentication status (authenticated vs. anonymous).

lib/app/bloc/app_bloc.dart

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'dart:async';
22

3-
import 'dart:async';
4-
53
import 'package:bloc/bloc.dart';
64
import 'package:equatable/equatable.dart';
75
import 'package:flex_color_scheme/flex_color_scheme.dart'; // Added
@@ -20,10 +18,10 @@ class AppBloc extends Bloc<AppEvent, AppState> {
2018
AppBloc({
2119
required HtAuthenticationRepository authenticationRepository,
2220
required HtPreferencesRepository preferencesRepository, // Added
23-
}) : _authenticationRepository = authenticationRepository,
24-
_preferencesRepository = preferencesRepository, // Added
25-
// Initialize with default state, load settings after user is known
26-
super(AppState()) {
21+
}) : _authenticationRepository = authenticationRepository,
22+
_preferencesRepository = preferencesRepository, // Added
23+
// Initialize with default state, load settings after user is known
24+
super(AppState()) {
2725
on<AppUserChanged>(_onAppUserChanged);
2826
// Add handler for explicitly refreshing settings if needed later
2927
on<AppSettingsRefreshed>(_onAppSettingsRefreshed);
@@ -55,10 +53,10 @@ class AppBloc extends Bloc<AppEvent, AppState> {
5553
return; // Don't load settings for unauthenticated users
5654
case AuthenticationStatus.anonymous:
5755
status = AppStatus.anonymous;
58-
break; // Continue to load settings for anonymous
56+
// Continue to load settings for anonymous
5957
case AuthenticationStatus.authenticated:
6058
status = AppStatus.authenticated;
61-
break; // Continue to load settings for authenticated
59+
// Continue to load settings for authenticated
6260
}
6361

6462
// Emit user and status update first
@@ -79,10 +77,12 @@ class AppBloc extends Bloc<AppEvent, AppState> {
7977

8078
try {
8179
// Fetch relevant settings
82-
final themeSettings =
83-
await _tryFetch(_preferencesRepository.getThemeSettings);
84-
final appSettings =
85-
await _tryFetch(_preferencesRepository.getAppSettings);
80+
final themeSettings = await _tryFetch(
81+
_preferencesRepository.getThemeSettings,
82+
);
83+
final appSettings = await _tryFetch(
84+
_preferencesRepository.getAppSettings,
85+
);
8686

8787
// Map settings to AppState properties
8888
final newThemeMode = _mapAppThemeMode(
@@ -91,11 +91,10 @@ class AppBloc extends Bloc<AppEvent, AppState> {
9191
final newFlexScheme = _mapAppThemeName(
9292
themeSettings?.themeName ?? AppThemeName.grey, // Default
9393
);
94-
final newFontFamily = _mapAppFontType(
95-
appSettings?.appFontType,
96-
);
94+
final newFontFamily = _mapAppFontType(appSettings?.appFontType);
9795
// Extract App Font Size
98-
final newAppFontSize = appSettings?.appFontSize ?? FontSize.medium; // Default
96+
final newAppFontSize =
97+
appSettings?.appFontSize ?? FontSize.medium; // Default
9998

10099
emit(
101100
state.copyWith(
@@ -136,7 +135,6 @@ class AppBloc extends Bloc<AppEvent, AppState> {
136135
case AppThemeMode.dark:
137136
return ThemeMode.dark;
138137
case AppThemeMode.system:
139-
default:
140138
return ThemeMode.system;
141139
}
142140
}
@@ -148,7 +146,6 @@ class AppBloc extends Bloc<AppEvent, AppState> {
148146
case AppThemeName.blue:
149147
return FlexScheme.blue;
150148
case AppThemeName.grey:
151-
default:
152149
return FlexScheme.material; // Default grey maps to material
153150
}
154151
}
@@ -167,9 +164,6 @@ class AppBloc extends Bloc<AppEvent, AppState> {
167164
return GoogleFonts.montserrat().fontFamily;
168165
case AppFontType.merriweather:
169166
return GoogleFonts.merriweather().fontFamily;
170-
// Add other fonts if necessary
171-
default:
172-
return null; // Fallback to theme default
173167
}
174168
}
175169

lib/app/bloc/app_event.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ abstract class AppEvent extends Equatable {
99

1010
@Deprecated('Use SettingsBloc events instead')
1111
class AppThemeChanged extends AppEvent {
12+
//
13+
// ignore: deprecated_consistency
1214
const AppThemeChanged();
1315
}
1416

lib/app/bloc/app_state.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class AppState extends Equatable {
7474

7575
@override
7676
List<Object?> get props => [
77-
selectedBottomNavigationIndex,
78-
themeMode,
79-
flexScheme,
80-
fontFamily,
81-
appFontSize, // Added
82-
status,
83-
user,
84-
];
77+
selectedBottomNavigationIndex,
78+
themeMode,
79+
flexScheme,
80+
fontFamily,
81+
appFontSize, // Added
82+
status,
83+
user,
84+
];
8585
}

lib/app/view/app.dart

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class App extends StatelessWidget {
3030
required HtPreferencesRepository htPreferencesRepository, // Added
3131
required HtKVStorageService kvStorageService,
3232
super.key,
33-
}) : _htAuthenticationRepository = htAuthenticationRepository,
34-
_htHeadlinesRepository = htHeadlinesRepository,
35-
_htCategoriesRepository = htCategoriesRepository,
36-
_htCountriesRepository = htCountriesRepository,
37-
_htSourcesRepository = htSourcesRepository,
38-
_htPreferencesRepository = htPreferencesRepository, // Added
39-
_kvStorageService = kvStorageService;
33+
}) : _htAuthenticationRepository = htAuthenticationRepository,
34+
_htHeadlinesRepository = htHeadlinesRepository,
35+
_htCategoriesRepository = htCategoriesRepository,
36+
_htCountriesRepository = htCountriesRepository,
37+
_htSourcesRepository = htSourcesRepository,
38+
_htPreferencesRepository = htPreferencesRepository, // Added
39+
_kvStorageService = kvStorageService;
4040

4141
final HtAuthenticationRepository _htAuthenticationRepository;
4242
final HtHeadlinesRepository _htHeadlinesRepository;
@@ -62,11 +62,13 @@ class App extends StatelessWidget {
6262
child: MultiBlocProvider(
6363
providers: [
6464
BlocProvider(
65-
create: (context) => AppBloc(
66-
authenticationRepository:
67-
context.read<HtAuthenticationRepository>(),
68-
preferencesRepository: context.read<HtPreferencesRepository>(), // Added
69-
),
65+
create:
66+
(context) => AppBloc(
67+
authenticationRepository:
68+
context.read<HtAuthenticationRepository>(),
69+
preferencesRepository:
70+
context.read<HtPreferencesRepository>(), // Added
71+
),
7072
),
7173
BlocProvider(
7274
create:
@@ -228,11 +230,12 @@ class _AppViewState extends State<_AppView> {
228230
},
229231
child: BlocBuilder<AppBloc, AppState>(
230232
// Build when theme-related properties change (including font size)
231-
buildWhen: (previous, current) =>
232-
previous.themeMode != current.themeMode ||
233-
previous.flexScheme != current.flexScheme ||
234-
previous.fontFamily != current.fontFamily ||
235-
previous.appFontSize != current.appFontSize, // Added condition
233+
buildWhen:
234+
(previous, current) =>
235+
previous.themeMode != current.themeMode ||
236+
previous.flexScheme != current.flexScheme ||
237+
previous.fontFamily != current.fontFamily ||
238+
previous.appFontSize != current.appFontSize, // Added condition
236239
builder: (context, state) {
237240
return MaterialApp.router(
238241
debugShowCheckedModeBanner: false,

lib/router/router.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:flutter/material.dart';
32
import 'package:flutter_bloc/flutter_bloc.dart';
43
import 'package:go_router/go_router.dart';
@@ -405,10 +404,13 @@ GoRouter createRouter({
405404
builder: (context, state) {
406405
// Provide SettingsBloc here for SettingsPage and its children
407406
return BlocProvider(
408-
create: (context) => SettingsBloc(
409-
preferencesRepository:
410-
context.read<HtPreferencesRepository>(),
411-
)..add(const SettingsLoadRequested()), // Load on entry
407+
create:
408+
(context) => SettingsBloc(
409+
preferencesRepository:
410+
context.read<HtPreferencesRepository>(),
411+
)..add(
412+
const SettingsLoadRequested(),
413+
), // Load on entry
412414
child: const SettingsPage(), // Use the actual page
413415
);
414416
},
@@ -417,8 +419,8 @@ GoRouter createRouter({
417419
GoRoute(
418420
path: Routes.settingsAppearance, // 'appearance'
419421
name: Routes.settingsAppearanceName,
420-
builder: (context, state) =>
421-
const AppearanceSettingsPage(),
422+
builder:
423+
(context, state) => const AppearanceSettingsPage(),
422424
// SettingsBloc is inherited from parent route
423425
),
424426
GoRoute(
@@ -429,14 +431,15 @@ GoRouter createRouter({
429431
GoRoute(
430432
path: Routes.settingsArticle, // 'article'
431433
name: Routes.settingsArticleName,
432-
builder: (context, state) =>
433-
const ArticleSettingsPage(),
434+
builder:
435+
(context, state) => const ArticleSettingsPage(),
434436
),
435437
GoRoute(
436438
path: Routes.settingsNotifications, // 'notifications'
437439
name: Routes.settingsNotificationsName,
438-
builder: (context, state) =>
439-
const NotificationSettingsPage(),
440+
builder:
441+
(context, state) =>
442+
const NotificationSettingsPage(),
440443
),
441444
],
442445
),

0 commit comments

Comments
 (0)