TF-2116 Add icon, color and base widget
(cherry picked from commit a4c7eea22ec6557bfdaee4d0ee18ce1a4501a43d)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientCircleAvatarIcon extends StatelessWidget {
|
||||
|
||||
final List<Color> colors;
|
||||
final double iconSize;
|
||||
final double labelFontSize;
|
||||
final String label;
|
||||
|
||||
const GradientCircleAvatarIcon({
|
||||
Key? key,
|
||||
required this.colors,
|
||||
this.iconSize = 40,
|
||||
this.label = '',
|
||||
this.labelFontSize = 24.0,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
stops: const [0.0, 1.0],
|
||||
colors: colors
|
||||
),
|
||||
color: AppColor.avatarColor
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: labelFontSize,
|
||||
fontWeight: FontWeight.w600
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
final TextAlign? textAlign;
|
||||
final bool flexibleText;
|
||||
final BoxBorder? border;
|
||||
final TextDirection iconAlignment;
|
||||
|
||||
const TMailButtonWidget({
|
||||
super.key,
|
||||
@@ -61,6 +62,7 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
this.textAlign,
|
||||
this.flexibleText = false,
|
||||
this.border,
|
||||
this.iconAlignment = TextDirection.ltr,
|
||||
});
|
||||
|
||||
factory TMailButtonWidget.fromIcon({
|
||||
@@ -190,20 +192,31 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
]
|
||||
);
|
||||
} else {
|
||||
childWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
icon!,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
fit: BoxFit.fill,
|
||||
colorFilter: iconColor?.asFilter()
|
||||
),
|
||||
SizedBox(width: iconSpace),
|
||||
if (flexibleText)
|
||||
Flexible(
|
||||
child: Text(
|
||||
if (iconAlignment == TextDirection.ltr) {
|
||||
childWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
icon!,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
fit: BoxFit.fill,
|
||||
colorFilter: iconColor?.asFilter()
|
||||
),
|
||||
SizedBox(width: iconSpace),
|
||||
if (flexibleText)
|
||||
Flexible(
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: textAlign,
|
||||
style: textStyle ?? const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.colorTextButtonHeaderThread
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
text,
|
||||
textAlign: textAlign,
|
||||
style: textStyle ?? const TextStyle(
|
||||
@@ -211,29 +224,54 @@ class TMailButtonWidget extends StatelessWidget {
|
||||
color: AppColor.colorTextButtonHeaderThread
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
text,
|
||||
textAlign: textAlign,
|
||||
style: textStyle ?? const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.colorTextButtonHeaderThread
|
||||
if (trailingIcon != null)
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: iconSpace),
|
||||
child: SvgPicture.asset(
|
||||
trailingIcon!,
|
||||
width: trailingIconSize,
|
||||
height: trailingIconSize,
|
||||
fit: BoxFit.fill,
|
||||
colorFilter: trailingIconColor?.asFilter()
|
||||
),
|
||||
),
|
||||
),
|
||||
if (trailingIcon != null)
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: iconSpace),
|
||||
child: SvgPicture.asset(
|
||||
trailingIcon!,
|
||||
width: trailingIconSize,
|
||||
height: trailingIconSize,
|
||||
fit: BoxFit.fill,
|
||||
colorFilter: trailingIconColor?.asFilter()
|
||||
]
|
||||
);
|
||||
} else {
|
||||
childWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (flexibleText)
|
||||
Flexible(
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: textAlign,
|
||||
style: textStyle ?? const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.colorTextButtonHeaderThread
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
text,
|
||||
textAlign: textAlign,
|
||||
style: textStyle ?? const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.colorTextButtonHeaderThread
|
||||
),
|
||||
),
|
||||
SizedBox(width: iconSpace),
|
||||
SvgPicture.asset(
|
||||
icon!,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
fit: BoxFit.fill,
|
||||
colorFilter: iconColor?.asFilter()
|
||||
),
|
||||
]
|
||||
);
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (icon != null) {
|
||||
childWidget = SvgPicture.asset(
|
||||
|
||||
@@ -181,7 +181,7 @@ class ConfirmDialogBuilder {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8, right: 8),
|
||||
child: buildIconWeb(
|
||||
icon: SvgPicture.asset(_imagePath.icCloseMailbox, fit: BoxFit.fill),
|
||||
icon: SvgPicture.asset(_imagePath.icCircleClose, fit: BoxFit.fill),
|
||||
onTap: () => _onCloseButtonAction?.call())
|
||||
)),
|
||||
if (_iconWidget != null)
|
||||
|
||||
Reference in New Issue
Block a user