136 lines
4.5 KiB
Dart
136 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:marco/controller/dashboard/dashboard_controller.dart';
|
|
import 'package:marco/helpers/widgets/my_text.dart';
|
|
import 'package:marco/helpers/utils/utils.dart';
|
|
import 'package:marco/helpers/widgets/my_custom_skeleton.dart';
|
|
|
|
class ExpenseByStatusWidget extends StatelessWidget {
|
|
final DashboardController controller;
|
|
|
|
const ExpenseByStatusWidget({super.key, required this.controller});
|
|
|
|
Widget _buildStatusTile({
|
|
required IconData icon,
|
|
required Color color,
|
|
required String title,
|
|
required String amount,
|
|
required String count,
|
|
}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
child: Row(
|
|
children: [
|
|
CircleAvatar(
|
|
backgroundColor: color.withOpacity(0.15),
|
|
radius: 22,
|
|
child: Icon(icon, color: color, size: 24),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
MyText.bodyMedium(title, fontWeight: 600),
|
|
const SizedBox(height: 2),
|
|
MyText.titleMedium(amount, color: Colors.blue, fontWeight: 700),
|
|
],
|
|
),
|
|
),
|
|
MyText.titleMedium(count, color: Colors.blue, fontWeight: 700),
|
|
const Icon(Icons.chevron_right, color: Colors.blue, size: 24),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Obx(() {
|
|
final data = controller.pendingExpensesData.value;
|
|
|
|
if (controller.isPendingExpensesLoading.value) {
|
|
return SkeletonLoaders.expenseByStatusSkeletonLoader();
|
|
}
|
|
|
|
if (data == null) {
|
|
return Center(
|
|
child: MyText.bodyMedium("No expense status data available"),
|
|
);
|
|
}
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(5),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.grey.withOpacity(0.05),
|
|
blurRadius: 6,
|
|
spreadRadius: 1,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
MyText.titleMedium("Expense - By Status", fontWeight: 700),
|
|
const SizedBox(height: 16),
|
|
_buildStatusTile(
|
|
icon: Icons.currency_rupee,
|
|
color: Colors.blue,
|
|
title: "Pending Payment",
|
|
amount: Utils.formatCurrency(data.processPending.totalAmount),
|
|
count: data.processPending.count.toString(),
|
|
),
|
|
_buildStatusTile(
|
|
icon: Icons.check_circle_outline,
|
|
color: Colors.orange,
|
|
title: "Pending Approve",
|
|
amount: Utils.formatCurrency(data.approvePending.totalAmount),
|
|
count: data.approvePending.count.toString(),
|
|
),
|
|
_buildStatusTile(
|
|
icon: Icons.search,
|
|
color: Colors.grey.shade700,
|
|
title: "Pending Review",
|
|
amount: Utils.formatCurrency(data.reviewPending.totalAmount),
|
|
count: data.reviewPending.count.toString(),
|
|
),
|
|
_buildStatusTile(
|
|
icon: Icons.insert_drive_file_outlined,
|
|
color: Colors.cyan,
|
|
title: "Draft",
|
|
amount: Utils.formatCurrency(data.draft.totalAmount),
|
|
count: data.draft.count.toString(),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Divider(color: Colors.grey.shade300),
|
|
const SizedBox(height: 12),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
MyText.bodyMedium("Project Spendings:", fontWeight: 600),
|
|
MyText.bodySmall("(All Processed Payments)",
|
|
color: Colors.grey.shade600),
|
|
],
|
|
),
|
|
MyText.titleLarge(
|
|
"${Utils.formatCurrency(data.totalAmount)} >",
|
|
color: Colors.blue,
|
|
fontWeight: 700,
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|