Skip to content

Instantly share code, notes, and snippets.

@gabrielaraujoz
Last active Jun 3, 2021
Embed
What would you like to do?
newrevelobadge
class ReveloBadge extends StatelessWidget {
final String text;
final String iconName;
final ReveloBadgeStyle badgeStyle;
const ReveloBadge({
Key key,
@required this.text,
@required this.badgeStyle,
this.iconName,
}) : super(key: key);
factory ReveloBadge.outlined({
Key key,
@required String text,
@required BuildContext context,
String iconName,
}) =>
ReveloBadge(
key: key,
text: text,
badgeStyle: ReveloBadgeStyle.outlined(context),
iconName: iconName,
);
factory ReveloBadge.red({
Key key,
@required String text,
String iconName,
}) =>
ReveloBadge(
key: key,
text: text,
iconName: iconName,
badgeStyle: ReveloBadgeStyle.red(),
);
factory ReveloBadge.blue({
Key key,
@required String text,
String iconName,
}) =>
ReveloBadge(
key: key,
text: text,
iconName: iconName,
badgeStyle: ReveloBadgeStyle.blueLight(),
);
factory ReveloBadge.green({
Key key,
@required String text,
String iconName,
}) =>
ReveloBadge(
key: key,
text: text,
iconName: iconName,
badgeStyle: ReveloBadgeStyle.green(),
);
factory ReveloBadge.gray({
Key key,
@required String text,
String iconName,
}) =>
ReveloBadge(
key: key,
text: text,
iconName: iconName,
badgeStyle: ReveloBadgeStyle.gray(),
);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: Dimens.sm, vertical: 2),
decoration: BoxDecoration(
color: badgeStyle.backgroundColor,
borderRadius: BorderRadius.circular(Dimens.borderRadiusSmaller),
border: badgeStyle.border,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (iconName != null)
Padding(
padding: const EdgeInsets.only(right: Dimens.md),
child: SafeIcon( // Classe própria que exibe um ícone a partir de um nome
assetName: iconName,
color: badgeStyle.textColor,
size: Size.square(12),
),
),
Flexible(
child: Text(
text.toUpperCase(),
style: ReveloTheme.of(context).overline.copyWith(
color: badgeStyle.textColor,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment