Use fontFamily for all style in Text widget

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-07-15 09:26:07 +07:00
committed by Dat H. Pham
parent 991ab686a4
commit a9a322818a
186 changed files with 717 additions and 443 deletions
+7 -6
View File
@@ -1,6 +1,7 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/toast/tmail_toast.dart';
import 'package:core/presentation/views/toast/toast_position.dart';
import 'package:flutter/material.dart';
@@ -106,7 +107,7 @@ class AppToast {
},
child: Text(
actionName,
style: TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white
@@ -132,7 +133,7 @@ class AppToast {
actionIcon,
Text(
actionName,
style: TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white
@@ -169,7 +170,7 @@ class AppToast {
context,
maxWidth: maxWidth ?? responsiveUtils.getMaxWidthToast(context),
toastPosition: ToastPosition.BOTTOM,
textStyle: textStyle ?? TextStyle(
textStyle: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textColor ?? AppColor.primaryColor
@@ -222,7 +223,7 @@ class AppToast {
},
child: Text(
action.actionName!,
style: TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white
@@ -250,7 +251,7 @@ class AppToast {
action.actionIcon!,
Text(
action.actionName!,
style: TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white
@@ -287,7 +288,7 @@ class AppToast {
context,
maxWidth: maxWidth ?? responsiveUtils.getMaxWidthToast(context),
toastPosition: ToastPosition.BOTTOM,
textStyle: textStyle ?? TextStyle(
textStyle: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textColor ?? AppColor.primaryColor
@@ -1,14 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:flutter/material.dart';
class CommonTextStyle {
static const textStyleNormal = TextStyle(
color: AppColor.primaryColor,
fontSize: 14,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static const defaultTextOverFlow = TextOverflow.ellipsis;
static const defaultSoftWrap = true;
+11 -3
View File
@@ -307,6 +307,10 @@ class ThemeUtils {
color: AppColor.gray424244.withOpacity(0.9),
);
static const TextStyle defaultTextStyleInterFont = TextStyle(
fontFamily: ConstantsUI.fontApp,
);
static TextSelectionThemeData get _textSelectionTheme {
return const TextSelectionThemeData(
cursorColor: AppColor.primaryColor,
@@ -316,12 +320,16 @@ class ThemeUtils {
}
static AppBarTheme get _appBarTheme {
return const AppBarTheme(
return AppBarTheme(
color: Colors.white,
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle.light,
iconTheme: IconThemeData(color: Colors.black),
titleTextStyle: TextStyle(color: Color(0XFF8B8B8B), fontSize: 18),
iconTheme: const IconThemeData(color: Colors.black),
titleTextStyle: defaultTextStyleInterFont.copyWith(
color: const Color(0XFF8B8B8B),
fontSize: 18,
),
toolbarTextStyle: defaultTextStyleInterFont,
);
}
@@ -1,5 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
class GradientCircleAvatarIcon extends StatelessWidget {
@@ -36,7 +37,7 @@ class GradientCircleAvatarIcon extends StatelessWidget {
color: AppColor.avatarColor
),
child: DefaultTextStyle(
style: textStyle ?? TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.white,
fontSize: labelFontSize,
fontWeight: FontWeight.w600
@@ -1,4 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -26,7 +27,11 @@ abstract class CupertinoActionSheetActionBuilder<T> {
}
TextStyle actionTextStyle({TextStyle? textStyle}) {
return textStyle ?? const TextStyle(fontSize: 17, color: AppColor.colorNameEmail);
return textStyle ??
ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 17,
color: AppColor.colorNameEmail,
);
}
Widget build();
@@ -1,3 +1,4 @@
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
typedef OnCupertinoActionSheetNoIconActionClick<T> = void Function(T data);
@@ -22,7 +23,11 @@ abstract class CupertinoActionSheetNoIconBuilder<T> {
}
TextStyle actionTextStyle({TextStyle? textStyle}) {
return textStyle ?? const TextStyle(fontSize: 17, color: Colors.black);
return textStyle ??
ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 17,
color: Colors.black,
);
}
Widget build();
@@ -1,5 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -103,7 +104,7 @@ Widget buildTextButton(String text, {
child: Text(
text,
textAlign: TextAlign.center,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 17,
color: Colors.white,
fontWeight: FontWeight.w500)),
@@ -145,7 +146,7 @@ Widget buildButtonWrapText(String name, {
child: Text(name,
textAlign: TextAlign.center,
style: textStyle ??
const TextStyle(
ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 17,
fontWeight: FontWeight.w500,
color: Colors.white)),
@@ -2,6 +2,7 @@
import 'package:core/presentation/action/action_callback_define.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/style_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/container/tmail_container_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -211,7 +212,7 @@ class TMailButtonWidget extends StatelessWidget {
Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -251,7 +252,7 @@ class TMailButtonWidget extends StatelessWidget {
child: Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -264,7 +265,7 @@ class TMailButtonWidget extends StatelessWidget {
Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -295,7 +296,7 @@ class TMailButtonWidget extends StatelessWidget {
child: Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -308,7 +309,7 @@ class TMailButtonWidget extends StatelessWidget {
Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -350,7 +351,7 @@ class TMailButtonWidget extends StatelessWidget {
childWidget = Text(
text,
textAlign: textAlign,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 12,
color: AppColor.colorTextButtonHeaderThread
),
@@ -1,4 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -21,7 +22,7 @@ abstract class ContextMenuActionBuilder<T> {
}
TextStyle actionTextStyle() {
return const TextStyle(
return ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
color: AppColor.nameUserColor);
}
@@ -24,7 +24,7 @@ class ContextMenuHeaderBuilder {
transform: Matrix4.translationValues(12, 5, 0.0),
child: Text(
_label ?? '',
style: _textStyle ?? const TextStyle(fontSize: 20.0, color: AppColor.nameUserColor, fontWeight: FontWeight.w500),
style: _textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 20.0, color: AppColor.nameUserColor, fontWeight: FontWeight.w500),
),
));
}
@@ -1,5 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/button/icon_button_web.dart';
import 'package:flex_color_picker/flex_color_picker.dart';
import 'package:flutter/material.dart';
@@ -45,11 +46,11 @@ class ColorPickerDialogBuilder {
title: Text(
title ?? '',
textAlign: TextAlign.center,
style: const TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.black)),
titleTextStyle: const TextStyle(
titleTextStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.black),
@@ -116,7 +117,7 @@ class ColorPickerDialogBuilder {
textActionCancel ?? '',
radius: 5,
height: 30,
textStyle: const TextStyle(
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.normal),
@@ -126,7 +127,7 @@ class ColorPickerDialogBuilder {
textActionResetDefault ?? '',
radius: 5,
height: 30,
textStyle: const TextStyle(
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.normal),
@@ -137,7 +138,7 @@ class ColorPickerDialogBuilder {
textActionSetColor ?? '',
radius: 5,
height: 30,
textStyle: const TextStyle(
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500),
@@ -38,7 +38,7 @@ class DownloadingFileDialogBuilder {
Widget build() {
return CupertinoAlertDialog(
key: _key ?? const Key('DownloadingFileBuilder'),
title: Text(_title, style: const TextStyle(fontSize: 17.0, color: Colors.black)),
title: Text(_title, style: ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 17.0, color: Colors.black)),
content: Padding(
padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
child: Center(
@@ -51,7 +51,7 @@ class DownloadingFileDialogBuilder {
const SizedBox(height: 16),
Text(
_content,
style: const TextStyle(fontSize: 13.0, color: Colors.black),
style: ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 13.0, color: Colors.black),
softWrap: false,
maxLines: 1)
],
@@ -63,7 +63,7 @@ class DownloadingFileDialogBuilder {
padding: const EdgeInsets.only(bottom: kIsWeb ? 16 : 0, top: kIsWeb ? 16 : 0),
child: TextButton(
onPressed: () => _onCancelDownloadActionClick?.call(),
child: Text(_actionText, style: const TextStyle(fontSize: 17.0, color: AppColor.appColor)),
child: Text(_actionText, style: ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 17.0, color: AppColor.appColor)),
))
],
);
@@ -1,4 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/material.dart';
typedef OnTapAvatarActionClick = void Function();
@@ -97,7 +98,7 @@ class AvatarBuilder {
),
child: Text(
_text ?? '',
style: _textStyle ?? TextStyle(fontSize: 20, color: _textColor ?? AppColor.avatarTextColor, fontWeight: FontWeight.w500)
style: _textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 20, color: _textColor ?? AppColor.avatarTextColor, fontWeight: FontWeight.w500)
)
),
);
@@ -2,6 +2,7 @@
import 'dart:async';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/text/text_form_field_builder.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -123,7 +124,7 @@ class EditTextModalSheetBuilder {
children: <Widget>[
Text(
_title,
style: const TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
style: ThemeUtils.defaultTextStyleInterFont.copyWith(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
textAlign: TextAlign.center),
Padding(
padding: const EdgeInsets.only(top: 20),
@@ -143,12 +144,12 @@ class EditTextModalSheetBuilder {
children: [
TextButton(
onPressed: () => _onCancelButtonPress(context),
child: Text(_cancelText.toUpperCase(), style: const TextStyle(color: AppColor.colorTextButton)),
child: Text(_cancelText.toUpperCase(), style: ThemeUtils.defaultTextStyleInterFont.copyWith(color: AppColor.colorTextButton)),
),
TextButton(
onPressed: () => _onConfirmButtonPress(context),
child: Text(_confirmText.toUpperCase(),
style: TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
color: (_error == null || (_error != null && _error!.isEmpty))
? AppColor.colorTextButton
: AppColor.colorDisableMailboxCreateButton)),
@@ -2,6 +2,7 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/style_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:flutter/material.dart';
@@ -54,7 +55,7 @@ class SearchBarView extends StatelessWidget {
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap,
style: const TextStyle(
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 17,
color: AppColor.colorHintSearchBar
)
@@ -1,4 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/semantics/text_field_semantics.dart';
import 'package:core/utils/direction_utils.dart';
import 'package:flutter/material.dart';
@@ -35,7 +36,7 @@ class TextFieldBuilder extends StatefulWidget {
this.obscureText = false,
this.autoFocus = false,
this.readOnly = false,
this.textStyle = const TextStyle(color: AppColor.textFieldTextColor),
this.textStyle,
this.textDirection = TextDirection.ltr,
this.textInputAction,
this.decoration = const InputDecoration(),
@@ -89,7 +90,9 @@ class _TextFieldBuilderState extends State<TextFieldBuilder> {
maxLines: widget.maxLines,
minLines: widget.minLines,
keyboardAppearance: widget.keyboardAppearance,
style: widget.textStyle,
style: widget.textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
color: AppColor.textFieldTextColor,
),
obscureText: widget.obscureText,
keyboardType: widget.keyboardType,
autofocus: widget.autoFocus,
@@ -1,4 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/utils/direction_utils.dart';
import 'package:flutter/material.dart';
@@ -33,7 +34,7 @@ class TextFormFieldBuilder extends StatefulWidget {
this.obscureText = false,
this.autoFocus = false,
this.readOnly = false,
this.textStyle = const TextStyle(color: AppColor.textFieldTextColor),
this.textStyle,
this.textDirection = TextDirection.ltr,
this.textInputAction,
this.decoration,
@@ -85,7 +86,9 @@ class _TextFieldFormBuilderState extends State<TextFormFieldBuilder> {
maxLines: widget.maxLines,
minLines: widget.minLines,
keyboardAppearance: widget.keyboardAppearance,
style: widget.textStyle,
style: widget.textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
color: AppColor.textFieldTextColor,
),
obscureText: widget.obscureText,
keyboardType: widget.keyboardType,
autofocus: widget.autoFocus,
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/toast/toast_position.dart';
import 'package:flutter/material.dart';
@@ -11,11 +12,7 @@ class TMailToast {
Duration? toastDuration,
ToastPosition? toastPosition,
Color? backgroundColor,
TextStyle textStyle = const TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
),
TextStyle? textStyle,
double toastBorderRadius = 10.0,
Border? border,
Widget? trailing,
@@ -93,7 +90,7 @@ class ToastView {
? Text(
text,
softWrap: true,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
@@ -109,7 +106,7 @@ class ToastView {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
text,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
@@ -126,7 +123,7 @@ class ToastView {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
text,
style: textStyle ?? const TextStyle(
style: textStyle ?? ThemeUtils.defaultTextStyleInterFont.copyWith(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
@@ -1,14 +1,15 @@
import 'package:core/presentation/extensions/list_extensions.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/text/rich_text_builder.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
const normalTextStyle = TextStyle(
final normalTextStyle = ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.black,
fontSize: 16,
);
const highlightTextStyle = TextStyle(
final highlightTextStyle = ThemeUtils.defaultTextStyleInterFont.copyWith(
color: Colors.red,
fontSize: 16,
);