@ -1,6 +1,8 @@
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/main.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 ' ;
@ -9,7 +11,7 @@ import 'package:mc_common_app/utils/enums.dart';
import ' package:mc_common_app/widgets/extensions/extensions_widget.dart ' ;
class MySubscriptionsCard extends StatelessWidget {
ProviderSubscriptionModel providerSubscriptionModel ;
Subscription pvm ;
bool isSubscribed ;
Color ? backgroundColor ;
late Color textColor ;
@ -17,20 +19,12 @@ class MySubscriptionsCard extends StatelessWidget {
Function onUpgradeSubscriptionClick ;
bool isMainPage ;
MySubscriptionsCard ( this . providerSubscriptionModel ,
{ Key ? key , this . isSubscribed = false , this . backgroundColor , required this . onRenewSubscriptionClick , required this . onUpgradeSubscriptionClick , this . isMainPage = true } )
MySubscriptionsCard ( this . pvm , { 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 ,
@ -38,17 +32,13 @@ class MySubscriptionsCard extends StatelessWidget {
Row (
children: [
Expanded (
child: providerSubscriptionModel . subscriptionName . toString ( ) . toText (
fontSize: 18 ,
color: textColor ,
) ,
child: pvm . 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: [
p roviderSubscriptionModel . isExpired !
p vm . isExpired !
? const SizedBox ( )
: Container (
height: 15 ,
@ -65,65 +55,55 @@ class MySubscriptionsCard extends StatelessWidget {
) ,
) ,
5. width ,
( p roviderSubscriptionModel . isExpired ! ? " Expired " : " Subscribed " ) . toText ( color: p roviderSubscriptionModel . isExpired ! ? MyColors . darkTextColor : MyColors . white )
( p vm . isExpired ! ? " Expired " : " Subscribed " ) . toText ( color: p vm . isExpired ! ? MyColors . darkTextColor : MyColors . white )
] ,
)
. toContainer (
backgroundColor: p roviderSubscriptionModel . isExpired ! ? MyColors . greyButtonColor : MyColors . primaryColor ,
backgroundColor: p vm . isExpired ! ? MyColors . greyButtonColor : MyColors . primaryColor ,
borderRadius: 30 ,
padding: const EdgeInsets . symmetric ( horizontal: 8 , vertical: 7 ) ,
)
. onPress ( ( ) {
p roviderSubscriptionModel . isExpired ! ? onRenewSubscriptionClick ( ) : onUpgradeSubscriptionClick ( ) ;
p vm . isExpired ! ? onRenewSubscriptionClick ( ) : onUpgradeSubscriptionClick ( ) ;
} )
] ,
) ,
6. height ,
showItem ( " Ads: " , providerSubscriptionModel . adsRemaining . toString ( ) ) ,
showItem ( " Users: " , providerSubscriptionModel . subUsersRemaining . toString ( ) ) ,
showItem ( " Branches: " , providerSubscriptionModel . branchesRemaining . toString ( ) ) ,
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 " ) ,
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 (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
" ${ providerSubscriptionModel . isExpired ! ? " Expired " : " Expires " } on ${ DateHelper . formatAsDayMonthYear ( providerSubscriptionModel . dateEnd ) } " . toText (
fontSize: 14 ,
color: textColor ,
Expanded (
child: Row (
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . end ,
children: [
pvm . price . toString ( ) . toText (
fontSize: 29 ,
isBold: true ,
letterSpacing: - 1.77 ,
color: textColor ,
) ,
2. width ,
" SAR/Month " . toText ( color: MyColors . lightTextColor , fontSize: 16 , letterSpacing: - 0.64 ) ,
] ,
) ,
) ,
if ( ! providerSubscriptionModel . isTrialSubscription ! )
] ,
) ,
Row (
children: [
" ${ pvm . isExpired ! ? " Expired " : " Expires " } on ${ DateHelper . formatAsDayMonthYear ( pvm . dateEnd ) } " . toText ( fontSize: 14 , letterSpacing: - 0.56 , color: textColor , fontWeight: MyFonts . Medium ) ,
if ( pvm . isRenewable ! )
Row (
children: [
6. width ,
" Renew " . toText (
color: MyColors . primaryColor ,
fontSize: 14 ,
textDecoration: TextDecoration . underline ,
decorationColor: MyColors . primaryColor ,
isBold: true ,
) ,
color: MyColors . primaryColor , fontSize: 14 , letterSpacing: - 0.56 , textDecoration: TextDecoration . underline , decorationColor: MyColors . primaryColor , fontWeight: MyFonts . Medium ) ,
] ,
) . onPress ( ( ) {
onRenewSubscriptionClick ( ) ;
@ -145,10 +125,7 @@ class MySubscriptionsCard extends StatelessWidget {
Widget showItem ( String title , String value ) {
return Row (
children: [
title . toText (
fontSize: 14 ,
color: textColor ,
) ,
title . toText ( fontSize: 14 , color: textColor , letterSpacing: - 0.56 ) ,
2. width ,
value . toText (
fontSize: 14 ,