Skip to content

Commit 105e551

Browse files
committed
style: format
1 parent e6de862 commit 105e551

File tree

4 files changed

+77
-65
lines changed

4 files changed

+77
-65
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ class AppBloc extends Bloc<AppEvent, AppState> {
6363
// If user is authenticated, load their app settings
6464
if (event.user != null) {
6565
try {
66-
final userAppSettings =
67-
await _userAppSettingsRepository.read(id: event.user!.id);
66+
final userAppSettings = await _userAppSettingsRepository.read(
67+
id: event.user!.id,
68+
);
6869
emit(state.copyWith(userAppSettings: userAppSettings));
6970
} on NotFoundException {
7071
// If settings not found, create default ones
@@ -95,7 +96,9 @@ class AppBloc extends Bloc<AppEvent, AppState> {
9596

9697
void _onLogoutRequested(AppLogoutRequested event, Emitter<AppState> emit) {
9798
unawaited(_authenticationRepository.signOut());
98-
emit(state.copyWith(clearUserAppSettings: true)); // Clear settings on logout
99+
emit(
100+
state.copyWith(clearUserAppSettings: true),
101+
); // Clear settings on logout
99102
}
100103

101104
@override

lib/app/bloc/app_state.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class AppState extends Equatable {
4949
status: status ?? this.status,
5050
user: user ?? this.user,
5151
environment: clearEnvironment ? null : environment ?? this.environment,
52-
userAppSettings:
53-
clearUserAppSettings ? null : userAppSettings ?? this.userAppSettings,
52+
userAppSettings: clearUserAppSettings
53+
? null
54+
: userAppSettings ?? this.userAppSettings,
5455
);
5556
}
5657

lib/settings/bloc/settings_bloc.dart

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ part 'settings_state.dart';
1111
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
1212
SettingsBloc({
1313
required HtDataRepository<UserAppSettings> userAppSettingsRepository,
14-
}) : _userAppSettingsRepository = userAppSettingsRepository,
15-
super(SettingsInitial()) {
14+
}) : _userAppSettingsRepository = userAppSettingsRepository,
15+
super(SettingsInitial()) {
1616
on<SettingsLoaded>(_onSettingsLoaded);
1717
on<SettingsBaseThemeChanged>(_onSettingsBaseThemeChanged);
1818
on<SettingsAccentThemeChanged>(_onSettingsAccentThemeChanged);
@@ -31,8 +31,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
3131
emit(SettingsLoadInProgress());
3232
try {
3333
// Assuming a fixed ID for user settings, or fetching based on current user
34-
final userAppSettings =
35-
await _userAppSettingsRepository.read(id: event.userId!);
34+
final userAppSettings = await _userAppSettingsRepository.read(
35+
id: event.userId!,
36+
);
3637
emit(SettingsLoadSuccess(userAppSettings: userAppSettings));
3738
} on NotFoundException {
3839
final defaultSettings = UserAppSettings(id: event.userId!);
@@ -70,8 +71,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
7071
if (state is SettingsLoadSuccess) {
7172
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
7273
final updatedSettings = currentSettings.copyWith(
73-
displaySettings:
74-
currentSettings.displaySettings.copyWith(baseTheme: event.baseTheme),
74+
displaySettings: currentSettings.displaySettings.copyWith(
75+
baseTheme: event.baseTheme,
76+
),
7577
);
7678
await _updateSettings(updatedSettings, emit);
7779
}
@@ -84,8 +86,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
8486
if (state is SettingsLoadSuccess) {
8587
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
8688
final updatedSettings = currentSettings.copyWith(
87-
displaySettings: currentSettings.displaySettings
88-
.copyWith(accentTheme: event.accentTheme),
89+
displaySettings: currentSettings.displaySettings.copyWith(
90+
accentTheme: event.accentTheme,
91+
),
8992
);
9093
await _updateSettings(updatedSettings, emit);
9194
}
@@ -98,8 +101,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
98101
if (state is SettingsLoadSuccess) {
99102
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
100103
final updatedSettings = currentSettings.copyWith(
101-
displaySettings: currentSettings.displaySettings
102-
.copyWith(fontFamily: event.fontFamily),
104+
displaySettings: currentSettings.displaySettings.copyWith(
105+
fontFamily: event.fontFamily,
106+
),
103107
);
104108
await _updateSettings(updatedSettings, emit);
105109
}
@@ -112,8 +116,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
112116
if (state is SettingsLoadSuccess) {
113117
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
114118
final updatedSettings = currentSettings.copyWith(
115-
displaySettings: currentSettings.displaySettings
116-
.copyWith(textScaleFactor: event.textScaleFactor),
119+
displaySettings: currentSettings.displaySettings.copyWith(
120+
textScaleFactor: event.textScaleFactor,
121+
),
117122
);
118123
await _updateSettings(updatedSettings, emit);
119124
}
@@ -126,8 +131,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
126131
if (state is SettingsLoadSuccess) {
127132
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
128133
final updatedSettings = currentSettings.copyWith(
129-
displaySettings: currentSettings.displaySettings
130-
.copyWith(fontWeight: event.fontWeight),
134+
displaySettings: currentSettings.displaySettings.copyWith(
135+
fontWeight: event.fontWeight,
136+
),
131137
);
132138
await _updateSettings(updatedSettings, emit);
133139
}
@@ -139,8 +145,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
139145
) async {
140146
if (state is SettingsLoadSuccess) {
141147
final currentSettings = (state as SettingsLoadSuccess).userAppSettings;
142-
final updatedSettings =
143-
currentSettings.copyWith(language: event.language);
148+
final updatedSettings = currentSettings.copyWith(
149+
language: event.language,
150+
);
144151
await _updateSettings(updatedSettings, emit);
145152
}
146153
}

lib/settings/view/settings_page.dart

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class SettingsPage extends StatelessWidget {
2020
Widget build(BuildContext context) {
2121
return BlocProvider(
2222
create: (context) => SettingsBloc(
23-
userAppSettingsRepository:
24-
context.read<HtDataRepository<UserAppSettings>>(),
23+
userAppSettingsRepository: context
24+
.read<HtDataRepository<UserAppSettings>>(),
2525
)..add(SettingsLoaded(userId: context.read<AppBloc>().state.user?.id)),
2626
child: const _SettingsView(),
2727
);
@@ -40,7 +40,8 @@ class _SettingsView extends StatelessWidget {
4040
),
4141
body: BlocConsumer<SettingsBloc, SettingsState>(
4242
listenWhen: (previous, current) =>
43-
current is SettingsUpdateSuccess || current is SettingsUpdateFailure,
43+
current is SettingsUpdateSuccess ||
44+
current is SettingsUpdateFailure,
4445
listener: (context, state) {
4546
if (state is SettingsUpdateSuccess) {
4647
ScaffoldMessenger.of(context)
@@ -52,23 +53,23 @@ class _SettingsView extends StatelessWidget {
5253
);
5354
// Optionally, trigger AppBloc to reload settings if it caches them
5455
context.read<AppBloc>().add(
55-
AppUserChanged(
56-
context.read<AppBloc>().state.user?.copyWith(
57-
// This is a simplified way to trigger AppBloc update.
58-
// A more robust solution might involve AppBloc listening
59-
// to SettingsBloc directly or a dedicated event.
60-
// For now, we'll rely on the AppBloc's authStateChanges
61-
// listener to eventually pick up the change if the
62-
// repository emits it, or a manual refresh.
63-
// For immediate UI update, we might need to pass the
64-
// updated settings to AppBloc.
65-
// For this task, we'll assume AppBloc will react
66-
// to the repository change or a full app restart.
67-
// A better approach would be to have AppBloc listen
68-
// to UserAppSettings changes from its repository.
69-
),
70-
),
71-
);
56+
AppUserChanged(
57+
context.read<AppBloc>().state.user?.copyWith(
58+
// This is a simplified way to trigger AppBloc update.
59+
// A more robust solution might involve AppBloc listening
60+
// to SettingsBloc directly or a dedicated event.
61+
// For now, we'll rely on the AppBloc's authStateChanges
62+
// listener to eventually pick up the change if the
63+
// repository emits it, or a manual refresh.
64+
// For immediate UI update, we might need to pass the
65+
// updated settings to AppBloc.
66+
// For this task, we'll assume AppBloc will react
67+
// to the repository change or a full app restart.
68+
// A better approach would be to have AppBloc listen
69+
// to UserAppSettings changes from its repository.
70+
),
71+
),
72+
);
7273
} else if (state is SettingsUpdateFailure) {
7374
ScaffoldMessenger.of(context)
7475
..hideCurrentSnackBar()
@@ -93,10 +94,10 @@ class _SettingsView extends StatelessWidget {
9394
message: l10n.failedToLoadSettingsMessage(state.errorMessage),
9495
onRetry: () {
9596
context.read<SettingsBloc>().add(
96-
SettingsLoaded(
97-
userId: context.read<AppBloc>().state.user?.id,
98-
),
99-
);
97+
SettingsLoaded(
98+
userId: context.read<AppBloc>().state.user?.id,
99+
),
100+
);
100101
},
101102
);
102103
} else if (state is SettingsLoadSuccess) {
@@ -132,9 +133,9 @@ class _SettingsView extends StatelessWidget {
132133
value: userAppSettings.displaySettings.baseTheme,
133134
onChanged: (value) {
134135
if (value != null) {
135-
context
136-
.read<SettingsBloc>()
137-
.add(SettingsBaseThemeChanged(value));
136+
context.read<SettingsBloc>().add(
137+
SettingsBaseThemeChanged(value),
138+
);
138139
}
139140
},
140141
items: AppBaseTheme.values
@@ -158,9 +159,9 @@ class _SettingsView extends StatelessWidget {
158159
value: userAppSettings.displaySettings.accentTheme,
159160
onChanged: (value) {
160161
if (value != null) {
161-
context
162-
.read<SettingsBloc>()
163-
.add(SettingsAccentThemeChanged(value));
162+
context.read<SettingsBloc>().add(
163+
SettingsAccentThemeChanged(value),
164+
);
164165
}
165166
},
166167
items: AppAccentTheme.values
@@ -184,9 +185,9 @@ class _SettingsView extends StatelessWidget {
184185
value: userAppSettings.displaySettings.fontFamily,
185186
onChanged: (value) {
186187
if (value != null) {
187-
context
188-
.read<SettingsBloc>()
189-
.add(SettingsFontFamilyChanged(value));
188+
context.read<SettingsBloc>().add(
189+
SettingsFontFamilyChanged(value),
190+
);
190191
}
191192
},
192193
items: _supportedFontFamilies
@@ -210,9 +211,9 @@ class _SettingsView extends StatelessWidget {
210211
value: userAppSettings.displaySettings.textScaleFactor,
211212
onChanged: (value) {
212213
if (value != null) {
213-
context
214-
.read<SettingsBloc>()
215-
.add(SettingsTextScaleFactorChanged(value));
214+
context.read<SettingsBloc>().add(
215+
SettingsTextScaleFactorChanged(value),
216+
);
216217
}
217218
},
218219
items: AppTextScaleFactor.values
@@ -236,9 +237,9 @@ class _SettingsView extends StatelessWidget {
236237
value: userAppSettings.displaySettings.fontWeight,
237238
onChanged: (value) {
238239
if (value != null) {
239-
context
240-
.read<SettingsBloc>()
241-
.add(SettingsFontWeightChanged(value));
240+
context.read<SettingsBloc>().add(
241+
SettingsFontWeightChanged(value),
242+
);
242243
}
243244
},
244245
items: AppFontWeight.values
@@ -262,9 +263,9 @@ class _SettingsView extends StatelessWidget {
262263
value: userAppSettings.language,
263264
onChanged: (value) {
264265
if (value != null) {
265-
context
266-
.read<SettingsBloc>()
267-
.add(SettingsLanguageChanged(value));
266+
context.read<SettingsBloc>().add(
267+
SettingsLanguageChanged(value),
268+
);
268269
}
269270
},
270271
items: _supportedLanguages
@@ -299,8 +300,8 @@ class _SettingsView extends StatelessWidget {
299300
Text(
300301
description,
301302
style: Theme.of(context).textTheme.bodySmall?.copyWith(
302-
color: Theme.of(context).colorScheme.onSurfaceVariant,
303-
),
303+
color: Theme.of(context).colorScheme.onSurfaceVariant,
304+
),
304305
),
305306
const SizedBox(height: AppSpacing.sm),
306307
Align(

0 commit comments

Comments
 (0)