Skip to content

Commit 89b47cc

Browse files
committed
refactor(theme): use AppTextScaleFactor
- Replaced FontSize with AppTextScaleFactor - Added extraLarge scale factor - Updated text scaling logic
1 parent 6bbc947 commit 89b47cc

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

lib/shared/theme/app_theme.dart

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import 'package:flex_color_scheme/flex_color_scheme.dart';
55
import 'package:flutter/material.dart';
66
import 'package:google_fonts/google_fonts.dart';
7-
import 'package:ht_preferences_client/ht_preferences_client.dart'; // Added for FontSize
7+
import 'package:ht_shared/ht_shared.dart';
88

99
// --- Common Sub-theme Settings ---
1010
// Defines customizations for various components, shared between light/dark themes.
@@ -33,17 +33,19 @@ const FlexSubThemesData _commonSubThemesData = FlexSubThemesData(
3333
// Helper function to apply common text theme customizations
3434
TextTheme _customizeTextTheme(
3535
TextTheme baseTextTheme, {
36-
required FontSize appFontSize, // Added parameter
36+
required AppTextScaleFactor appTextScaleFactor, // Added parameter
3737
}) {
3838
// Define font size factors
3939
double factor;
40-
switch (appFontSize) {
41-
case FontSize.small:
40+
switch (appTextScaleFactor) {
41+
case AppTextScaleFactor.small:
4242
factor = 0.85;
43-
case FontSize.large:
43+
case AppTextScaleFactor.large:
4444
factor = 1.15;
45-
case FontSize.medium:
45+
case AppTextScaleFactor.medium:
4646
factor = 1.0;
47+
case AppTextScaleFactor.extraLarge:
48+
factor = 1.3; // Define factor for extraLarge
4749
}
4850

4951
// Helper to apply factor safely
@@ -118,10 +120,10 @@ TextTheme Function([TextTheme?]) _getGoogleFontTextTheme(String? fontFamily) {
118120

119121
/// Defines the application's light theme using FlexColorScheme.
120122
///
121-
/// Takes the active [scheme], [appFontSize], and optional [fontFamily].
123+
/// Takes the active [scheme], [appTextScaleFactor], and optional [fontFamily].
122124
ThemeData lightTheme({
123125
required FlexScheme scheme,
124-
required FontSize appFontSize, // Added parameter
126+
required AppTextScaleFactor appTextScaleFactor, // Added parameter
125127
String? fontFamily,
126128
}) {
127129
final textThemeGetter = _getGoogleFontTextTheme(fontFamily);
@@ -130,18 +132,21 @@ ThemeData lightTheme({
130132
return FlexThemeData.light(
131133
scheme: scheme,
132134
fontFamily: fontFamily,
133-
// Pass appFontSize to customizeTextTheme
134-
textTheme: _customizeTextTheme(baseTextTheme, appFontSize: appFontSize),
135+
// Pass appTextScaleFactor to customizeTextTheme
136+
textTheme: _customizeTextTheme(
137+
baseTextTheme,
138+
appTextScaleFactor: appTextScaleFactor,
139+
),
135140
subThemesData: _commonSubThemesData,
136141
);
137142
}
138143

139144
/// Defines the application's dark theme using FlexColorScheme.
140145
///
141-
/// Takes the active [scheme], [appFontSize], and optional [fontFamily].
146+
/// Takes the active [scheme], [appTextScaleFactor], and optional [fontFamily].
142147
ThemeData darkTheme({
143148
required FlexScheme scheme,
144-
required FontSize appFontSize, // Added parameter
149+
required AppTextScaleFactor appTextScaleFactor, // Added parameter
145150
String? fontFamily,
146151
}) {
147152
final textThemeGetter = _getGoogleFontTextTheme(fontFamily);
@@ -152,8 +157,11 @@ ThemeData darkTheme({
152157
return FlexThemeData.dark(
153158
scheme: scheme,
154159
fontFamily: fontFamily,
155-
// Pass appFontSize to customizeTextTheme
156-
textTheme: _customizeTextTheme(baseTextTheme, appFontSize: appFontSize),
160+
// Pass appTextScaleFactor to customizeTextTheme
161+
textTheme: _customizeTextTheme(
162+
baseTextTheme,
163+
appTextScaleFactor: appTextScaleFactor,
164+
),
157165
subThemesData: _commonSubThemesData,
158166
);
159167
}

0 commit comments

Comments
 (0)