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.
128 lines
4.7 KiB
Dart
128 lines
4.7 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/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/utils/enums.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
class AllSubscriptionsCard extends StatelessWidget {
|
|
Subscription subscription;
|
|
bool isSubscribed;
|
|
Color? backgroundColor;
|
|
late Color textColor;
|
|
Function onRenewSubscriptionClick;
|
|
Function onUpgradeSubscriptionClick;
|
|
Function onDowngradeSubscriptionClick;
|
|
|
|
AllSubscriptionsCard(
|
|
this.subscription, {
|
|
Key? key,
|
|
this.isSubscribed = false,
|
|
this.backgroundColor,
|
|
required this.onRenewSubscriptionClick,
|
|
required this.onUpgradeSubscriptionClick,
|
|
required this.onDowngradeSubscriptionClick,
|
|
}) : 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,
|
|
letterSpacing: -0.43,
|
|
color: textColor,
|
|
),
|
|
),
|
|
if (subscription.isMyCurrentPackage!) "Current Package".toText(color: MyColors.primaryColor, fontWeight: MyFonts.SemiBold),
|
|
if (!subscription.isMyCurrentPackage!)
|
|
(subscription.subscriptionTypeEnum)!
|
|
.getStringSubscriptionTypeEnum()
|
|
.toText(color: Colors.white, fontSize: 12)
|
|
.toContainer(
|
|
backgroundColor: MyColors.primaryColor,
|
|
borderRadius: 30,
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 6,
|
|
vertical: 3,
|
|
),
|
|
)
|
|
.onPress(() {
|
|
if (subscription.subscriptionTypeEnum == SubscriptionTypeEnum.downgrade) {
|
|
onDowngradeSubscriptionClick();
|
|
} else {
|
|
onUpgradeSubscriptionClick();
|
|
}
|
|
})
|
|
],
|
|
),
|
|
6.height,
|
|
showItem("Ads:", subscription.subscriptionAds.toString()),
|
|
showItem("Users:", subscription.subscriptionSubUsers.toString()),
|
|
showItem("Branches:", subscription.subscriptionBranches.toString()),
|
|
14.height,
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
subscription.price.toString().toText(fontSize: 29, isBold: true, color: textColor, letterSpacing: -1.77),
|
|
2.width,
|
|
"${subscription.currency}/Month".toText(color: MyColors.lightTextColor, fontSize: 16, letterSpacing: -0.64),
|
|
],
|
|
),
|
|
),
|
|
if (subscription.subscriptionTypeEnum == SubscriptionTypeEnum.current && subscription.isRenewable!)
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
(subscription.subscriptionTypeEnum == SubscriptionTypeEnum.current && subscription.isRenewable!)
|
|
? "Renew".toText()
|
|
: (subscription.subscriptionTypeEnum)!.getStringSubscriptionTypeEnum().toText(),
|
|
6.width,
|
|
const Icon(
|
|
Icons.arrow_forward,
|
|
size: 16,
|
|
)
|
|
],
|
|
).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, fontWeight: MyFonts.Medium),
|
|
2.width,
|
|
value.toText(fontSize: 14, color: textColor, letterSpacing: -0.56, fontWeight: MyFonts.Medium),
|
|
],
|
|
);
|
|
}
|
|
}
|