subscriptionTransactionHistoryCard method
dynamic
subscriptionTransactionHistoryCard()
Implementation
subscriptionTransactionHistoryCard() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Subscription Transaction History',
style: TextStyle(
fontSize: 15.dp,
fontWeight: FontWeight.w600,
color: ColorHelper.neutralText,
),
),
],
),
// Details Card
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (Get.width <= 960 && controller.selectedSubsccriber.value?.subscriptions != null) {
return Obx(
() {
return Column(
children: controller.selectedSubsccriber.value!.subscriptions
!.map((subscription) {
final oneYearLater = DateTime(
subscription.createdAt.year + 1,
subscription.createdAt.month,
subscription.createdAt.day,
);
String nextBillingDate = DateFormat('dd-MM-yyyy').format(oneYearLater);
return Padding(
padding: EdgeInsets.only(top: 10.dp),
child: ExpandableObjectWidget(
isExpanded: controller.expandedSubscriptionId.value == subscription.id,
title: subscription.package,
onExpandIcon: () {
if (controller.expandedSubscriptionId.value == subscription.id) {
controller.expandedSubscriptionId.value = null;
} else {
controller.expandedSubscriptionId.value = subscription.id;
}
},
labels: const [
'Subscription ID',
'Subscription Plan',
'Transaction Date',
'Amount Paid',
'Payment Status',
'Next Billing Date',
],
values: [
subscription.subscriberId,
subscription.package,
DateFormat('dd-MM-yyyy').format(
subscription.createdAt),
subscription.price,
subscription.status ?? '-',
nextBillingDate,
],
),
);
}).toList(),
);
}
);
}
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: ColorHelper.grey01, width: 1),
color: Colors.white),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SizedBox(
width: constraints.maxWidth,
child: Table(
columnWidths: const {
0: FlexColumnWidth(1.1),
1: FlexColumnWidth(1.05),
2: FlexColumnWidth(0.55),
3: FlexColumnWidth(0.45),
4: FlexColumnWidth(0.5),
5: FlexColumnWidth(0.5),
6: FlexColumnWidth(0.3),
},
children: [
TableRow(
decoration: const BoxDecoration(
color: ColorHelper.lightBg02,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
),
children: [
tableLabel('Subscription ID'),
tableLabel('Subscription Plan'),
tableLabel('Transaction Date'),
tableLabel('Amount Paid'),
tableLabel('Payment Status'),
tableLabel('Next Billing Date'),
],
),
...List.generate(
(controller.selectedSubsccriber.value?.subscriptions
?.length ??
0), (index) {
Subscription? subscription = controller
.selectedSubsccriber.value?.subscriptions?[index];
var createdAt = subscription?.createdAt??DateTime.now();
final oneYearLater = DateTime(
createdAt.year+1,
createdAt.month,
createdAt.day,
);
String nextBillingDate = DateFormat('dd-MM-yyyy').format(oneYearLater);
return TableRow(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)),
children: [
buildTableCell('${subscription?.subscriberId}'),
buildTableCell('${subscription?.name}'),
buildTableCell(DateFormat('dd-MM-yyyy').format(
subscription?.createdAt ?? DateTime.now())),
buildTableCell('${subscription?.price}'),
buildTableCell("${subscription?.status}"),
buildTableCell(nextBillingDate),
],
);
}),
],
),
),
),
);
}),
],
);
}