add new featurs like new stat page

This commit is contained in:
Hamza-Ayed
2026-05-08 22:44:55 +03:00
parent efbc921273
commit 8f555691b9
33 changed files with 1194 additions and 585 deletions

View File

@@ -1,9 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:sefer_driver/constant/colors.dart';
import 'package:sefer_driver/constant/style.dart';
import 'package:get/get.dart';
import 'package:sefer_driver/constant/finance_design_system.dart';
import 'package:sefer_driver/views/widgets/mycircular.dart';
import '../../../controller/payment/driver_payment_controller.dart';
@@ -20,12 +17,15 @@ class WeeklyPaymentPage extends StatelessWidget {
backgroundColor: FinanceDesignSystem.backgroundColor,
appBar: AppBar(
title: Text('Weekly Summary'.tr,
style: const TextStyle(fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
style: TextStyle(
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios_new_rounded, color: FinanceDesignSystem.primaryDark, size: 20),
icon: Icon(Icons.arrow_back_ios_new_rounded,
color: FinanceDesignSystem.primaryDark, size: 20),
onPressed: () => Get.back(),
),
),
@@ -45,9 +45,11 @@ class WeeklyPaymentPage extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text('Transactions this week'.tr, style: FinanceDesignSystem.headingStyle),
Text('Transactions this week'.tr,
style: FinanceDesignSystem.headingStyle),
const Spacer(),
Icon(Icons.list_rounded, color: Colors.grey.shade400, size: 20),
Icon(Icons.list_rounded,
color: Colors.grey.shade400, size: 20),
],
),
),
@@ -61,7 +63,9 @@ class WeeklyPaymentPage extends StatelessWidget {
itemCount: controller.weeklyList.length,
itemBuilder: (BuildContext context, int index) {
final tx = controller.weeklyList[index];
final double amount = double.tryParse(tx['amount']?.toString() ?? '0') ?? 0;
final double amount = double.tryParse(
tx['amount']?.toString() ?? '0') ??
0;
return AnimationConfiguration.staggeredList(
position: index,
duration: const Duration(milliseconds: 250),
@@ -69,10 +73,12 @@ class WeeklyPaymentPage extends StatelessWidget {
verticalOffset: 25,
child: FadeInAnimation(
child: TransactionPreviewItem(
title: amount >= 0 ? 'Credit'.tr : 'Debit'.tr,
title:
amount >= 0 ? 'Credit'.tr : 'Debit'.tr,
subtitle: tx['dateUpdated'] ?? '',
amount: amount.abs().toStringAsFixed(0),
date: tx['dateUpdated']?.split(' ')[0] ?? '',
date:
tx['dateUpdated']?.split(' ')[0] ?? '',
type: amount >= 0 ? 'credit' : 'debit',
method: tx['paymentMethod'],
onTap: () {},
@@ -95,7 +101,7 @@ class WeeklyPaymentPage extends StatelessWidget {
final totalAmount = controller.weeklyList.isEmpty
? '0.00'
: controller.weeklyList[0]['totalAmount']?.toString() ?? '0.00';
final double earnings = double.tryParse(totalAmount) ?? 0;
final int trips = controller.weeklyList.length;
final double commission = earnings * 0.15; // Example 15%
@@ -109,7 +115,7 @@ class WeeklyPaymentPage extends StatelessWidget {
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: FinanceDesignSystem.primaryDark.withOpacity(0.3),
color: FinanceDesignSystem.primaryDark.withValues(alpha: 0.3),
blurRadius: 20,
offset: const Offset(0, 8),
),
@@ -118,17 +124,24 @@ class WeeklyPaymentPage extends StatelessWidget {
child: Column(
children: [
Text('Total Weekly Earnings'.tr,
style: TextStyle(color: Colors.white.withOpacity(0.8), fontSize: 14)),
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8), fontSize: 14)),
const SizedBox(height: 8),
Text('${earnings.toStringAsFixed(0)} SYP',
style: const TextStyle(color: Colors.white, fontSize: 36, fontWeight: FontWeight.bold)),
style: const TextStyle(
color: Colors.white,
fontSize: 36,
fontWeight: FontWeight.bold)),
const SizedBox(height: 24),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildStatItem('Total Trips'.tr, trips.toString(), Icons.directions_car_rounded),
_buildStatItem('Commission'.tr, '${commission.toStringAsFixed(0)}', Icons.percent_rounded),
_buildStatItem('Net Profit'.tr, '${netProfit.toStringAsFixed(0)}', Icons.account_balance_rounded),
_buildStatItem('Total Trips'.tr, trips.toString(),
Icons.directions_car_rounded),
_buildStatItem('Commission'.tr, commission.toStringAsFixed(0),
Icons.percent_rounded),
_buildStatItem('Net Profit'.tr, netProfit.toStringAsFixed(0),
Icons.account_balance_rounded),
],
),
],
@@ -141,12 +154,20 @@ class WeeklyPaymentPage extends StatelessWidget {
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.circular(10)),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(10)),
child: Icon(icon, color: Colors.white, size: 18),
),
const SizedBox(height: 8),
Text(value, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14)),
Text(label, style: TextStyle(color: Colors.white.withOpacity(0.6), fontSize: 10)),
Text(value,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14)),
Text(label,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.6), fontSize: 10)),
],
);
}
@@ -159,18 +180,27 @@ class WeeklyPaymentPage extends StatelessWidget {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.02), blurRadius: 10)],
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.02), blurRadius: 10)
],
),
child: Row(
children: [
IconButton(icon: const Icon(Icons.chevron_left_rounded), onPressed: () {}),
IconButton(
icon: const Icon(Icons.chevron_left_rounded), onPressed: () {}),
Expanded(
child: Center(
child: Text('Dec 15 - Dec 21, 2024'.tr,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: FinanceDesignSystem.primaryDark)),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: FinanceDesignSystem.primaryDark)),
),
),
IconButton(icon: const Icon(Icons.chevron_right_rounded), onPressed: () {}),
IconButton(
icon: const Icon(Icons.chevron_right_rounded),
onPressed: () {}),
],
),
),
@@ -184,7 +214,9 @@ class WeeklyPaymentPage extends StatelessWidget {
children: [
Icon(Icons.bar_chart_rounded, size: 64, color: Colors.grey.shade300),
const SizedBox(height: 16),
Text('No transactions this week'.tr, style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.grey)),
Text('No transactions this week'.tr,
style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.grey)),
],
),
);