Skip to content

Commit 6edce6a

Browse files
committed
refactor: themeing and font weight adjustments
- Added font weight to theme - Refactored themeing logic - Added debug prints for theme values
1 parent 185e935 commit 6edce6a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lib/app/view/app.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ class _AppViewState extends State<_AppView> {
184184
previous.appTextScaleFactor != current.appTextScaleFactor ||
185185
previous.locale != current.locale, // Added locale check
186186
builder: (context, state) {
187+
print('[_AppViewState] Building MaterialApp.router');
188+
print('[_AppViewState] state.fontFamily: ${state.fontFamily}');
189+
print('[_AppViewState] state.settings.displaySettings.fontFamily: ${state.settings.displaySettings.fontFamily}');
190+
print('[_AppViewState] state.settings.displaySettings.fontWeight: ${state.settings.displaySettings.fontWeight}');
187191
return MaterialApp.router(
188192
debugShowCheckedModeBanner: false,
189193
themeMode: state.themeMode,

lib/settings/bloc/settings_bloc.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
160160
Emitter<SettingsState> emit,
161161
) async {
162162
if (state.userAppSettings == null) return;
163+
print('[SettingsBloc] _onAppFontTypeChanged: Received event.fontType: ${event.fontType}');
163164

164165
final updatedSettings = state.userAppSettings!.copyWith(
165166
displaySettings: state.userAppSettings!.displaySettings.copyWith(
166167
fontFamily: event.fontType,
167168
),
168169
);
170+
print('[SettingsBloc] _onAppFontTypeChanged: Updated settings.fontFamily: ${updatedSettings.displaySettings.fontFamily}');
169171
emit(state.copyWith(userAppSettings: updatedSettings, clearError: true));
170172
await _persistSettings(updatedSettings, emit);
171173
}
@@ -175,12 +177,14 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
175177
Emitter<SettingsState> emit,
176178
) async {
177179
if (state.userAppSettings == null) return;
180+
print('[SettingsBloc] _onAppFontWeightChanged: Received event.fontWeight: ${event.fontWeight}');
178181

179182
final updatedSettings = state.userAppSettings!.copyWith(
180183
displaySettings: state.userAppSettings!.displaySettings.copyWith(
181184
fontWeight: event.fontWeight,
182185
),
183186
);
187+
print('[SettingsBloc] _onAppFontWeightChanged: Updated settings.fontWeight: ${updatedSettings.displaySettings.fontWeight}');
184188
emit(state.copyWith(userAppSettings: updatedSettings, clearError: true));
185189
await _persistSettings(updatedSettings, emit);
186190
}

lib/shared/theme/app_theme.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ TextTheme _customizeTextTheme(
3636
required AppTextScaleFactor appTextScaleFactor,
3737
required AppFontWeight appFontWeight, // Added parameter
3838
}) {
39+
print('[_customizeTextTheme] Received appFontWeight: $appFontWeight, appTextScaleFactor: $appTextScaleFactor');
3940
// Define font size factors
4041
double factor;
4142
switch (appTextScaleFactor) {
@@ -66,6 +67,7 @@ TextTheme _customizeTextTheme(
6667
selectedFontWeight = FontWeight.w700;
6768
break;
6869
}
70+
print('[_customizeTextTheme] Mapped to selectedFontWeight: $selectedFontWeight');
6971

7072
return baseTextTheme.copyWith(
7173
// --- Headline/Title Styles ---
@@ -118,25 +120,32 @@ TextTheme _customizeTextTheme(
118120
// based on the provided font family name.
119121
// Corrected return type to match GoogleFonts functions (positional optional)
120122
TextTheme Function([TextTheme?]) _getGoogleFontTextTheme(String? fontFamily) {
123+
print('[_getGoogleFontTextTheme] Received fontFamily: $fontFamily');
121124
// Map font family names (as used in AppBloc mapping) to GoogleFonts functions
122125
if (fontFamily == GoogleFonts.roboto().fontFamily) {
126+
print('[_getGoogleFontTextTheme] Returning GoogleFonts.robotoTextTheme');
123127
return GoogleFonts.robotoTextTheme;
124128
}
125129
if (fontFamily == GoogleFonts.openSans().fontFamily) {
130+
print('[_getGoogleFontTextTheme] Returning GoogleFonts.openSansTextTheme');
126131
return GoogleFonts.openSansTextTheme;
127132
}
128133
if (fontFamily == GoogleFonts.lato().fontFamily) {
134+
print('[_getGoogleFontTextTheme] Returning GoogleFonts.latoTextTheme');
129135
return GoogleFonts.latoTextTheme;
130136
}
131137
if (fontFamily == GoogleFonts.montserrat().fontFamily) {
138+
print('[_getGoogleFontTextTheme] Returning GoogleFonts.montserratTextTheme');
132139
return GoogleFonts.montserratTextTheme;
133140
}
134141
if (fontFamily == GoogleFonts.merriweather().fontFamily) {
142+
print('[_getGoogleFontTextTheme] Returning GoogleFonts.merriweatherTextTheme');
135143
return GoogleFonts.merriweatherTextTheme;
136144
}
137145
// Add mappings for other AppFontType values if needed
138146

139147
// Default fallback if fontFamily is null or not recognized
148+
print('[_getGoogleFontTextTheme] Defaulting to GoogleFonts.notoSansTextTheme');
140149
return GoogleFonts.notoSansTextTheme;
141150
}
142151

@@ -149,6 +158,7 @@ ThemeData lightTheme({
149158
required AppFontWeight appFontWeight, // Added parameter
150159
String? fontFamily,
151160
}) {
161+
print('[AppTheme.lightTheme] Received scheme: $scheme, appTextScaleFactor: $appTextScaleFactor, appFontWeight: $appFontWeight, fontFamily: $fontFamily');
152162
final textThemeGetter = _getGoogleFontTextTheme(fontFamily);
153163
final baseTextTheme = textThemeGetter();
154164

@@ -173,6 +183,7 @@ ThemeData darkTheme({
173183
required AppFontWeight appFontWeight, // Added parameter
174184
String? fontFamily,
175185
}) {
186+
print('[AppTheme.darkTheme] Received scheme: $scheme, appTextScaleFactor: $appTextScaleFactor, appFontWeight: $appFontWeight, fontFamily: $fontFamily');
176187
final textThemeGetter = _getGoogleFontTextTheme(fontFamily);
177188
final baseTextTheme = textThemeGetter(
178189
ThemeData(brightness: Brightness.dark).textTheme,

0 commit comments

Comments
 (0)