This commit is contained in:
Hamza-Ayed
2024-08-11 13:22:36 +03:00
parent 9976a1abea
commit 9f93c88b4d
33 changed files with 2896 additions and 368 deletions

View File

@@ -10,8 +10,11 @@ import '../functions/crud.dart';
class StaticController extends GetxController {
Map<String, dynamic> jsonData1 = {};
Map<String, dynamic> jsonData2 = {};
List staticList = [];
var chartDataPassengers;
var chartDataDrivers;
var chartDataDriversCalling;
var chartDataDriversMatchingNotes;
bool isLoading = false;
String totalMonthlyPassengers = '';
String totalMonthlyDrivers = '';
@@ -57,17 +60,32 @@ class StaticController extends GetxController {
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
final List<dynamic> jsonData = jsonResponse['message'];
totalMonthlyDrivers = jsonData[0]['totalMonthly'].toString();
staticList = jsonData;
totalMonthlyDrivers = jsonData[0]['totalDrivers'].toString();
driversData = jsonData.map<MonthlyDriverInstall>((item) {
return MonthlyDriverInstall.fromJson(item);
}).toList();
final List<FlSpot> spots = driversData
.map((data) => FlSpot(
data.day.toDouble(),
data.totalDrivers.toDouble(),
data.dailyTotalDrivers.toDouble(),
))
.toList();
chartDataDrivers = spots;
final List<FlSpot> spotsCalling = driversData
.map((data) => FlSpot(
data.day.toDouble(),
data.dailyTotalCallingDrivers.toDouble(),
))
.toList();
chartDataDriversCalling = spotsCalling;
final List<FlSpot> spotsTotalMatchingNotes = driversData
.map((data) => FlSpot(
data.day.toDouble(),
data.dailyMatchingNotes.toDouble(),
))
.toList();
chartDataDriversMatchingNotes = spotsTotalMatchingNotes;
update(); // Notify the observers about the data and loading state change
}