TF-3410 Use TextTheme apply almost text style for text widget
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -111,7 +111,6 @@ extension AppColor on Color {
|
||||
static const colorBorderIdentityInfo = Color(0xFFE7E8EC);
|
||||
static const colorBgMailboxSelected = Color(0x99E4E8EC);
|
||||
static const colorLoading = Color(0x2999A2AD);
|
||||
static const colorActionButtonHover = Color(0xFFA2AAB3);
|
||||
static const colorBgMenuItemDropDownSelected = Color(0x80DEE2E7);
|
||||
static const colorButtonCancelDialog = Color(0x0D000000);
|
||||
static const colorShadowComposerButton = Color(0x99007AFF);
|
||||
@@ -245,7 +244,7 @@ extension AppColor on Color {
|
||||
static const blue400 = Color(0xFF80BDFF);
|
||||
static const m3Tertiary = Color(0xFF8C9CAF);
|
||||
static const m3Neutral70 = Color(0xFFAEAAAE);
|
||||
static const colorF3F6F9 = Color(0xFFF3F6F9);
|
||||
static const grayBackgroundColor = Color(0xFFF3F6F9);
|
||||
static const m3SurfaceBackground = Color(0xFF1C1B1F);
|
||||
|
||||
static const mapGradientColor = [
|
||||
|
||||
@@ -38,4 +38,6 @@ extension StringExtension on String {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String get firstCharacterToUpperCase => isNotEmpty ? this[0].toUpperCase() : '';
|
||||
}
|
||||
@@ -141,7 +141,6 @@ class ImagePaths {
|
||||
String get icSwitchOff => _getImagePath('ic_switch_off.svg');
|
||||
String get icClock => _getImagePath('ic_clock.svg');
|
||||
String get icCalendar => _getImagePath('ic_calendar.svg');
|
||||
String get icAddEmailForward => _getImagePath('ic_add_email_forwards.svg');
|
||||
String get icChevronDownOutline => _getImagePath('ic_chevron_down_outline.svg');
|
||||
String get icUndo => _getImagePath('ic_undo.svg');
|
||||
String get icDownloadAttachment => _getImagePath('ic_download_attachment.svg');
|
||||
@@ -227,6 +226,7 @@ class ImagePaths {
|
||||
String get icSubaddressingAllow => _getImagePath('ic_subaddressing_allow.svg');
|
||||
String get icSubaddressingDisallow => _getImagePath('ic_subaddressing_disallow.svg');
|
||||
String get icMarkAsImportant => _getImagePath('ic_mark_as_important.svg');
|
||||
String get icCloseDialog => _getImagePath('ic_close_dialog.svg');
|
||||
|
||||
String _getImagePath(String imageName) {
|
||||
return AssetsPaths.images + imageName;
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ThemeUtils {
|
||||
ThemeUtils._();
|
||||
|
||||
static ThemeData get appTheme {
|
||||
return ThemeData(
|
||||
@@ -23,11 +24,119 @@ class ThemeUtils {
|
||||
|
||||
static TextTheme get _textTheme {
|
||||
return const TextTheme(
|
||||
bodyMedium: TextStyle(color: AppColor.baseTextColor),
|
||||
bodySmall: TextStyle(color: AppColor.baseTextColor),
|
||||
bodyLarge: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: -0.15,
|
||||
fontSize: 17,
|
||||
height: 24 / 17,
|
||||
),
|
||||
bodyMedium: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.25,
|
||||
),
|
||||
bodySmall: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w400,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 13,
|
||||
height: 16 / 13
|
||||
),
|
||||
labelLarge: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.1,
|
||||
),
|
||||
labelSmall: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
displayLarge: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
displayMedium: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.4,
|
||||
),
|
||||
displaySmall: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.4,
|
||||
),
|
||||
headlineMedium: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
headlineSmall: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.4,
|
||||
),
|
||||
headlineLarge: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 32,
|
||||
),
|
||||
titleLarge: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 22,
|
||||
height: 28 / 22,
|
||||
),
|
||||
titleMedium: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.15,
|
||||
),
|
||||
titleSmall: TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static TextStyle textStyleBodyBody1({Color? color, FontWeight? fontWeight}) => TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: fontWeight ?? FontWeight.w500,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 16,
|
||||
height: 20 / 16,
|
||||
color: color,
|
||||
);
|
||||
|
||||
static TextStyle textStyleBodyBody2({Color? color, FontWeight? fontWeight}) => TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: fontWeight ?? FontWeight.w400,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 15,
|
||||
height: 20 / 15,
|
||||
color: color,
|
||||
);
|
||||
|
||||
static TextStyle textStyleBodyBody3({Color? color, FontWeight? fontWeight}) => TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: fontWeight ?? FontWeight.w400,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 14,
|
||||
height: 18 / 14,
|
||||
color: color,
|
||||
);
|
||||
|
||||
static TextStyle textStyleHeadingH6({Color? color, FontWeight? fontWeight}) => TextStyle(
|
||||
fontFamily: ConstantsUI.fontApp,
|
||||
fontWeight: fontWeight ?? FontWeight.w700,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 20,
|
||||
height: 24 / 20,
|
||||
color: color,
|
||||
);
|
||||
|
||||
static TextSelectionThemeData get _textSelectionTheme {
|
||||
return const TextSelectionThemeData(
|
||||
cursorColor: AppColor.primaryColor,
|
||||
|
||||
+13
-4
@@ -66,7 +66,10 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
child: Text(
|
||||
_messageText ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog)),
|
||||
style: _styleMessage ?? Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: AppColor.steelGrayA540,
|
||||
),
|
||||
),
|
||||
onPressed: () => {},
|
||||
),
|
||||
)
|
||||
@@ -79,7 +82,9 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
cursor: PlatformInfo.isWeb ? WidgetStateMouseCursor.clickable : MouseCursor.defer,
|
||||
child: CupertinoActionSheetAction(
|
||||
child: RichText(text: TextSpan(
|
||||
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog),
|
||||
style: _styleMessage ?? Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: AppColor.steelGrayA540,
|
||||
),
|
||||
children: listTextSpan
|
||||
)),
|
||||
onPressed: () => {},
|
||||
@@ -93,7 +98,9 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
child: CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
_confirmText ?? '',
|
||||
style: _styleConfirmButton ?? const TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionDeleteConfirmDialog)),
|
||||
style: _styleConfirmButton ?? Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: AppColor.steelGray600,
|
||||
)),
|
||||
onPressed: () => _onConfirmActionClick?.call(),
|
||||
),
|
||||
)
|
||||
@@ -104,7 +111,9 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
child: CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
_cancelText ?? '',
|
||||
style: _styleCancelButton ?? const TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionCancelDialog)),
|
||||
style: _styleCancelButton ?? Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
)),
|
||||
onPressed: () => _onCancelActionClick?.call(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,17 +8,19 @@ class ConfirmDialogButton extends StatelessWidget {
|
||||
final Color backgroundColor;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final int? maxLines;
|
||||
final TextStyle textStyle;
|
||||
final TextStyle? textStyle;
|
||||
final Color? textColor;
|
||||
final VoidCallback? onTapAction;
|
||||
|
||||
const ConfirmDialogButton({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.textStyle,
|
||||
required this.backgroundColor,
|
||||
this.textStyle,
|
||||
this.borderRadius,
|
||||
this.padding,
|
||||
this.maxLines,
|
||||
this.textColor,
|
||||
this.onTapAction
|
||||
});
|
||||
|
||||
@@ -45,7 +47,9 @@ class ConfirmDialogButton extends StatelessWidget {
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: textStyle
|
||||
style: textStyle ?? Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: textColor,
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@@ -8,354 +9,436 @@ typedef OnConfirmButtonAction = void Function();
|
||||
typedef OnCancelButtonAction = void Function();
|
||||
typedef OnCloseButtonAction = void Function();
|
||||
|
||||
class ConfirmDialogBuilder {
|
||||
final ImagePaths _imagePath;
|
||||
|
||||
Key? _key;
|
||||
String _title = '';
|
||||
String _textContent = '';
|
||||
String _confirmText = '';
|
||||
String _cancelText = '';
|
||||
Widget? _iconWidget;
|
||||
Widget? _additionalWidgetContent;
|
||||
Color? _colorCancelButton;
|
||||
Color? _colorConfirmButton;
|
||||
TextStyle? _styleTextCancelButton;
|
||||
TextStyle? _styleTextConfirmButton;
|
||||
TextStyle? _styleTitle;
|
||||
TextStyle? _styleContent;
|
||||
double? _radiusButton;
|
||||
EdgeInsetsGeometry? _paddingTitle;
|
||||
EdgeInsets? _paddingContent;
|
||||
EdgeInsetsGeometry? _paddingButton;
|
||||
EdgeInsets? _marginButton;
|
||||
EdgeInsets? _outsideDialogPadding;
|
||||
EdgeInsetsGeometry? _marginIcon;
|
||||
EdgeInsets? _margin;
|
||||
double? _widthDialog;
|
||||
final double maxWith;
|
||||
Alignment? _alignment;
|
||||
Color? _backgroundColor;
|
||||
class ConfirmationDialogBuilder extends StatelessWidget {
|
||||
final ImagePaths imagePath;
|
||||
final String title;
|
||||
final String textContent;
|
||||
final String confirmText;
|
||||
final String cancelText;
|
||||
final Widget? iconWidget;
|
||||
final Widget? additionalWidgetContent;
|
||||
final Color? colorCancelButton;
|
||||
final Color? colorConfirmButton;
|
||||
final TextStyle? styleTextCancelButton;
|
||||
final TextStyle? styleTextConfirmButton;
|
||||
final TextStyle? styleTitle;
|
||||
final TextStyle? styleContent;
|
||||
final double? radiusButton;
|
||||
final EdgeInsetsGeometry? paddingTitle;
|
||||
final EdgeInsetsGeometry? paddingContent;
|
||||
final EdgeInsetsGeometry? paddingButton;
|
||||
final EdgeInsetsGeometry? marginButton;
|
||||
final EdgeInsets? outsideDialogPadding;
|
||||
final EdgeInsetsGeometry? marginIcon;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final double? widthDialog;
|
||||
final double maxWidth;
|
||||
final Alignment? alignment;
|
||||
final Color? backgroundColor;
|
||||
final bool showAsBottomSheet;
|
||||
final List<TextSpan>? listTextSpan;
|
||||
final int? titleActionButtonMaxLines;
|
||||
final bool isArrangeActionButtonsVertical;
|
||||
final bool useIconAsBasicLogo;
|
||||
final OnConfirmButtonAction? onConfirmButtonAction;
|
||||
final OnCancelButtonAction? onCancelButtonAction;
|
||||
final OnCloseButtonAction? onCloseButtonAction;
|
||||
|
||||
OnConfirmButtonAction? _onConfirmButtonAction;
|
||||
OnCancelButtonAction? _onCancelButtonAction;
|
||||
OnCloseButtonAction? _onCloseButtonAction;
|
||||
const ConfirmationDialogBuilder({
|
||||
super.key,
|
||||
required this.imagePath,
|
||||
this.title = '',
|
||||
this.textContent = '',
|
||||
this.confirmText = '',
|
||||
this.cancelText = '',
|
||||
this.iconWidget,
|
||||
this.additionalWidgetContent,
|
||||
this.colorCancelButton,
|
||||
this.colorConfirmButton,
|
||||
this.styleTextCancelButton,
|
||||
this.styleTextConfirmButton,
|
||||
this.styleTitle,
|
||||
this.styleContent,
|
||||
this.radiusButton,
|
||||
this.paddingTitle,
|
||||
this.paddingContent,
|
||||
this.paddingButton,
|
||||
this.marginButton,
|
||||
this.outsideDialogPadding,
|
||||
this.marginIcon,
|
||||
this.margin,
|
||||
this.widthDialog,
|
||||
this.maxWidth = double.infinity,
|
||||
this.alignment,
|
||||
this.backgroundColor,
|
||||
this.showAsBottomSheet = false,
|
||||
this.listTextSpan,
|
||||
this.titleActionButtonMaxLines,
|
||||
this.isArrangeActionButtonsVertical = false,
|
||||
this.useIconAsBasicLogo = false,
|
||||
this.onConfirmButtonAction,
|
||||
this.onCancelButtonAction,
|
||||
this.onCloseButtonAction,
|
||||
});
|
||||
|
||||
ConfirmDialogBuilder(
|
||||
this._imagePath,
|
||||
{
|
||||
this.showAsBottomSheet = false,
|
||||
this.listTextSpan,
|
||||
this.maxWith = double.infinity,
|
||||
this.titleActionButtonMaxLines,
|
||||
this.isArrangeActionButtonsVertical = false,
|
||||
this.useIconAsBasicLogo = false,
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return showAsBottomSheet
|
||||
? _BodyContent(
|
||||
imagePath: imagePath,
|
||||
title: title,
|
||||
textContent: textContent,
|
||||
confirmText: confirmText,
|
||||
cancelText: cancelText,
|
||||
iconWidget: iconWidget,
|
||||
additionalWidgetContent: additionalWidgetContent,
|
||||
colorCancelButton: colorCancelButton,
|
||||
colorConfirmButton: colorConfirmButton,
|
||||
styleTextCancelButton: styleTextCancelButton,
|
||||
styleTextConfirmButton: styleTextConfirmButton,
|
||||
styleTitle: styleTitle,
|
||||
styleContent: styleContent,
|
||||
radiusButton: radiusButton,
|
||||
paddingTitle: paddingTitle,
|
||||
paddingContent: paddingContent,
|
||||
paddingButton: paddingButton,
|
||||
marginButton: marginButton,
|
||||
marginIcon: marginIcon,
|
||||
margin: margin,
|
||||
widthDialog: widthDialog,
|
||||
maxWidth: maxWidth,
|
||||
listTextSpan: listTextSpan,
|
||||
titleActionButtonMaxLines: titleActionButtonMaxLines,
|
||||
isArrangeActionButtonsVertical: isArrangeActionButtonsVertical,
|
||||
useIconAsBasicLogo: useIconAsBasicLogo,
|
||||
onConfirmButtonAction: onConfirmButtonAction,
|
||||
onCancelButtonAction: onCancelButtonAction,
|
||||
onCloseButtonAction: onCloseButtonAction,
|
||||
)
|
||||
: Dialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(18))),
|
||||
insetPadding: outsideDialogPadding,
|
||||
alignment: alignment ?? Alignment.center,
|
||||
backgroundColor: backgroundColor,
|
||||
child: _BodyContent(
|
||||
imagePath: imagePath,
|
||||
title: title,
|
||||
textContent: textContent,
|
||||
confirmText: confirmText,
|
||||
cancelText: cancelText,
|
||||
iconWidget: iconWidget,
|
||||
additionalWidgetContent: additionalWidgetContent,
|
||||
colorCancelButton: colorCancelButton,
|
||||
colorConfirmButton: colorConfirmButton,
|
||||
styleTextCancelButton: styleTextCancelButton,
|
||||
styleTextConfirmButton: styleTextConfirmButton,
|
||||
styleTitle: styleTitle,
|
||||
styleContent: styleContent,
|
||||
radiusButton: radiusButton,
|
||||
paddingTitle: paddingTitle,
|
||||
paddingContent: paddingContent,
|
||||
paddingButton: paddingButton,
|
||||
marginButton: marginButton,
|
||||
marginIcon: marginIcon,
|
||||
margin: margin,
|
||||
widthDialog: widthDialog,
|
||||
maxWidth: maxWidth,
|
||||
listTextSpan: listTextSpan,
|
||||
titleActionButtonMaxLines: titleActionButtonMaxLines,
|
||||
isArrangeActionButtonsVertical: isArrangeActionButtonsVertical,
|
||||
useIconAsBasicLogo: useIconAsBasicLogo,
|
||||
onConfirmButtonAction: onConfirmButtonAction,
|
||||
onCancelButtonAction: onCancelButtonAction,
|
||||
onCloseButtonAction: onCloseButtonAction,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BodyContent extends StatelessWidget {
|
||||
final ImagePaths imagePath;
|
||||
final String title;
|
||||
final String textContent;
|
||||
final String confirmText;
|
||||
final String cancelText;
|
||||
final Widget? iconWidget;
|
||||
final Widget? additionalWidgetContent;
|
||||
final Color? colorCancelButton;
|
||||
final Color? colorConfirmButton;
|
||||
final TextStyle? styleTextCancelButton;
|
||||
final TextStyle? styleTextConfirmButton;
|
||||
final TextStyle? styleTitle;
|
||||
final TextStyle? styleContent;
|
||||
final double? radiusButton;
|
||||
final EdgeInsetsGeometry? paddingTitle;
|
||||
final EdgeInsetsGeometry? paddingContent;
|
||||
final EdgeInsetsGeometry? paddingButton;
|
||||
final EdgeInsetsGeometry? marginButton;
|
||||
final EdgeInsetsGeometry? marginIcon;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final double? widthDialog;
|
||||
final double maxWidth;
|
||||
final List<TextSpan>? listTextSpan;
|
||||
final int? titleActionButtonMaxLines;
|
||||
final bool isArrangeActionButtonsVertical;
|
||||
final bool useIconAsBasicLogo;
|
||||
final OnConfirmButtonAction? onConfirmButtonAction;
|
||||
final OnCancelButtonAction? onCancelButtonAction;
|
||||
final OnCloseButtonAction? onCloseButtonAction;
|
||||
|
||||
const _BodyContent({
|
||||
required this.imagePath,
|
||||
required this.title,
|
||||
required this.textContent,
|
||||
required this.confirmText,
|
||||
required this.cancelText,
|
||||
this.iconWidget,
|
||||
this.additionalWidgetContent,
|
||||
this.colorCancelButton,
|
||||
this.colorConfirmButton,
|
||||
this.styleTextCancelButton,
|
||||
this.styleTextConfirmButton,
|
||||
this.styleTitle,
|
||||
this.styleContent,
|
||||
this.radiusButton,
|
||||
this.paddingTitle,
|
||||
this.paddingContent,
|
||||
this.paddingButton,
|
||||
this.marginButton,
|
||||
this.marginIcon,
|
||||
this.margin,
|
||||
this.widthDialog,
|
||||
required this.maxWidth,
|
||||
this.listTextSpan,
|
||||
this.titleActionButtonMaxLines,
|
||||
required this.isArrangeActionButtonsVertical,
|
||||
required this.useIconAsBasicLogo,
|
||||
this.onConfirmButtonAction,
|
||||
this.onCancelButtonAction,
|
||||
this.onCloseButtonAction,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: widthDialog ?? 400,
|
||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(18)),
|
||||
),
|
||||
margin: margin,
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
top: 11,
|
||||
end: 11,
|
||||
start: 16,
|
||||
bottom: 24,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildCloseButton(),
|
||||
_buildIcon(),
|
||||
_buildTitle(context),
|
||||
_buildContent(context),
|
||||
_buildAdditionalContent(),
|
||||
_buildActionButtons(context),
|
||||
].where((widget) => widget != const SizedBox.shrink()).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCloseButton() {
|
||||
return onCloseButtonAction != null
|
||||
? Align(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
child: TMailButtonWidget.fromIcon(
|
||||
icon: imagePath.icCloseDialog,
|
||||
iconSize: 29,
|
||||
iconColor: AppColor.steelGrayA540,
|
||||
padding: const EdgeInsets.all(5),
|
||||
backgroundColor: Colors.transparent,
|
||||
onTapActionCallback: onCloseButtonAction,
|
||||
),
|
||||
)
|
||||
: const SizedBox(height: 24);
|
||||
}
|
||||
|
||||
Widget _buildIcon() {
|
||||
if (useIconAsBasicLogo) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SvgPicture.asset(
|
||||
imagePath.icTMailLogo,
|
||||
fit: BoxFit.fill,
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
);
|
||||
} else if (iconWidget != null) {
|
||||
return Container(
|
||||
margin: marginIcon ?? EdgeInsets.zero,
|
||||
alignment: Alignment.center,
|
||||
child: iconWidget,
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
void key(Key key) {
|
||||
_key = key;
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void title(String title) {
|
||||
_title = title;
|
||||
Widget _buildTitle(BuildContext context) {
|
||||
return title.trim().isNotEmpty
|
||||
? Padding(
|
||||
padding: paddingTitle ??
|
||||
const EdgeInsetsDirectional.only(top: 16, end: 5),
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: styleTitle ??
|
||||
Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void content(String content) {
|
||||
_textContent = content;
|
||||
Widget _buildContent(BuildContext context) {
|
||||
if (textContent.trim().isNotEmpty) {
|
||||
return Padding(
|
||||
padding:
|
||||
paddingContent ?? const EdgeInsetsDirectional.only(top: 16, end: 5),
|
||||
child: Center(
|
||||
child: Text(
|
||||
textContent,
|
||||
textAlign: TextAlign.center,
|
||||
style: styleContent ??
|
||||
Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: AppColor.steelGrayA540,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (listTextSpan != null) {
|
||||
return Padding(
|
||||
padding:
|
||||
paddingContent ?? const EdgeInsetsDirectional.only(top: 16, end: 5),
|
||||
child: Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: styleContent ??
|
||||
Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: AppColor.steelGrayA540,
|
||||
),
|
||||
children: listTextSpan,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void addWidgetContent(Widget? icon) {
|
||||
_additionalWidgetContent = icon;
|
||||
Widget _buildAdditionalContent() {
|
||||
return additionalWidgetContent != null
|
||||
? Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 16, end: 5),
|
||||
child: additionalWidgetContent!,
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void addIcon(Widget? icon) {
|
||||
_iconWidget = icon;
|
||||
}
|
||||
|
||||
void colorCancelButton(Color? color) {
|
||||
_colorCancelButton = color;
|
||||
}
|
||||
|
||||
void colorConfirmButton(Color? color) {
|
||||
_colorConfirmButton = color;
|
||||
}
|
||||
|
||||
void styleTextCancelButton(TextStyle? style) {
|
||||
_styleTextCancelButton = style;
|
||||
}
|
||||
|
||||
void styleTextConfirmButton(TextStyle? style) {
|
||||
_styleTextConfirmButton = style;
|
||||
}
|
||||
|
||||
void styleTitle(TextStyle? style) {
|
||||
_styleTitle = style;
|
||||
}
|
||||
|
||||
void styleContent(TextStyle? style) {
|
||||
_styleContent = style;
|
||||
}
|
||||
|
||||
void radiusButton(double? radius) {
|
||||
_radiusButton = radius;
|
||||
}
|
||||
|
||||
void paddingTitle(EdgeInsetsGeometry? value) {
|
||||
_paddingTitle = value;
|
||||
}
|
||||
|
||||
void paddingContent(EdgeInsets? value) {
|
||||
_paddingContent = value;
|
||||
}
|
||||
|
||||
void paddingButton(EdgeInsetsGeometry? value) {
|
||||
_paddingButton = value;
|
||||
}
|
||||
|
||||
void marginButton(EdgeInsets? value) {
|
||||
_marginButton = value;
|
||||
}
|
||||
|
||||
void marginIcon(EdgeInsetsGeometry? value) {
|
||||
_marginIcon = value;
|
||||
}
|
||||
|
||||
void margin(EdgeInsets? value) {
|
||||
_margin = value;
|
||||
}
|
||||
|
||||
void widthDialog(double? value) {
|
||||
_widthDialog = value;
|
||||
}
|
||||
|
||||
void alignment(Alignment? alignment) {
|
||||
_alignment = alignment;
|
||||
}
|
||||
|
||||
void outsideDialogPadding(EdgeInsets? value) {
|
||||
_outsideDialogPadding = value;
|
||||
}
|
||||
|
||||
void backgroundColor(Color value) {
|
||||
_backgroundColor = value;
|
||||
}
|
||||
|
||||
void onConfirmButtonAction(String confirmText, OnConfirmButtonAction? onConfirmButtonAction) {
|
||||
_confirmText = confirmText;
|
||||
_onConfirmButtonAction = onConfirmButtonAction;
|
||||
}
|
||||
|
||||
void onCancelButtonAction(String cancelText, OnCancelButtonAction? onCancelButtonAction) {
|
||||
_cancelText = cancelText;
|
||||
_onCancelButtonAction = onCancelButtonAction;
|
||||
}
|
||||
|
||||
void onCloseButtonAction(OnCloseButtonAction? onCloseButtonAction) {
|
||||
_onCloseButtonAction = onCloseButtonAction;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
if (showAsBottomSheet) {
|
||||
return _bodyContent();
|
||||
Widget _buildActionButtons(BuildContext context) {
|
||||
if (isArrangeActionButtonsVertical) {
|
||||
return Padding(
|
||||
padding: marginButton ??
|
||||
const EdgeInsetsDirectional.only(start: 15, end: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (cancelText.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 16),
|
||||
child: _buildButton(
|
||||
context,
|
||||
cancelText,
|
||||
onCancelButtonAction,
|
||||
colorCancelButton,
|
||||
styleTextCancelButton,
|
||||
),
|
||||
),
|
||||
if (confirmText.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 16),
|
||||
child: _buildButton(
|
||||
context,
|
||||
confirmText,
|
||||
onConfirmButtonAction,
|
||||
colorConfirmButton,
|
||||
styleTextConfirmButton,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Dialog(
|
||||
key: _key,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(18))),
|
||||
insetPadding: _outsideDialogPadding,
|
||||
alignment: _alignment ?? Alignment.center,
|
||||
backgroundColor: _backgroundColor,
|
||||
child: _bodyContent(),
|
||||
return Padding(
|
||||
padding: marginButton ??
|
||||
const EdgeInsetsDirectional.only(top: 16, start: 15, end: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
if (cancelText.isNotEmpty)
|
||||
Expanded(
|
||||
child: _buildButton(
|
||||
context,
|
||||
cancelText,
|
||||
onCancelButtonAction,
|
||||
colorCancelButton,
|
||||
styleTextCancelButton,
|
||||
),
|
||||
),
|
||||
if (confirmText.isNotEmpty && cancelText.isNotEmpty)
|
||||
const SizedBox(width: 16),
|
||||
if (confirmText.isNotEmpty)
|
||||
Expanded(
|
||||
child: _buildButton(
|
||||
context,
|
||||
confirmText,
|
||||
onConfirmButtonAction,
|
||||
colorConfirmButton,
|
||||
styleTextConfirmButton,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _bodyContent() {
|
||||
return Container(
|
||||
width: _widthDialog ?? 400,
|
||||
constraints: BoxConstraints(maxWidth: maxWith),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(18)),
|
||||
),
|
||||
margin: _margin,
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
top: 8,
|
||||
end: 8,
|
||||
start: 16,
|
||||
bottom: 24,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_onCloseButtonAction != null)
|
||||
Align(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
child: TMailButtonWidget.fromIcon(
|
||||
icon: _imagePath.icCancel,
|
||||
iconSize: 24,
|
||||
iconColor: AppColor.steelGrayA540,
|
||||
padding: const EdgeInsets.all(5),
|
||||
backgroundColor: Colors.transparent,
|
||||
onTapActionCallback: _onCloseButtonAction,
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox(height: 24),
|
||||
if (useIconAsBasicLogo)
|
||||
SvgPicture.asset(
|
||||
_imagePath.icTMailLogo,
|
||||
fit: BoxFit.fill,
|
||||
width: 70,
|
||||
height: 70,
|
||||
)
|
||||
else if (_iconWidget != null)
|
||||
Container(
|
||||
margin: _marginIcon ?? EdgeInsets.zero,
|
||||
alignment: Alignment.center,
|
||||
child: _iconWidget,
|
||||
),
|
||||
if (_title.isNotEmpty)
|
||||
Padding(
|
||||
padding: _paddingTitle
|
||||
?? const EdgeInsetsDirectional.only(top: 16, end: 8,),
|
||||
child: Center(
|
||||
child: Text(
|
||||
_title,
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleTitle ?? const TextStyle(
|
||||
fontSize: 22.0,
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
if (_textContent.isNotEmpty)
|
||||
Padding(
|
||||
padding: _paddingContent
|
||||
?? const EdgeInsetsDirectional.only(top: 16, end: 8,),
|
||||
child: Center(
|
||||
child: Text(
|
||||
_textContent,
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleContent ?? const TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: AppColor.steelGrayA540,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else if (listTextSpan != null)
|
||||
Padding(
|
||||
padding: _paddingContent ??
|
||||
const EdgeInsetsDirectional.only(top: 16, end: 8,),
|
||||
child: Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: _styleContent ?? const TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: AppColor.steelGrayA540,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
children: listTextSpan,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_additionalWidgetContent != null)
|
||||
Padding(
|
||||
padding:const EdgeInsetsDirectional.only(top: 16, end: 8,),
|
||||
child: _additionalWidgetContent,
|
||||
),
|
||||
if (isArrangeActionButtonsVertical)
|
||||
...[
|
||||
if (_cancelText.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 16, end: 8,),
|
||||
child: ConfirmDialogButton(
|
||||
label: _cancelText,
|
||||
backgroundColor: _colorCancelButton ?? AppColor.blue700,
|
||||
borderRadius: _radiusButton,
|
||||
textStyle: _styleTextCancelButton ?? const TextStyle(
|
||||
fontSize: 17,
|
||||
height: 24 / 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
),
|
||||
padding: _paddingButton,
|
||||
maxLines: titleActionButtonMaxLines,
|
||||
onTapAction: _onCancelButtonAction),
|
||||
),
|
||||
if (_confirmText.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 16, end: 8),
|
||||
child: ConfirmDialogButton(
|
||||
label: _confirmText,
|
||||
backgroundColor: _colorConfirmButton ?? AppColor.colorF3F6F9,
|
||||
borderRadius: _radiusButton,
|
||||
textStyle: _styleTextConfirmButton ?? const TextStyle(
|
||||
fontSize: 17,
|
||||
height: 24 / 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.steelGray600,
|
||||
),
|
||||
padding: _paddingButton,
|
||||
maxLines: titleActionButtonMaxLines,
|
||||
onTapAction: _onConfirmButtonAction),
|
||||
),
|
||||
]
|
||||
else
|
||||
Padding(
|
||||
padding: _marginButton
|
||||
?? const EdgeInsetsDirectional.only(top: 16, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (_cancelText.isNotEmpty)
|
||||
Expanded(child: ConfirmDialogButton(
|
||||
label: _cancelText,
|
||||
backgroundColor: _colorCancelButton ?? AppColor.blue700,
|
||||
borderRadius: _radiusButton,
|
||||
textStyle: _styleTextCancelButton ?? const TextStyle(
|
||||
fontSize: 17,
|
||||
height: 24 / 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
),
|
||||
padding: _paddingButton,
|
||||
maxLines: titleActionButtonMaxLines,
|
||||
onTapAction: _onCancelButtonAction,
|
||||
)),
|
||||
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty)
|
||||
const SizedBox(width: 16),
|
||||
if (_confirmText.isNotEmpty)
|
||||
Expanded(child: ConfirmDialogButton(
|
||||
label: _confirmText,
|
||||
backgroundColor: _colorConfirmButton ?? AppColor.colorF3F6F9,
|
||||
borderRadius: _radiusButton,
|
||||
textStyle: _styleTextConfirmButton ?? const TextStyle(
|
||||
fontSize: 17,
|
||||
height: 24 / 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.steelGray600,
|
||||
),
|
||||
padding: _paddingButton,
|
||||
maxLines: titleActionButtonMaxLines,
|
||||
onTapAction: _onConfirmButtonAction,
|
||||
))
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Widget _buildButton(
|
||||
BuildContext context,
|
||||
String label,
|
||||
VoidCallback? onTapAction,
|
||||
Color? bgColor,
|
||||
TextStyle? textStyle,
|
||||
) {
|
||||
return ConfirmDialogButton(
|
||||
label: label,
|
||||
backgroundColor: bgColor ??
|
||||
(onTapAction == onConfirmButtonAction
|
||||
? AppColor.grayBackgroundColor
|
||||
: AppColor.blue700),
|
||||
borderRadius: radiusButton,
|
||||
textStyle: textStyle,
|
||||
padding: paddingButton,
|
||||
textColor: onTapAction == onConfirmButtonAction
|
||||
? AppColor.steelGray600
|
||||
: Colors.white,
|
||||
maxLines: titleActionButtonMaxLines,
|
||||
onTapAction: onTapAction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class HtmlUtils {
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
${useDefaultFont && PlatformInfo.isMobile
|
||||
? '<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">'
|
||||
? '<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">'
|
||||
: ''}
|
||||
<style>
|
||||
${useDefaultFont ? '''
|
||||
|
||||
+7
-7
@@ -285,10 +285,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
||||
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1207,21 +1207,21 @@ packages:
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: win32
|
||||
sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c"
|
||||
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.4"
|
||||
version: "5.5.1"
|
||||
win32_registry:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "1c52f994bdccb77103a6231ad4ea331a244dbcef5d1f37d8462f713143b0bfae"
|
||||
sha256: "723b7f851e5724c55409bb3d5a32b203b3afe8587eaf5dafb93a5fed8ecda0d6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.4"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -93,6 +93,8 @@ dependencies:
|
||||
|
||||
debounce_throttle: 2.0.0
|
||||
|
||||
win32: 5.5.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user