You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_provider_app/lib/views/subscriptions/widget/subscriptions_card.dart

147 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/subscriptions_models/subscription_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/date_helper.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class SubscriptionsCard extends StatelessWidget {
Subscription subscription;
bool isSubscribed;
Color? backgroundColor;
late Color textColor;
SubscriptionsCard(this.subscription, {Key? key, this.isSubscribed = false, this.backgroundColor}) : super(key: key);
@override
Widget build(BuildContext context) {
textColor = backgroundColor == null ? Colors.black : Colors.white;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: subscription.name.toString().toText(
fontSize: 18,
color: textColor,
),
),
if (isSubscribed)
Row(
children: [
Container(
color: MyColors.white,
padding: const EdgeInsets.all(2),
child: const Icon(
Icons.done,
size: 8,
color: MyColors.primaryColor,
),
).toCircle(
borderRadius: 122,
),
6.width,
"Subscribed".toText(color: Colors.white, isBold: true)
],
).toContainer(
backgroundColor: MyColors.primaryColor,
borderRadius: 20,
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 3,
),
)
],
),
6.height,
showItem("Ads:", subscription.numberOfAds.toString()),
showItem("Users:", subscription.numberOfSubUsers.toString()),
showItem("Branches:", subscription.numberOfBranches.toString()),
14.height,
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
subscription.price.toString().toText(
fontSize: 26,
isBold: true,
color: textColor,
),
2.width,
"${subscription.currency}/Month".toText(
color: MyColors.lightTextColor,
fontSize: 16,
),
],
),
),
if (!isSubscribed)
Row(
children: [
"Upgrade".toText(
fontSize: 14,
color: textColor,
),
4.width,
Icon(
Icons.arrow_forward,
size: 16,
color: textColor,
)
],
)
],
),
if (isSubscribed)
Row(
children: [
"Expires on ${DateHelper.formatAsDayMonthYear(subscription.dateEnd)}".toText(
fontSize: 14,
color: textColor,
),
6.width,
"Renew".toText(
color: MyColors.primaryColor,
fontSize: 14,
textDecoration: TextDecoration.underline,
isBold: true,
),
],
)
],
).toWhiteContainer(
width: double.infinity,
allPading: 12,
backgroundColor: backgroundColor,
margin: const EdgeInsets.symmetric(
horizontal: 21,
),
);
}
Widget showItem(String title, String value) {
return Row(
children: [
title.toText(
fontSize: 14,
color: textColor,
),
2.width,
value.toText(
fontSize: 14,
color: textColor,
),
],
);
}
}