Untitled
unknown
plain_text
a year ago
4.2 kB
11
Indexable
class SubscriptionCover extends StatelessWidget {
final bool isSelected;
final Package package;
final Function({required int index}) onSelectSubscription;
final int index;
const SubscriptionCover(
{super.key,
required this.package,
required this.isSelected,
required this.onSelectSubscription,
required this.index});
@override
Widget build(BuildContext context) {
String subscriptionTitle = '';
switch (package.storeProduct.identifier) {
case 'SummifyPremiumWeekly' || 'summify_premium_week':
subscriptionTitle = '1 month';
case 'SummifyPremiumMonth' || 'summify_premium_month':
subscriptionTitle = '12 months';
}
final textColor = Theme.of(context).brightness == Brightness.light
? isSelected
? Colors.white
: Colors.black
: Colors.white;
String currency({required String code}) {
Locale locale = Localizations.localeOf(context);
var format = NumberFormat.simpleCurrency(locale: locale.toString());
return format.currencySymbol;
}
return Expanded(
child: SizedBox(
height: 110,
child: GestureDetector(
onTap: () => onSelectSubscription(index: index),
child: Container(
decoration: BoxDecoration(
color: isSelected
? Theme.of(context).primaryColor
: Colors.white12,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Theme.of(context).brightness == Brightness.light
? Theme.of(context).hintColor
: Colors.white,
width: 2)),
child: Stack(
fit: StackFit.expand,
children: [
if (isSelected)
Align(
alignment: Alignment.topLeft,
child: SvgPicture.asset(Assets.icons.discount),
),
if (isSelected)
Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.all(0),
child: SvgPicture.asset(Assets.icons.checkCircle)),
),
Padding(
padding: const EdgeInsets.only(top: 6, bottom: 6),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
subscriptionTitle,
textAlign: TextAlign.center,
style: TextStyle(
color: textColor,
fontSize: 15,
fontWeight: FontWeight.w500),
),
// const Divider(
// color: Colors.transparent,
// ),
Text(
package.storeProduct.priceString,
textAlign: TextAlign.center,
overflow: TextOverflow.clip,
style: TextStyle(
color: textColor,
fontSize: 24,
fontWeight:
isSelected ? FontWeight.w700 : FontWeight.w400),
),
Text(
'${currency(code: package.storeProduct.currencyCode)} ${(package.storeProduct.price * 2).toStringAsFixed(2)}',
style: TextStyle(
color: textColor,
decoration: TextDecoration.lineThrough,
decorationColor: textColor,
fontSize: 16,
fontWeight: FontWeight.w400),
),
],
),
),
],
),
),
),
),
);
}
}Editor is loading...
Leave a Comment