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.
141 lines
5.6 KiB
Dart
141 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/generated/locale_keys.g.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:easy_localization/easy_localization.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
class MySubscriptionsCard extends StatelessWidget {
|
|
Subscription subscriptionVM;
|
|
bool isSubscribed;
|
|
Color? backgroundColor;
|
|
late Color textColor;
|
|
Function onRenewSubscriptionClick;
|
|
Function onUpgradeSubscriptionClick;
|
|
bool isMainPage;
|
|
|
|
MySubscriptionsCard(this.subscriptionVM, {super.key, this.isSubscribed = false, this.backgroundColor, required this.onRenewSubscriptionClick, required this.onUpgradeSubscriptionClick, this.isMainPage = true});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
textColor = backgroundColor == null ? Colors.black : Colors.white;
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: subscriptionVM.name.toString().toText(fontSize: 18, color: textColor, letterSpacing: -0.43),
|
|
),
|
|
// if (providerSubscriptionModel.isActive!) "Current Package".toText(color: MyColors.primaryColor, fontWeight: FontWeight.bold),
|
|
5.width,
|
|
Row(
|
|
children: [
|
|
subscriptionVM.isExpired!
|
|
? const SizedBox()
|
|
: Container(
|
|
height: 15,
|
|
width: 15,
|
|
decoration: const BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: MyColors.white,
|
|
),
|
|
alignment: Alignment.center,
|
|
child: const Icon(
|
|
Icons.done,
|
|
size: 12,
|
|
color: MyColors.primaryColor,
|
|
),
|
|
),
|
|
5.width,
|
|
(subscriptionVM.isExpired! ? "Expired" : "Subscribed").toText(color: subscriptionVM.isExpired! ? MyColors.darkTextColor : MyColors.white)
|
|
],
|
|
)
|
|
.toContainer(
|
|
backgroundColor: subscriptionVM.isExpired! ? MyColors.greyButtonColor : MyColors.primaryColor,
|
|
borderRadius: 30,
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 7),
|
|
)
|
|
.onPress(() {
|
|
subscriptionVM.isExpired! ? onRenewSubscriptionClick() : onUpgradeSubscriptionClick();
|
|
})
|
|
],
|
|
),
|
|
6.height,
|
|
// showItem("Ads:", "${pvm.adsRemaining.toString()} of ${pvm.totalAds.toString()} remaining"),
|
|
// showItem("Users:", "${pvm.subUsersRemaining.toString()} of ${pvm.totalSubUsers.toString()} remaining"),
|
|
// showItem("Branches:", "${pvm.branchesRemaining.toString()} of ${pvm.totalBranches.toString()} remaining"),
|
|
|
|
showItem("Ads: ", "${subscriptionVM.adsRemaining.toString()} remaining"),
|
|
showItem("Users: ", "${subscriptionVM.subUsersRemaining.toString()} remaining"),
|
|
showItem("Branches: ", "${subscriptionVM.branchesRemaining.toString()} remaining"),
|
|
|
|
14.height,
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
subscriptionVM.price.toString().toText(
|
|
fontSize: 29,
|
|
isBold: true,
|
|
letterSpacing: -1.77,
|
|
height: 1,
|
|
color: textColor,
|
|
),
|
|
2.width,
|
|
" ${LocaleKeys.sar.tr()}/Month".toText(color: MyColors.lightTextColor, fontSize: 16, letterSpacing: -0.64).paddingOnly(bottom: 3),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
"${subscriptionVM.isExpired! ? "Expired" : "Expires"} on ${DateHelper.formatAsDayMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(subscriptionVM.dateEnd ?? "")))}".toText(fontSize: 14, letterSpacing: -0.56, color: textColor, fontWeight: MyFonts.Medium),
|
|
if (subscriptionVM.isRenewable!)
|
|
Row(
|
|
children: [
|
|
6.width,
|
|
"Renew".toText(color: MyColors.primaryColor, fontSize: 14, letterSpacing: -0.56, textDecoration: TextDecoration.underline, decorationColor: MyColors.primaryColor, fontWeight: MyFonts.Medium),
|
|
],
|
|
).onPress(() {
|
|
onRenewSubscriptionClick();
|
|
}),
|
|
],
|
|
)
|
|
],
|
|
).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, letterSpacing: -0.56),
|
|
2.width,
|
|
value.toText(
|
|
fontSize: 14,
|
|
color: textColor,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|