-
-
Save gabrielaraujoz/ec50c7f7dee9d71c29e52f1c31e1cde5 to your computer and use it in GitHub Desktop.
newrevelobadge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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