@@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
3
3
import 'package:ht_main/l10n/l10n.dart' ;
4
4
import 'package:ht_main/settings/bloc/settings_bloc.dart' ;
5
5
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' ; // Use types from ht_shared
7
7
8
8
/// {@template appearance_settings_page}
9
9
/// A page for configuring appearance-related settings like theme and fonts.
@@ -12,47 +12,69 @@ class AppearanceSettingsPage extends StatelessWidget {
12
12
/// {@macro appearance_settings_page}
13
13
const AppearanceSettingsPage ({super .key});
14
14
15
- // Helper to map AppThemeMode enum to user-friendly strings
16
- String _themeModeToString ( AppThemeMode mode, AppLocalizations l10n) {
15
+ // Helper to map AppBaseTheme enum to user-friendly strings
16
+ String _baseThemeToString ( AppBaseTheme mode, AppLocalizations l10n) {
17
17
switch (mode) {
18
- case AppThemeMode .light:
19
- return l10n.settingsAppearanceThemeModeLight; // Add l10n key
20
- case AppThemeMode .dark:
21
- return l10n.settingsAppearanceThemeModeDark; // Add l10n key
22
- case AppThemeMode .system:
23
- return l10n.settingsAppearanceThemeModeSystem; // Add l10n key
18
+ case AppBaseTheme .light:
19
+ return l10n.settingsAppearanceThemeModeLight;
20
+ case AppBaseTheme .dark:
21
+ return l10n.settingsAppearanceThemeModeDark;
22
+ case AppBaseTheme .system:
23
+ return l10n.settingsAppearanceThemeModeSystem;
24
24
}
25
25
}
26
26
27
- // Helper to map AppThemeName enum to user-friendly strings
28
- String _themeNameToString ( AppThemeName name, AppLocalizations l10n) {
27
+ // Helper to map AppAccentTheme enum to user-friendly strings
28
+ String _accentThemeToString ( AppAccentTheme name, AppLocalizations l10n) {
29
29
switch (name) {
30
- case AppThemeName .red :
31
- return l10n.settingsAppearanceThemeNameRed; // Add l10n key
32
- case AppThemeName .blue :
33
- return l10n.settingsAppearanceThemeNameBlue; // Add l10n key
34
- case AppThemeName .grey :
35
- return l10n.settingsAppearanceThemeNameGrey; // Add l10n key
30
+ case AppAccentTheme .newsRed :
31
+ return l10n.settingsAppearanceThemeNameRed;
32
+ case AppAccentTheme .defaultBlue :
33
+ return l10n.settingsAppearanceThemeNameBlue;
34
+ case AppAccentTheme .graphiteGray :
35
+ return l10n.settingsAppearanceThemeNameGrey;
36
36
}
37
37
}
38
38
39
- // Helper to map FontSize enum to user-friendly strings
40
- String _fontSizeToString (FontSize size, AppLocalizations l10n) {
39
+ // Helper to map AppTextScaleFactor enum to user-friendly strings
40
+ String _textScaleFactorToString (
41
+ AppTextScaleFactor size,
42
+ AppLocalizations l10n,
43
+ ) {
41
44
switch (size) {
42
- case FontSize .small:
43
- return l10n.settingsAppearanceFontSizeSmall; // Add l10n key
44
- case FontSize .large:
45
- return l10n.settingsAppearanceFontSizeLarge; // Add l10n key
46
- case FontSize .medium:
47
- return l10n.settingsAppearanceFontSizeMedium; // Add l10n key
45
+ case AppTextScaleFactor .small:
46
+ return l10n.settingsAppearanceFontSizeSmall;
47
+ case AppTextScaleFactor .large:
48
+ return l10n.settingsAppearanceFontSizeLarge;
49
+ case AppTextScaleFactor .medium:
50
+ return l10n.settingsAppearanceFontSizeMedium;
51
+ case AppTextScaleFactor .extraLarge:
52
+ return l10n.settingsAppearanceFontSizeExtraLarge; // Add l10n key
48
53
}
49
54
}
50
55
51
- // Helper to map AppFontType enum to user-friendly strings
52
- // (Using the enum name directly might be sufficient if they are clear)
53
- String _fontTypeToString (AppFontType type, AppLocalizations l10n) {
56
+ // Helper to map font family string to user-friendly strings
57
+ String _fontFamilyToString (String fontFamily, AppLocalizations l10n) {
58
+ // This mapping might need to be more sophisticated if supporting multiple
59
+ // specific fonts. For now, just return the string or a placeholder.
54
60
// Consider adding specific l10n keys if needed, e.g., l10n.fontRoboto
55
- return type.name; // Example: 'roboto', 'openSans'
61
+ return fontFamily == 'SystemDefault'
62
+ ? l10n
63
+ .settingsAppearanceFontFamilySystemDefault // Add l10n key
64
+ : fontFamily;
65
+ }
66
+
67
+ // TODO(cline): Replace with localized strings once localization issue is resolved.
68
+ // Helper to map AppFontWeight enum to user-friendly strings (currently uses enum name)
69
+ String _fontWeightToString (AppFontWeight weight, AppLocalizations l10n) {
70
+ switch (weight) {
71
+ case AppFontWeight .light:
72
+ return 'Light' ; // Temporary: Use enum name or placeholder
73
+ case AppFontWeight .regular:
74
+ return 'Regular' ; // Temporary: Use enum name or placeholder
75
+ case AppFontWeight .bold:
76
+ return 'Bold' ; // Temporary: Use enum name or placeholder
77
+ }
56
78
}
57
79
58
80
@override
@@ -73,19 +95,17 @@ class AppearanceSettingsPage extends StatelessWidget {
73
95
}
74
96
75
97
return Scaffold (
76
- appBar: AppBar (
77
- title: Text (l10n.settingsAppearanceTitle), // Reuse title key
78
- ),
98
+ appBar: AppBar (title: Text (l10n.settingsAppearanceTitle)),
79
99
body: ListView (
80
100
padding: const EdgeInsets .all (AppSpacing .lg),
81
101
children: [
82
- // --- Theme Mode ---
83
- _buildDropdownSetting <AppThemeMode >(
102
+ // --- Base Theme ---
103
+ _buildDropdownSetting <AppBaseTheme >(
84
104
context: context,
85
- title: l10n.settingsAppearanceThemeModeLabel, // Add l10n key
86
- currentValue: state.themeSettings.themeMode ,
87
- items: AppThemeMode .values,
88
- itemToString: (mode) => _themeModeToString (mode, l10n),
105
+ title: l10n.settingsAppearanceThemeModeLabel,
106
+ currentValue: state.userAppSettings.displaySettings.baseTheme ,
107
+ items: AppBaseTheme .values,
108
+ itemToString: (mode) => _baseThemeToString (mode, l10n),
89
109
onChanged: (value) {
90
110
if (value != null ) {
91
111
settingsBloc.add (SettingsAppThemeModeChanged (value));
@@ -94,46 +114,73 @@ class AppearanceSettingsPage extends StatelessWidget {
94
114
),
95
115
const SizedBox (height: AppSpacing .lg),
96
116
97
- // --- Theme Name ---
98
- _buildDropdownSetting <AppThemeName >(
117
+ // --- Accent Theme ---
118
+ _buildDropdownSetting <AppAccentTheme >(
99
119
context: context,
100
- title: l10n.settingsAppearanceThemeNameLabel, // Add l10n key
101
- currentValue: state.themeSettings.themeName ,
102
- items: AppThemeName .values,
103
- itemToString: (name) => _themeNameToString (name, l10n),
120
+ title: l10n.settingsAppearanceThemeNameLabel,
121
+ currentValue: state.userAppSettings.displaySettings.accentTheme ,
122
+ items: AppAccentTheme .values,
123
+ itemToString: (name) => _accentThemeToString (name, l10n),
104
124
onChanged: (value) {
105
125
if (value != null ) {
106
- settingsBloc.add (SettingsAppThemeNameChanged (value));
126
+ context.read <SettingsBloc >().add (
127
+ SettingsAppThemeNameChanged (value),
128
+ );
107
129
}
108
130
},
109
131
),
110
132
const SizedBox (height: AppSpacing .lg),
111
133
112
- // --- App Font Size ---
113
- _buildDropdownSetting <FontSize >(
134
+ // --- Text Scale Factor ---
135
+ _buildDropdownSetting <AppTextScaleFactor >(
114
136
context: context,
115
- title: l10n.settingsAppearanceAppFontSizeLabel, // Add l10n key
116
- currentValue: state.appSettings.appFontSize,
117
- items: FontSize .values,
118
- itemToString: (size) => _fontSizeToString (size, l10n),
137
+ title:
138
+ l10n.settingsAppearanceAppFontSizeLabel, // Reusing key for text size
139
+ currentValue: state.userAppSettings.displaySettings.textScaleFactor,
140
+ items: AppTextScaleFactor .values,
141
+ itemToString: (size) => _textScaleFactorToString (size, l10n),
119
142
onChanged: (value) {
120
143
if (value != null ) {
121
- settingsBloc.add (SettingsAppFontSizeChanged (value));
144
+ context.read <SettingsBloc >().add (
145
+ SettingsAppFontSizeChanged (value),
146
+ );
147
+ }
148
+ },
149
+ ),
150
+ const SizedBox (height: AppSpacing .lg),
151
+
152
+ // --- Font Family ---
153
+ _buildDropdownSetting <String >(
154
+ // Font family is a String
155
+ context: context,
156
+ title:
157
+ l10n.settingsAppearanceAppFontTypeLabel, // Reusing key for font family
158
+ currentValue: state.userAppSettings.displaySettings.fontFamily,
159
+ items: const [
160
+ 'SystemDefault' ,
161
+ ], // Only SystemDefault supported for now
162
+ itemToString: (fontFamily) => _fontFamilyToString (fontFamily, l10n),
163
+ onChanged: (value) {
164
+ if (value != null ) {
165
+ context.read <SettingsBloc >().add (
166
+ SettingsAppFontTypeChanged (value),
167
+ );
122
168
}
123
169
},
124
170
),
125
171
const SizedBox (height: AppSpacing .lg),
126
172
127
- // --- App Font Type ---
128
- _buildDropdownSetting <AppFontType >(
173
+ // --- Font Weight ---
174
+ _buildDropdownSetting <AppFontWeight >(
129
175
context: context,
130
- title: l10n.settingsAppearanceAppFontTypeLabel, // Add l10n key
131
- currentValue: state.appSettings.appFontType,
132
- items: AppFontType .values,
133
- itemToString: (type) => _fontTypeToString (type, l10n),
176
+ title: l10n.settingsAppearanceFontWeightLabel, // Add l10n key
177
+ currentValue: state.userAppSettings.displaySettings.fontWeight,
178
+ items: AppFontWeight .values,
179
+ itemToString:
180
+ (weight) => _fontWeightToString (weight, l10n), // Use helper
134
181
onChanged: (value) {
135
182
if (value != null ) {
136
- settingsBloc.add (SettingsAppFontTypeChanged (value));
183
+ settingsBloc.add (SettingsAppFontWeightChanged (value));
137
184
}
138
185
},
139
186
),
0 commit comments