5/29/3
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:SEFER/constant/info.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:SEFER/views/widgets/mycircular.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../controller/home/captin/duration_controller .dart';
|
||||
|
||||
class RideCalculateDriver extends StatelessWidget {
|
||||
@@ -22,83 +23,269 @@ class RideCalculateDriver extends StatelessWidget {
|
||||
child: GetBuilder<DurationController>(
|
||||
builder: (durationController) => durationController.isLoading
|
||||
? const Center(child: MyCircularProgressIndicator())
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
: ListView(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'${'Average of Hours of'.tr} ${AppInformation.appName}${' is ON for this month'.tr}${' ${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}'.tr}',
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: Get.height * .4,
|
||||
child: LineChart(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.ease,
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: durationController.chartData,
|
||||
isCurved: true,
|
||||
color: Colors.deepPurpleAccent, // Custom color
|
||||
barWidth: 3, // Thinner line
|
||||
dotData: const FlDotData(
|
||||
show: true), // Show dots on each point
|
||||
belowBarData: BarAreaData(
|
||||
// Add gradient fill below the line
|
||||
show: true,
|
||||
color: AppColor.deepPurpleAccent,
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
height: Get.height * .4,
|
||||
child: LineChart(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.ease,
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
isStepLineChart: true,
|
||||
spots: durationController.chartData,
|
||||
isCurved: true,
|
||||
color:
|
||||
Colors.deepPurpleAccent, // Custom color
|
||||
barWidth: 3, // Thinner line
|
||||
dotData: const FlDotData(
|
||||
show: true), // Show dots on each point
|
||||
belowBarData: BarAreaData(
|
||||
// Add gradient fill below the line
|
||||
show: true,
|
||||
color: AppColor.deepPurpleAccent,
|
||||
),
|
||||
isStrokeJoinRound: true,
|
||||
shadow: const BoxShadow(
|
||||
color: AppColor.yellowColor,
|
||||
blurRadius: 4,
|
||||
offset: Offset(2, 2),
|
||||
),
|
||||
),
|
||||
isStrokeJoinRound: true,
|
||||
shadow: const BoxShadow(
|
||||
color: AppColor.yellowColor,
|
||||
blurRadius: 4,
|
||||
offset: Offset(2, 2),
|
||||
),
|
||||
),
|
||||
],
|
||||
showingTooltipIndicators: const [],
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
topTitles: AxisTitles(
|
||||
],
|
||||
showingTooltipIndicators: const [],
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
topTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
bottomTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Total Hours on month'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
leftTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Counts of Hours on days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
),
|
||||
gridData: const FlGridData(
|
||||
show: true,
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: AppColor.accentColor),
|
||||
left: BorderSide(color: AppColor.accentColor),
|
||||
),
|
||||
bottomTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Total Hours on month'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
leftTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Counts of Hours on days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
),
|
||||
gridData: const FlGridData(
|
||||
show: true,
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom:
|
||||
BorderSide(color: AppColor.accentColor),
|
||||
left: BorderSide(color: AppColor.accentColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
height: Get.height * .4,
|
||||
child: LineChart(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.ease,
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: durationController.chartRideCount,
|
||||
// isCurved: true,
|
||||
color:
|
||||
Colors.deepPurpleAccent, // Custom color
|
||||
barWidth: 3, // Thinner line
|
||||
dotData: const FlDotData(
|
||||
show: true), // Show dots on each point
|
||||
belowBarData: BarAreaData(
|
||||
// Add gradient fill below the line
|
||||
show: true,
|
||||
color: AppColor.deepPurpleAccent,
|
||||
),
|
||||
isStrokeJoinRound: true,
|
||||
shadow: const BoxShadow(
|
||||
color: AppColor.yellowColor,
|
||||
blurRadius: 4,
|
||||
offset: Offset(2, 2),
|
||||
),
|
||||
),
|
||||
],
|
||||
showingTooltipIndicators: const [],
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
topTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
// sideTitles: const SideTitles(
|
||||
// reservedSize: 30, showTitles: true),
|
||||
),
|
||||
bottomTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'${"Total rides on month".tr} = ${durationController.jsonData2['message'][0]['totalCount'].toString()}'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
leftTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Counts of rides on days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
),
|
||||
gridData: const FlGridData(
|
||||
show: true,
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom:
|
||||
BorderSide(color: AppColor.accentColor),
|
||||
left: BorderSide(color: AppColor.accentColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
height: Get.height * .4,
|
||||
child: LineChart(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.ease,
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
isStepLineChart: true,
|
||||
spots:
|
||||
durationController.chartRidePriceDriver,
|
||||
isCurved: true,
|
||||
isStrokeCapRound: true,
|
||||
preventCurveOverShooting: true,
|
||||
color:
|
||||
Colors.deepPurpleAccent, // Custom color
|
||||
barWidth: 3, // Thinner line
|
||||
dotData: const FlDotData(
|
||||
show: true), // Show dots on each point
|
||||
belowBarData: BarAreaData(
|
||||
// Add gradient fill below the line
|
||||
show: true,
|
||||
color: AppColor.deepPurpleAccent,
|
||||
),
|
||||
isStrokeJoinRound: true,
|
||||
shadow: const BoxShadow(
|
||||
color: AppColor.yellowColor,
|
||||
blurRadius: 4,
|
||||
offset: Offset(2, 2),
|
||||
),
|
||||
),
|
||||
],
|
||||
showingTooltipIndicators: const [],
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
topTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
// sideTitles: const SideTitles(
|
||||
// reservedSize: 30, showTitles: true),
|
||||
),
|
||||
bottomTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'${"Total rides on month".tr} = ${durationController.jsonData2['message'][0]['totalCount'].toString()}'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
leftTitles: AxisTitles(
|
||||
axisNameWidget: Text(
|
||||
'Counts of rides on days'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
axisNameSize: 30,
|
||||
sideTitles: const SideTitles(
|
||||
reservedSize: 30, showTitles: true)),
|
||||
),
|
||||
gridData: const FlGridData(
|
||||
show: true,
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom:
|
||||
BorderSide(color: AppColor.accentColor),
|
||||
left: BorderSide(color: AppColor.accentColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: durationController.monthlyList.isEmpty
|
||||
? SizedBox(
|
||||
height: Get.height * .2,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No data yet".tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
)
|
||||
: DriverStatsTable(
|
||||
monthlyList:
|
||||
durationController.monthlyList,
|
||||
)))
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -109,103 +296,172 @@ class RideCalculateDriver extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// class BarChartWidget extends StatelessWidget {
|
||||
// const BarChartWidget({super.key});
|
||||
class DriverStatsTable extends StatelessWidget {
|
||||
final List monthlyList;
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final durationController = Get.put(DurationController());
|
||||
// return Obx(() {
|
||||
// final data = durationController.data;
|
||||
// double maxDuration = 0;
|
||||
const DriverStatsTable({Key? key, required this.monthlyList})
|
||||
: super(key: key);
|
||||
|
||||
// // Find the maximum duration to determine the maximum height of the bars
|
||||
// for (final entry in data) {
|
||||
// final durationInHours = entry.totalDuration.inHours.toDouble();
|
||||
// if (durationInHours > maxDuration) {
|
||||
// maxDuration = durationInHours;
|
||||
// }
|
||||
// }
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: DataTable(
|
||||
columnSpacing: 12,
|
||||
columns: [
|
||||
DataColumn(label: Text('Statistic'.tr)),
|
||||
DataColumn(label: Text('Value'.tr)),
|
||||
],
|
||||
rows: _buildRows(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// return durationController.isLoading
|
||||
// ? const Center(
|
||||
// child: MyCircularProgressIndicator(),
|
||||
// )
|
||||
// : Column(
|
||||
// children: [
|
||||
// Text(
|
||||
// 'Average of Hours of ${AppInformation.appName} is ON for this month'
|
||||
// .tr,
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Container(
|
||||
// height: Get.height * .7,
|
||||
// decoration: AppStyle.boxDecoration,
|
||||
// child: ListView.builder(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// itemCount: data.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final entry = data[index];
|
||||
// final durationInHours =
|
||||
// entry.totalDuration.inHours.toDouble();
|
||||
// final dayLabel = entry.day.day.toString();
|
||||
List<DataRow> _buildRows() {
|
||||
return [
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Total Orders'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
monthlyList[0]['total_orders'].toString(),
|
||||
style: AppStyle.number,
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Completed'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
monthlyList[0]['completed_orders'].toString(),
|
||||
style: AppStyle.number,
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Canceled Orders'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
monthlyList[0]['canceled_orders'].toString(),
|
||||
style: AppStyle.number,
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Rejected Orders'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
monthlyList[0]['rejected_orders'].toString(),
|
||||
style: AppStyle.number,
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Percent Rejected'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
'${(monthlyList[0]['percent_rejected']).toString()}%',
|
||||
style: AppStyle.number.copyWith(
|
||||
color: double.parse(monthlyList[0]['percent_canceled']) < .3
|
||||
? AppColor.greenColor
|
||||
: AppColor.redColor),
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Percent Canceled'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
'${(monthlyList[0]['percent_canceled']).toString()}%',
|
||||
style: AppStyle.number.copyWith(
|
||||
color: double.parse(monthlyList[0]['percent_canceled']) < .3
|
||||
? AppColor.greenColor
|
||||
: AppColor.redColor),
|
||||
)),
|
||||
]),
|
||||
DataRow(cells: [
|
||||
DataCell(Text(
|
||||
'Percent Completed'.tr,
|
||||
style: AppStyle.title,
|
||||
)),
|
||||
DataCell(Text(
|
||||
'${(monthlyList[0]['percent_completed']).toString()}%',
|
||||
style: AppStyle.number.copyWith(
|
||||
color: double.parse(monthlyList[0]['percent_completed']) > .7
|
||||
? AppColor.greenColor
|
||||
: AppColor.redColor),
|
||||
)),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
// child: AnimatedBuilder(
|
||||
// // animation: durationController.animationController,
|
||||
// builder: (context, child) {
|
||||
// final animationValue =
|
||||
// durationController.animationController.value;
|
||||
// final animatedValue =
|
||||
// (durationInHours / maxDuration) *
|
||||
// animationValue;
|
||||
class StaticDriverOrder extends StatelessWidget {
|
||||
const StaticDriverOrder({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.jsonTitle,
|
||||
}) : super(key: key);
|
||||
|
||||
// return Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// Transform(
|
||||
// transform: Matrix4.identity()
|
||||
// ..setEntry(3, 2,
|
||||
// 0.001) // Apply perspective for a 3D effect
|
||||
// ..rotateX(-0.5 *
|
||||
// animatedValue), // Rotate around X-axis
|
||||
// alignment: Alignment.bottomCenter,
|
||||
// child: Container(
|
||||
// width: 20,
|
||||
// height:
|
||||
// (durationInHours / maxDuration) * 400,
|
||||
// color: durationInHours > 8
|
||||
// ? AppColor.greenColor
|
||||
// : AppColor.yellowColor,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// durationInHours.toStringAsFixed(
|
||||
// 0,
|
||||
// ), // Display the duration value inside the bar
|
||||
// style: const TextStyle(
|
||||
// color: Colors.white,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 4),
|
||||
// Text(dayLabel),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
final String title, jsonTitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 3,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8.0),
|
||||
Text(
|
||||
jsonTitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user