This commit is contained in:
Hamza-Ayed
2024-06-05 21:53:17 +03:00
parent 22487e138d
commit a3d3090a15
22 changed files with 633 additions and 539 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
@@ -85,34 +86,46 @@ class DurationController extends GetxController {
link: AppLink.getRidesDriverByDay,
payload: {'driver_id': box.read(BoxName.driverID)},
);
jsonData2 = jsonDecode(res);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
// print(jsonResponse);
final List<dynamic> jsonData = jsonResponse['message'];
rideCountData = jsonData.map<MonthlyRideModel>((item) {
return MonthlyRideModel.fromJson(item);
}).toList();
ridePriceDriverData = jsonData.map<MonthlyPriceDriverModel>((item) {
return MonthlyPriceDriverModel.fromJson(item);
}).toList();
if (res != 'failure') {
jsonData2 = jsonDecode(res);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
// print(jsonResponse);
final List<dynamic> jsonData = jsonResponse['message'];
rideCountData = jsonData.map<MonthlyRideModel>((item) {
return MonthlyRideModel.fromJson(item);
}).toList();
ridePriceDriverData = jsonData.map<MonthlyPriceDriverModel>((item) {
return MonthlyPriceDriverModel.fromJson(item);
}).toList();
final List<FlSpot> spots = rideCountData
.map((data) => FlSpot(
data.day.toDouble(),
data.countRide.toDouble(),
))
.toList();
chartRideCount = spots;
final List<FlSpot> spotsDriverPrices = ridePriceDriverData
.map((data) => FlSpot(
data.day.toDouble(),
data.pricePerDay.toDouble(),
))
.toList();
chartRidePriceDriver = spotsDriverPrices;
final List<FlSpot> spots = rideCountData
.map((data) => FlSpot(
data.day.toDouble(),
data.countRide.toDouble(),
))
.toList();
chartRideCount = spots;
final List<FlSpot> spotsDriverPrices = ridePriceDriverData
.map((data) => FlSpot(
data.day.toDouble(),
data.pricePerDay.toDouble(),
))
.toList();
chartRidePriceDriver = spotsDriverPrices;
update(); // Notify the observers about the data and loading state change
update(); // Notify the observers about the data and loading state change
} else {
Get.defaultDialog(
title: 'No data yet!'.tr,
middleText: '',
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {
Get.back();
Get.back();
}));
}
}
List<DurationData> parseData(List<dynamic> json) {