Skip to content

Commit bf18995

Browse files
committed
feat(settings_page): update SettingsPage for AppSettings model
This commit updates the `SettingsPage` to use the `AppSettings` model instead of `UserAppSettings` for its `SettingsBloc` and `AppBloc` interactions, ensuring type consistency with the updated core package.
1 parent 0df8dd7 commit bf18995

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

lib/settings/view/settings_page.dart

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ class SettingsPage extends StatelessWidget {
2020
Widget build(BuildContext context) {
2121
return BlocProvider(
2222
create: (context) => SettingsBloc(
23-
userAppSettingsRepository: context
24-
.read<DataRepository<UserAppSettings>>(),
23+
appSettingsRepository:
24+
context
25+
.read<
26+
DataRepository<AppSettings>
27+
>(),
2528
)..add(SettingsLoaded(userId: context.read<AppBloc>().state.user?.id)),
2629
child: const _SettingsView(),
2730
);
@@ -86,9 +89,12 @@ class _SettingsViewState extends State<_SettingsView> {
8689
SnackBar(content: Text(l10n.settingsSavedSuccessfully)),
8790
);
8891
// Trigger AppBloc to reload settings for immediate UI update
89-
if (state.userAppSettings != null) {
92+
if (state.appSettings != null) {
93+
9094
context.read<AppBloc>().add(
91-
AppUserAppSettingsChanged(state.userAppSettings!),
95+
AppUserAppSettingsChanged(
96+
state.appSettings!,
97+
),
9298
);
9399
}
94100
} else if (state is SettingsUpdateFailure) {
@@ -102,7 +108,7 @@ class _SettingsViewState extends State<_SettingsView> {
102108
}
103109
},
104110
builder: (context, state) {
105-
if (state.userAppSettings == null &&
111+
if (state.appSettings == null &&
106112
state is! SettingsLoadInProgress) {
107113
// If settings are null and not loading, try to load them
108114
context.read<SettingsBloc>().add(
@@ -127,8 +133,9 @@ class _SettingsViewState extends State<_SettingsView> {
127133
);
128134
},
129135
);
130-
} else if (state.userAppSettings != null) {
131-
final userAppSettings = state.userAppSettings!;
136+
} else if (state.appSettings != null) {
137+
138+
final appSettings = state.appSettings!;
132139
return ListView(
133140
padding: const EdgeInsets.all(AppSpacing.lg),
134141
children: [
@@ -159,7 +166,7 @@ class _SettingsViewState extends State<_SettingsView> {
159166
title: l10n.baseThemeLabel,
160167
description: l10n.baseThemeDescription,
161168
child: DropdownButton<AppBaseTheme>(
162-
value: userAppSettings.displaySettings.baseTheme,
169+
value: appSettings.displaySettings.baseTheme,
163170
onChanged: (value) {
164171
if (value != null) {
165172
context.read<SettingsBloc>().add(
@@ -185,7 +192,7 @@ class _SettingsViewState extends State<_SettingsView> {
185192
title: l10n.accentThemeLabel,
186193
description: l10n.accentThemeDescription,
187194
child: DropdownButton<AppAccentTheme>(
188-
value: userAppSettings.displaySettings.accentTheme,
195+
value: appSettings.displaySettings.accentTheme,
189196
onChanged: (value) {
190197
if (value != null) {
191198
context.read<SettingsBloc>().add(
@@ -218,7 +225,7 @@ class _SettingsViewState extends State<_SettingsView> {
218225
title: l10n.fontFamilyLabel,
219226
description: l10n.fontFamilyDescription,
220227
child: DropdownButton<String>(
221-
value: userAppSettings.displaySettings.fontFamily,
228+
value: appSettings.displaySettings.fontFamily,
222229
onChanged: (value) {
223230
if (value != null) {
224231
context.read<SettingsBloc>().add(
@@ -242,8 +249,7 @@ class _SettingsViewState extends State<_SettingsView> {
242249
title: l10n.textScaleFactorLabel,
243250
description: l10n.textScaleFactorDescription,
244251
child: DropdownButton<AppTextScaleFactor>(
245-
value:
246-
userAppSettings.displaySettings.textScaleFactor,
252+
value: appSettings.displaySettings.textScaleFactor,
247253
onChanged: (value) {
248254
if (value != null) {
249255
context.read<SettingsBloc>().add(
@@ -269,7 +275,7 @@ class _SettingsViewState extends State<_SettingsView> {
269275
title: l10n.fontWeightLabel,
270276
description: l10n.fontWeightDescription,
271277
child: DropdownButton<AppFontWeight>(
272-
value: userAppSettings.displaySettings.fontWeight,
278+
value: appSettings.displaySettings.fontWeight,
273279
onChanged: (value) {
274280
if (value != null) {
275281
context.read<SettingsBloc>().add(
@@ -316,7 +322,7 @@ class _SettingsViewState extends State<_SettingsView> {
316322
horizontal: AppSpacing.xxl,
317323
),
318324
child: _LanguageSelectionList(
319-
currentLanguage: userAppSettings.language,
325+
currentLanguage: appSettings.language,
320326
l10n: l10n,
321327
),
322328
),

0 commit comments

Comments
 (0)