Merge branch 'aamir_dev' into faiz_dev
commit
718cc75d13
@ -0,0 +1,168 @@
|
|||||||
|
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/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 InkWell(
|
||||||
|
// onTap: isSubscribed
|
||||||
|
// ? null
|
||||||
|
// : () {
|
||||||
|
// onRenewSubscriptionClick();
|
||||||
|
// },
|
||||||
|
// child:
|
||||||
|
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,
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
if (subscription.isMyCurrentPackage!) "Current Package".toText(color: MyColors.primaryColor, fontWeight: FontWeight.bold),
|
||||||
|
if (!subscription.isMyCurrentPackage!)
|
||||||
|
(subscription.subscriptionTypeEnum)!
|
||||||
|
.getStringSubscriptionTypeEnum()
|
||||||
|
.toText(color: Colors.white)
|
||||||
|
.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.numberOfAds.toString()),
|
||||||
|
showItem("Users:", subscription.numberOfSubUsers.toString()),
|
||||||
|
showItem("Branches:", subscription.numberOfBranches.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: 26,
|
||||||
|
isBold: true,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
2.width,
|
||||||
|
"${subscription.currency}/Month".toText(
|
||||||
|
color: MyColors.lightTextColor,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (subscription.isMyCurrentPackage!)
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
(subscription.subscriptionTypeEnum == SubscriptionTypeEnum.current) ? "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,
|
||||||
|
),
|
||||||
|
2.width,
|
||||||
|
value.toText(
|
||||||
|
fontSize: 14,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
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/provider_subscription_model.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 MySubscriptionsCard extends StatelessWidget {
|
||||||
|
ProviderSubscriptionModel providerSubscriptionModel;
|
||||||
|
bool isSubscribed;
|
||||||
|
Color? backgroundColor;
|
||||||
|
late Color textColor;
|
||||||
|
Function onRenewSubscriptionClick;
|
||||||
|
Function onUpgradeSubscriptionClick;
|
||||||
|
bool isMainPage;
|
||||||
|
|
||||||
|
MySubscriptionsCard(this.providerSubscriptionModel,
|
||||||
|
{Key? key, this.isSubscribed = false, this.backgroundColor, required this.onRenewSubscriptionClick, required this.onUpgradeSubscriptionClick, this.isMainPage = true})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
textColor = backgroundColor == null ? Colors.black : Colors.white;
|
||||||
|
// return InkWell(
|
||||||
|
// onTap: isSubscribed
|
||||||
|
// ? null
|
||||||
|
// : () {
|
||||||
|
// onRenewSubscriptionClick();
|
||||||
|
// },
|
||||||
|
// child:
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: providerSubscriptionModel.subscriptionName.toString().toText(
|
||||||
|
fontSize: 18,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// if (providerSubscriptionModel.isActive!) "Current Package".toText(color: MyColors.primaryColor, fontWeight: FontWeight.bold),
|
||||||
|
5.width,
|
||||||
|
if (!providerSubscriptionModel.isExpired!)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 15,
|
||||||
|
width: 15,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: MyColors.white,
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Icon(
|
||||||
|
Icons.done,
|
||||||
|
size: 12,
|
||||||
|
color: MyColors.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
5.width,
|
||||||
|
"Subscribed".toText(color: MyColors.white)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.toContainer(
|
||||||
|
backgroundColor: MyColors.primaryColor,
|
||||||
|
borderRadius: 30,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 7),
|
||||||
|
)
|
||||||
|
.onPress(() {
|
||||||
|
onUpgradeSubscriptionClick();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
6.height,
|
||||||
|
showItem("Ads:", providerSubscriptionModel.adsRemaining.toString()),
|
||||||
|
showItem("Users:", providerSubscriptionModel.subUsersRemaining.toString()),
|
||||||
|
showItem("Branches:", providerSubscriptionModel.branchesRemaining.toString()),
|
||||||
|
14.height,
|
||||||
|
// Row(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Expanded(
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// "10000".toString().toText(
|
||||||
|
// fontSize: 26,
|
||||||
|
// isBold: true,
|
||||||
|
// color: textColor,
|
||||||
|
// ),
|
||||||
|
// 2.width,
|
||||||
|
// " SAR/Month".toText(
|
||||||
|
// color: MyColors.lightTextColor,
|
||||||
|
// fontSize: 16,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
"Expires on ${DateHelper.formatAsDayMonthYear(providerSubscriptionModel.dateEnd)}".toText(
|
||||||
|
fontSize: 14,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
if (!providerSubscriptionModel.isTrialSubscription!)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
6.width,
|
||||||
|
"Renew".toText(
|
||||||
|
color: MyColors.primaryColor,
|
||||||
|
fontSize: 14,
|
||||||
|
textDecoration: TextDecoration.underline,
|
||||||
|
decorationColor: MyColors.primaryColor,
|
||||||
|
isBold: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).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,
|
||||||
|
),
|
||||||
|
2.width,
|
||||||
|
value.toText(
|
||||||
|
fontSize: 14,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,185 +0,0 @@
|
|||||||
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/utils/enums.dart';
|
|
||||||
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
||||||
|
|
||||||
class SubscriptionsCard extends StatelessWidget {
|
|
||||||
Subscription subscription;
|
|
||||||
bool isSubscribed;
|
|
||||||
Color? backgroundColor;
|
|
||||||
late Color textColor;
|
|
||||||
Function onRenewSubscriptionClick;
|
|
||||||
bool isMainPage;
|
|
||||||
|
|
||||||
SubscriptionsCard(this.subscription,
|
|
||||||
{Key? key,
|
|
||||||
this.isSubscribed = false,
|
|
||||||
this.backgroundColor,
|
|
||||||
required this.onRenewSubscriptionClick,
|
|
||||||
this.isMainPage = true})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
textColor = backgroundColor == null ? Colors.black : Colors.white;
|
|
||||||
return InkWell(
|
|
||||||
onTap: isSubscribed
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
onRenewSubscriptionClick();
|
|
||||||
},
|
|
||||||
child: 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,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
if (!isMainPage)
|
|
||||||
if (subscription.subscriptionTypeEnum ==
|
|
||||||
SubscriptionTypeEnum.current)
|
|
||||||
"Current Package".toText(color: MyColors.primaryColor,fontWeight: FontWeight.bold),
|
|
||||||
if (isMainPage)
|
|
||||||
"Upgrade".toText(color: Colors.white).toContainer(
|
|
||||||
backgroundColor: MyColors.primaryColor,
|
|
||||||
borderRadius: 30,
|
|
||||||
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.start,
|
|
||||||
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 (!isMainPage)
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
(subscription.subscriptionTypeEnum ==
|
|
||||||
SubscriptionTypeEnum.current)
|
|
||||||
? "Renew".toText()
|
|
||||||
: (subscription.subscriptionTypeEnum)!
|
|
||||||
.getStringSubscriptionTypeEnum()
|
|
||||||
.toText(),
|
|
||||||
6.width,
|
|
||||||
const Icon(
|
|
||||||
Icons.arrow_forward,
|
|
||||||
size: 16,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// if (isSubscribed)
|
|
||||||
if (isMainPage)
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
"Expires on ${DateHelper.formatAsDayMonthYear(subscription.dateEnd)}"
|
|
||||||
.toText(
|
|
||||||
fontSize: 14,
|
|
||||||
color: textColor,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
6.width,
|
|
||||||
"Renew".toText(
|
|
||||||
color: MyColors.primaryColor,
|
|
||||||
fontSize: 14,
|
|
||||||
textDecoration: TextDecoration.underline,
|
|
||||||
decorationColor: MyColors.primaryColor,
|
|
||||||
isBold: true,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).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,
|
|
||||||
),
|
|
||||||
2.width,
|
|
||||||
value.toText(
|
|
||||||
fontSize: 14,
|
|
||||||
color: textColor,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue