| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:cake_wallet/generated/i18n.dart'; |
| 3 | |
| 4 | class DiscountBadge extends StatelessWidget { |
| 5 | const DiscountBadge({ |
| 6 | Key? key, |
| 7 | required this.percentage, |
| 8 | this.discountBackground, |
| 9 | this.isAmount = false, |
| 10 | }) : super(key: key); |
| 11 | |
| 12 | final double percentage; |
| 13 | final bool isAmount; |
| 14 | final AssetImage? discountBackground; |
| 15 | |
| 16 | @override |
| 17 | Widget build(BuildContext context) { |
| 18 | return Container( |
| 19 | padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), |
| 20 | child: Text( |
| 21 | isAmount |
| 22 | ? '\$${percentage.toStringAsFixed(2)}' |
| 23 | : S.of(context).discount(percentage.toStringAsFixed(2)), |
| 24 | style: Theme.of(context).textTheme.bodySmall?.copyWith( |
| 25 | fontWeight: FontWeight.w500, |
| 26 | ), |
| 27 | ), |
| 28 | decoration: BoxDecoration( |
| 29 | image: DecorationImage( |
| 30 | fit: BoxFit.fill, |
| 31 | image: discountBackground ?? AssetImage('assets/images/badge_discount.png'), |
| 32 | ), |
| 33 | ), |
| 34 | ); |
| 35 | } |
| 36 | } |