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 pvm ;
bool isSubscribed ;
Color ? backgroundColor ;
late Color textColor ;
Function onRenewSubscriptionClick ;
Function onUpgradeSubscriptionClick ;
bool isMainPage ;
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 Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
children: [
Expanded (
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: [
pvm . 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 ,
( pvm . isExpired ! ? " Expired " : " Subscribed " ) . toText ( color: pvm . isExpired ! ? MyColors . darkTextColor : MyColors . white )
] ,
)
. toContainer (
backgroundColor: pvm . isExpired ! ? MyColors . greyButtonColor : MyColors . primaryColor ,
borderRadius: 30 ,
padding: const EdgeInsets . symmetric ( horizontal: 8 , vertical: 7 ) ,
)
. onPress ( ( ) {
pvm . 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: " , " ${ pvm . adsRemaining . toString ( ) } remaining " ) ,
showItem ( " Users: " , " ${ pvm . subUsersRemaining . toString ( ) } remaining " ) ,
showItem ( " Branches: " , " ${ pvm . branchesRemaining . toString ( ) } remaining " ) ,
14. height ,
Row (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
Expanded (
child: Row (
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . end ,
children: [
pvm . 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: [
" ${ pvm . isExpired ! ? " Expired " : " Expires " } on ${ DateHelper . formatAsDayMonthYear ( DateHelper . parseStringToDate ( DateHelper . formatDateT ( 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 , 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 ,
) ,
] ,
) ;
}
}