Skip to content

Commit 4e596f6

Browse files
committed
refactor(settings): use AppTextScaleFactor enum
- Replaced FontSize enum - Updated event and state - Updated dropdown setting
1 parent a8067d0 commit 4e596f6

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

lib/settings/view/article_settings_page.dart

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:ht_main/l10n/l10n.dart';
44
import 'package:ht_main/settings/bloc/settings_bloc.dart';
55
import 'package:ht_main/shared/constants/constants.dart';
6-
import 'package:ht_preferences_client/ht_preferences_client.dart';
6+
import 'package:ht_shared/ht_shared.dart'
7+
show AppTextScaleFactor; // Import new enum
78

89
/// {@template article_settings_page}
910
/// A page for configuring article display settings.
@@ -12,15 +13,21 @@ class ArticleSettingsPage extends StatelessWidget {
1213
/// {@macro article_settings_page}
1314
const ArticleSettingsPage({super.key});
1415

15-
// Helper to map FontSize enum to user-friendly strings
16-
String _fontSizeToString(FontSize size, AppLocalizations l10n) {
17-
switch (size) {
18-
case FontSize.small:
16+
// Helper to map AppTextScaleFactor enum to user-friendly strings
17+
String _textScaleFactorToString(
18+
AppTextScaleFactor factor,
19+
AppLocalizations l10n,
20+
) {
21+
switch (factor) {
22+
case AppTextScaleFactor.small:
1923
return l10n.settingsAppearanceFontSizeSmall; // Reuse key
20-
case FontSize.large:
21-
return l10n.settingsAppearanceFontSizeLarge; // Reuse key
22-
case FontSize.medium:
24+
case AppTextScaleFactor.medium:
2325
return l10n.settingsAppearanceFontSizeMedium; // Reuse key
26+
case AppTextScaleFactor.large:
27+
return l10n.settingsAppearanceFontSizeLarge; // Reuse key
28+
case AppTextScaleFactor.extraLarge:
29+
return l10n
30+
.settingsAppearanceFontSizeExtraLarge; // Add l10n key if needed
2431
}
2532
}
2633

@@ -48,15 +55,21 @@ class ArticleSettingsPage extends StatelessWidget {
4855
padding: const EdgeInsets.all(AppSpacing.lg),
4956
children: [
5057
// --- Article Font Size ---
51-
_buildDropdownSetting<FontSize>(
58+
_buildDropdownSetting<AppTextScaleFactor>(
5259
context: context,
5360
title: l10n.settingsArticleFontSizeLabel, // Add l10n key
54-
currentValue: state.articleSettings.articleFontSize,
55-
items: FontSize.values,
56-
itemToString: (size) => _fontSizeToString(size, l10n),
61+
currentValue:
62+
state
63+
.userAppSettings
64+
.displaySettings
65+
.textScaleFactor, // Use new model field
66+
items: AppTextScaleFactor.values,
67+
itemToString: (factor) => _textScaleFactorToString(factor, l10n),
5768
onChanged: (value) {
5869
if (value != null) {
59-
settingsBloc.add(SettingsArticleFontSizeChanged(value));
70+
settingsBloc.add(
71+
SettingsAppFontSizeChanged(value),
72+
); // Use new event
6073
}
6174
},
6275
),

0 commit comments

Comments
 (0)