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

@@ -15,27 +15,36 @@ class BehaviorPage extends StatelessWidget {
return Scaffold(
backgroundColor: FinanceDesignSystem.backgroundColor,
appBar: AppBar(
title: Text('Driver Behavior'.tr, style: const TextStyle(fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
title: Text('Driver Behavior'.tr,
style: TextStyle(
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
centerTitle: true,
backgroundColor: FinanceDesignSystem.cardColor,
elevation: 0,
iconTheme: const IconThemeData(color: FinanceDesignSystem.primaryDark),
iconTheme: IconThemeData(color: FinanceDesignSystem.primaryDark),
),
body: Obx(() {
if (controller.isLoading.value) {
return const Center(child: CircularProgressIndicator(color: FinanceDesignSystem.accentBlue));
return Center(
child: CircularProgressIndicator(
color: FinanceDesignSystem.accentBlue));
}
double score = controller.overallScore.value;
bool isExcellent = score >= 90;
bool isGood = score >= 75 && score < 90;
Color statusColor = isExcellent ? Colors.green : (isGood ? Colors.orange : Colors.red);
String statusText = isExcellent ? 'Excellent'.tr : (isGood ? 'Good'.tr : 'Needs Improvement'.tr);
Color statusColor =
isExcellent ? Colors.green : (isGood ? Colors.orange : Colors.red);
String statusText = isExcellent
? 'Excellent'.tr
: (isGood ? 'Good'.tr : 'Needs Improvement'.tr);
return CustomScrollView(
slivers: [
SliverPadding(
padding: const EdgeInsets.all(FinanceDesignSystem.horizontalPadding),
padding:
const EdgeInsets.all(FinanceDesignSystem.horizontalPadding),
sliver: SliverList(
delegate: SliverChildListDelegate([
// Overall Score Card
@@ -44,11 +53,17 @@ class BehaviorPage extends StatelessWidget {
decoration: BoxDecoration(
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(24),
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 10, offset: Offset(0, 4))],
boxShadow: const [
BoxShadow(
color: Colors.black12,
blurRadius: 10,
offset: Offset(0, 4))
],
),
child: Column(
children: [
Icon(Icons.shield_rounded, size: 48, color: statusColor),
Icon(Icons.shield_rounded,
size: 48, color: statusColor),
const SizedBox(height: 16),
Text(
"Overall Behavior Score".tr,
@@ -65,33 +80,41 @@ class BehaviorPage extends StatelessWidget {
),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 6),
decoration: BoxDecoration(
color: statusColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(20),
),
child: Text(
statusText,
style: TextStyle(color: statusColor, fontWeight: FontWeight.bold),
style: TextStyle(
color: statusColor,
fontWeight: FontWeight.bold),
),
),
],
),
),
const SizedBox(height: 30),
Text("Last 10 Trips".tr, style: FinanceDesignSystem.headingStyle),
Text("Last 10 Trips".tr,
style: FinanceDesignSystem.headingStyle),
const SizedBox(height: 16),
]),
),
),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: FinanceDesignSystem.horizontalPadding),
padding: const EdgeInsets.symmetric(
horizontal: FinanceDesignSystem.horizontalPadding),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
var trip = controller.lastTrips[index];
double tripScore = double.tryParse(trip['behavior_score'].toString()) ?? 0;
Color tColor = tripScore >= 90 ? Colors.green : (tripScore >= 75 ? Colors.orange : Colors.red);
double tripScore =
double.tryParse(trip['behavior_score'].toString()) ?? 0;
Color tColor = tripScore >= 90
? Colors.green
: (tripScore >= 75 ? Colors.orange : Colors.red);
return Container(
margin: const EdgeInsets.only(bottom: 12),
@@ -118,7 +141,8 @@ class BehaviorPage extends StatelessWidget {
),
title: Text(
"Trip ID: ${trip['trip_id']}",
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 16),
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 8.0),
@@ -126,9 +150,16 @@ class BehaviorPage extends StatelessWidget {
spacing: 12,
runSpacing: 8,
children: [
_buildBadge(Icons.speed, "${trip['max_speed']} km/h", Colors.blue),
_buildBadge(Icons.warning_amber_rounded, "${trip['hard_brakes']} ${'Hard Brakes'.tr}", Colors.orange),
_buildBadge(Icons.map_rounded, "${trip['total_distance']} km", Colors.purple),
_buildBadge(Icons.speed,
"${trip['max_speed']} km/h", Colors.blue),
_buildBadge(
Icons.warning_amber_rounded,
"${trip['hard_brakes']} ${'Hard Brakes'.tr}",
Colors.orange),
_buildBadge(
Icons.map_rounded,
"${trip['total_distance']} km",
Colors.purple),
],
),
),
@@ -137,9 +168,14 @@ class BehaviorPage extends StatelessWidget {
children: [
Text(
"${tripScore.toStringAsFixed(0)}",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: tColor),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: tColor),
),
Text('Score'.tr, style: const TextStyle(fontSize: 10, color: Colors.grey)),
Text('Score'.tr,
style: const TextStyle(
fontSize: 10, color: Colors.grey)),
],
),
),
@@ -168,7 +204,9 @@ class BehaviorPage extends StatelessWidget {
children: [
Icon(icon, size: 14, color: color),
const SizedBox(width: 4),
Text(label, style: TextStyle(fontSize: 12, color: color, fontWeight: FontWeight.w600)),
Text(label,
style: TextStyle(
fontSize: 12, color: color, fontWeight: FontWeight.w600)),
],
),
);