Skip to content

Commit 2437100

Browse files
committed
feature: Implemented the font size adjustment for the setting feature, and resolved localization errors by adding missing keys to lib/l10n/arb/app_en.arb and lib/l10n/arb/app_ar.arb and running flutter gen-l10n.
1 parent 1059164 commit 2437100

File tree

6 files changed

+193
-38
lines changed

6 files changed

+193
-38
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import 'package:bloc/bloc.dart';
66
import 'package:equatable/equatable.dart';
77
import 'package:flex_color_scheme/flex_color_scheme.dart'; // Added
88
import 'package:flutter/material.dart';
9-
import 'package:google_fonts/google_fonts.dart'; // Added for font mapping
9+
import 'package:google_fonts/google_fonts.dart';
1010
import 'package:ht_authentication_client/ht_authentication_client.dart';
1111
import 'package:ht_authentication_repository/ht_authentication_repository.dart';
12-
import 'package:ht_preferences_client/ht_preferences_client.dart'; // Added
13-
import 'package:ht_preferences_repository/ht_preferences_repository.dart'; // Added
12+
// Ensure full import for FontSize enum access
13+
import 'package:ht_preferences_client/ht_preferences_client.dart';
14+
import 'package:ht_preferences_repository/ht_preferences_repository.dart';
1415

1516
part 'app_event.dart';
1617
part 'app_state.dart';
@@ -91,13 +92,16 @@ class AppBloc extends Bloc<AppEvent, AppState> {
9192
themeSettings?.themeName ?? AppThemeName.grey, // Default
9293
);
9394
final newFontFamily = _mapAppFontType(
94-
appSettings?.appFontType, // Nullable, default handled in theme
95+
appSettings?.appFontType,
9596
);
97+
// Extract App Font Size
98+
final newAppFontSize = appSettings?.appFontSize ?? FontSize.medium; // Default
9699

97100
emit(
98101
state.copyWith(
99102
themeMode: newThemeMode,
100103
flexScheme: newFlexScheme,
104+
appFontSize: newAppFontSize, // Pass font size
101105
fontFamily: newFontFamily,
102106
// Use clearFontFamily flag if appSettings was null and we want to reset
103107
clearFontFamily: appSettings == null,

lib/app/bloc/app_state.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ class AppState extends Equatable {
2020
AppState({
2121
this.selectedBottomNavigationIndex = 0,
2222
this.themeMode = ThemeMode.system,
23-
this.flexScheme = FlexScheme.material, // Default scheme
24-
this.fontFamily, // Default font family (null means use FlexColorScheme default)
25-
this.status = AppStatus.initial, // Default to initial
23+
this.appFontSize = FontSize.medium, // Default font size
24+
this.flexScheme = FlexScheme.material,
25+
this.fontFamily,
26+
this.status = AppStatus.initial,
2627
User? user,
27-
}) : user = user ?? User(); // Use default constructor
28+
}) : user = user ?? User();
2829

2930
/// The index of the currently selected item in the bottom navigation bar.
3031
final int selectedBottomNavigationIndex;
3132

3233
/// The overall theme mode (light, dark, system).
3334
final ThemeMode themeMode;
3435

36+
/// The font size for the app's UI.
37+
final FontSize appFontSize;
38+
3539
/// The active color scheme defined by FlexColorScheme.
3640
final FlexScheme flexScheme;
3741

@@ -51,16 +55,18 @@ class AppState extends Equatable {
5155
ThemeMode? themeMode,
5256
FlexScheme? flexScheme,
5357
String? fontFamily,
58+
FontSize? appFontSize, // Added
5459
AppStatus? status,
5560
User? user,
56-
bool clearFontFamily = false, // Flag to explicitly clear font family
61+
bool clearFontFamily = false,
5762
}) {
5863
return AppState(
5964
selectedBottomNavigationIndex:
6065
selectedBottomNavigationIndex ?? this.selectedBottomNavigationIndex,
6166
themeMode: themeMode ?? this.themeMode,
6267
flexScheme: flexScheme ?? this.flexScheme,
6368
fontFamily: clearFontFamily ? null : fontFamily ?? this.fontFamily,
69+
appFontSize: appFontSize ?? this.appFontSize, // Added
6470
status: status ?? this.status,
6571
user: user ?? this.user,
6672
);
@@ -72,6 +78,7 @@ class AppState extends Equatable {
7278
themeMode,
7379
flexScheme,
7480
fontFamily,
81+
appFontSize, // Added
7582
status,
7683
user,
7784
];

lib/app/view/app.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,12 @@ class _AppViewState extends State<_AppView> {
227227
_statusNotifier.value = state.status;
228228
},
229229
child: BlocBuilder<AppBloc, AppState>(
230-
// Build when theme-related properties change
230+
// Build when theme-related properties change (including font size)
231231
buildWhen: (previous, current) =>
232232
previous.themeMode != current.themeMode ||
233233
previous.flexScheme != current.flexScheme ||
234-
previous.fontFamily != current.fontFamily,
234+
previous.fontFamily != current.fontFamily ||
235+
previous.appFontSize != current.appFontSize, // Added condition
235236
builder: (context, state) {
236237
return MaterialApp.router(
237238
debugShowCheckedModeBanner: false,
@@ -240,10 +241,12 @@ class _AppViewState extends State<_AppView> {
240241
theme: lightTheme(
241242
scheme: state.flexScheme,
242243
fontFamily: state.fontFamily,
244+
appFontSize: state.appFontSize, // Pass font size
243245
),
244246
darkTheme: darkTheme(
245247
scheme: state.flexScheme,
246248
fontFamily: state.fontFamily,
249+
appFontSize: state.appFontSize, // Pass font size
247250
),
248251
routerConfig: _router,
249252
localizationsDelegates: AppLocalizations.localizationsDelegates,

lib/l10n/arb/app_ar.arb

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,5 +357,65 @@
357357
"accountSignInPromptButton": "تسجيل / تسجيل الدخول",
358358
"@accountSignInPromptButton": {
359359
"description": "Button text shown in the user header for anonymous users to initiate sign-in/sign-up"
360-
}
360+
},
361+
"settingsTitle": "الإعدادات",
362+
"@settingsTitle": { "description": "Title for the main settings page" },
363+
"settingsLoadingHeadline": "جارٍ تحميل الإعدادات...",
364+
"@settingsLoadingHeadline": { "description": "Headline shown while settings are loading" },
365+
"settingsLoadingSubheadline": "يرجى الانتظار بينما نقوم بجلب تفضيلاتك.",
366+
"@settingsLoadingSubheadline": { "description": "Subheadline shown while settings are loading" },
367+
"settingsErrorDefault": "تعذر تحميل الإعدادات.",
368+
"@settingsErrorDefault": { "description": "Default error message when settings fail to load" },
369+
"settingsAppearanceTitle": "المظهر",
370+
"@settingsAppearanceTitle": { "description": "Title for the appearance settings section/page" },
371+
"settingsFeedDisplayTitle": "عرض الموجز",
372+
"@settingsFeedDisplayTitle": { "description": "Title for the feed display settings section/page" },
373+
"settingsArticleDisplayTitle": "عرض المقال",
374+
"@settingsArticleDisplayTitle": { "description": "Title for the article display settings section/page" },
375+
"settingsNotificationsTitle": "الإشعارات",
376+
"@settingsNotificationsTitle": { "description": "Title for the notification settings section/page" },
377+
"settingsAppearanceThemeModeLight": "فاتح",
378+
"@settingsAppearanceThemeModeLight": { "description": "Label for the light theme mode option" },
379+
"settingsAppearanceThemeModeDark": "داكن",
380+
"@settingsAppearanceThemeModeDark": { "description": "Label for the dark theme mode option" },
381+
"settingsAppearanceThemeModeSystem": "النظام",
382+
"@settingsAppearanceThemeModeSystem": { "description": "Label for the system theme mode option" },
383+
"settingsAppearanceThemeNameRed": "أحمر",
384+
"@settingsAppearanceThemeNameRed": { "description": "Label for the red color scheme option" },
385+
"settingsAppearanceThemeNameBlue": "أزرق",
386+
"@settingsAppearanceThemeNameBlue": { "description": "Label for the blue color scheme option" },
387+
"settingsAppearanceThemeNameGrey": "رمادي",
388+
"@settingsAppearanceThemeNameGrey": { "description": "Label for the grey color scheme option" },
389+
"settingsAppearanceFontSizeSmall": "صغير",
390+
"@settingsAppearanceFontSizeSmall": { "description": "Label for the small font size option" },
391+
"settingsAppearanceFontSizeLarge": "كبير",
392+
"@settingsAppearanceFontSizeLarge": { "description": "Label for the large font size option" },
393+
"settingsAppearanceFontSizeMedium": "متوسط",
394+
"@settingsAppearanceFontSizeMedium": { "description": "Label for the medium font size option" },
395+
"settingsAppearanceThemeModeLabel": "وضع المظهر",
396+
"@settingsAppearanceThemeModeLabel": { "description": "Label for the theme mode selection dropdown" },
397+
"settingsAppearanceThemeNameLabel": "نظام الألوان",
398+
"@settingsAppearanceThemeNameLabel": { "description": "Label for the color scheme selection dropdown" },
399+
"settingsAppearanceAppFontSizeLabel": "حجم خط التطبيق",
400+
"@settingsAppearanceAppFontSizeLabel": { "description": "Label for the app font size selection dropdown" },
401+
"settingsAppearanceAppFontTypeLabel": "خط التطبيق",
402+
"@settingsAppearanceAppFontTypeLabel": { "description": "Label for the app font selection dropdown" },
403+
"settingsFeedTileTypeImageTop": "صورة في الأعلى",
404+
"@settingsFeedTileTypeImageTop": { "description": "Label for the feed tile type with image on top" },
405+
"settingsFeedTileTypeImageStart": "صورة في البداية",
406+
"@settingsFeedTileTypeImageStart": { "description": "Label for the feed tile type with image at the start" },
407+
"settingsFeedTileTypeTextOnly": "نص فقط",
408+
"@settingsFeedTileTypeTextOnly": { "description": "Label for the feed tile type with text only" },
409+
"settingsFeedTileTypeLabel": "تخطيط عنصر الموجز",
410+
"@settingsFeedTileTypeLabel": { "description": "Label for the feed tile layout selection dropdown" },
411+
"settingsArticleFontSizeLabel": "حجم خط المقال",
412+
"@settingsArticleFontSizeLabel": { "description": "Label for the article font size selection dropdown" },
413+
"settingsNotificationsEnableLabel": "تفعيل الإشعارات",
414+
"@settingsNotificationsEnableLabel": { "description": "Label for the switch to enable/disable notifications" },
415+
"settingsNotificationsCategoriesLabel": "الفئات المتابعة",
416+
"@settingsNotificationsCategoriesLabel": { "description": "Label for the section to select notification categories" },
417+
"settingsNotificationsSourcesLabel": "المصادر المتابعة",
418+
"@settingsNotificationsSourcesLabel": { "description": "Label for the section to select notification sources" },
419+
"settingsNotificationsCountriesLabel": "البلدان المتابعة",
420+
"@settingsNotificationsCountriesLabel": { "description": "Label for the section to select notification countries" }
361421
}

lib/l10n/arb/app_en.arb

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,5 +357,65 @@
357357
"sourceFilterEmptySubheadline": "There are no sources available at the moment.",
358358
"@sourceFilterEmptySubheadline": {
359359
"description": "Subheadline for empty state on source filter page"
360-
}
360+
},
361+
"settingsTitle": "Settings",
362+
"@settingsTitle": { "description": "Title for the main settings page" },
363+
"settingsLoadingHeadline": "Loading Settings...",
364+
"@settingsLoadingHeadline": { "description": "Headline shown while settings are loading" },
365+
"settingsLoadingSubheadline": "Please wait while we fetch your preferences.",
366+
"@settingsLoadingSubheadline": { "description": "Subheadline shown while settings are loading" },
367+
"settingsErrorDefault": "Could not load settings.",
368+
"@settingsErrorDefault": { "description": "Default error message when settings fail to load" },
369+
"settingsAppearanceTitle": "Appearance",
370+
"@settingsAppearanceTitle": { "description": "Title for the appearance settings section/page" },
371+
"settingsFeedDisplayTitle": "Feed Display",
372+
"@settingsFeedDisplayTitle": { "description": "Title for the feed display settings section/page" },
373+
"settingsArticleDisplayTitle": "Article Display",
374+
"@settingsArticleDisplayTitle": { "description": "Title for the article display settings section/page" },
375+
"settingsNotificationsTitle": "Notifications",
376+
"@settingsNotificationsTitle": { "description": "Title for the notification settings section/page" },
377+
"settingsAppearanceThemeModeLight": "Light",
378+
"@settingsAppearanceThemeModeLight": { "description": "Label for the light theme mode option" },
379+
"settingsAppearanceThemeModeDark": "Dark",
380+
"@settingsAppearanceThemeModeDark": { "description": "Label for the dark theme mode option" },
381+
"settingsAppearanceThemeModeSystem": "System",
382+
"@settingsAppearanceThemeModeSystem": { "description": "Label for the system theme mode option" },
383+
"settingsAppearanceThemeNameRed": "Red",
384+
"@settingsAppearanceThemeNameRed": { "description": "Label for the red color scheme option" },
385+
"settingsAppearanceThemeNameBlue": "Blue",
386+
"@settingsAppearanceThemeNameBlue": { "description": "Label for the blue color scheme option" },
387+
"settingsAppearanceThemeNameGrey": "Grey",
388+
"@settingsAppearanceThemeNameGrey": { "description": "Label for the grey color scheme option" },
389+
"settingsAppearanceFontSizeSmall": "Small",
390+
"@settingsAppearanceFontSizeSmall": { "description": "Label for the small font size option" },
391+
"settingsAppearanceFontSizeLarge": "Large",
392+
"@settingsAppearanceFontSizeLarge": { "description": "Label for the large font size option" },
393+
"settingsAppearanceFontSizeMedium": "Medium",
394+
"@settingsAppearanceFontSizeMedium": { "description": "Label for the medium font size option" },
395+
"settingsAppearanceThemeModeLabel": "Theme Mode",
396+
"@settingsAppearanceThemeModeLabel": { "description": "Label for the theme mode selection dropdown" },
397+
"settingsAppearanceThemeNameLabel": "Color Scheme",
398+
"@settingsAppearanceThemeNameLabel": { "description": "Label for the color scheme selection dropdown" },
399+
"settingsAppearanceAppFontSizeLabel": "App Font Size",
400+
"@settingsAppearanceAppFontSizeLabel": { "description": "Label for the app font size selection dropdown" },
401+
"settingsAppearanceAppFontTypeLabel": "App Font",
402+
"@settingsAppearanceAppFontTypeLabel": { "description": "Label for the app font selection dropdown" },
403+
"settingsFeedTileTypeImageTop": "Image Top",
404+
"@settingsFeedTileTypeImageTop": { "description": "Label for the feed tile type with image on top" },
405+
"settingsFeedTileTypeImageStart": "Image Start",
406+
"@settingsFeedTileTypeImageStart": { "description": "Label for the feed tile type with image at the start" },
407+
"settingsFeedTileTypeTextOnly": "Text Only",
408+
"@settingsFeedTileTypeTextOnly": { "description": "Label for the feed tile type with text only" },
409+
"settingsFeedTileTypeLabel": "Feed Tile Layout",
410+
"@settingsFeedTileTypeLabel": { "description": "Label for the feed tile layout selection dropdown" },
411+
"settingsArticleFontSizeLabel": "Article Font Size",
412+
"@settingsArticleFontSizeLabel": { "description": "Label for the article font size selection dropdown" },
413+
"settingsNotificationsEnableLabel": "Enable Notifications",
414+
"@settingsNotificationsEnableLabel": { "description": "Label for the switch to enable/disable notifications" },
415+
"settingsNotificationsCategoriesLabel": "Followed Categories",
416+
"@settingsNotificationsCategoriesLabel": { "description": "Label for the section to select notification categories" },
417+
"settingsNotificationsSourcesLabel": "Followed Sources",
418+
"@settingsNotificationsSourcesLabel": { "description": "Label for the section to select notification sources" },
419+
"settingsNotificationsCountriesLabel": "Followed Countries",
420+
"@settingsNotificationsCountriesLabel": { "description": "Label for the section to select notification countries" }
361421
}

0 commit comments

Comments
 (0)