This commit is contained in:
Hamza-Ayed
2024-05-29 16:09:37 +03:00
parent 058fb67a41
commit 4af52f4392
44 changed files with 9509 additions and 2044 deletions

View File

@@ -12,15 +12,42 @@ class DurationController extends GetxController {
final data = DurationData;
// late AnimationController animationController;
late List<MonthlyDataModel> rideData;
late List<MonthlyRideModel> rideCountData;
late List<MonthlyPriceDriverModel> ridePriceDriverData;
Map<String, dynamic> jsonData1 = {};
Map<String, dynamic> jsonData2 = {};
bool isLoading = false;
String totalDurationToday = '';
var chartData;
var chartRideCount;
var chartRidePriceDriver;
List monthlyList = [];
@override
void onInit() async {
super.onInit();
await fetchData();
await fetchRideDriver();
await getStaticDriver();
}
getStaticDriver() async {
isLoading = true;
update();
var res = await CRUD().get(
link: AppLink.driverStatistic,
payload: {'driverID': box.read(BoxName.driverID)});
if (res == 'failure') {
monthlyList = [];
print('monthlyList $monthlyList');
isLoading = false;
update();
} else {
monthlyList = jsonDecode(res)['message'];
print(monthlyList);
isLoading = false;
update();
}
}
Future<void> fetchData() async {
@@ -50,6 +77,44 @@ class DurationController extends GetxController {
update(); // Notify the observers about the data and loading state change
}
Future<void> fetchRideDriver() async {
isLoading = true;
update(); // Notify the observers about the loading state change
var res = await CRUD().get(
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();
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
}
List<DurationData> parseData(List<dynamic> json) {
return json.map((entry) {
final Map<String, dynamic> entryMap = entry;

View File

@@ -445,11 +445,12 @@ class MapDriverController extends GetxController {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
totalCost = carType != 'Comfort' && carType != 'Mashwari'
? totalPassenger
: price < double.parse(totalPassenger)
totalCost =
carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
? totalPassenger
: price.toStringAsFixed(2);
: price < double.parse(totalPassenger)
? totalPassenger
: price.toStringAsFixed(2);
paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger();
@@ -574,14 +575,18 @@ class MapDriverController extends GetxController {
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().speedPrice)
: carType == 'Mashwari'
: carType == 'Lady'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().deliveryPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.mashwariPrice); // $1 for each minute + $4 for each km
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Mashwari'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().deliveryPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.mashwariPrice); // $1 for each minute + $4 for each km
price = (price * .10) + price; // Add 10% tax
speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide;
@@ -827,6 +832,8 @@ class MapDriverController extends GetxController {
int minutes = 0;
late String carType;
late String kazan;
late String startNameLocation;
late String endNameLocation;
@override
void onInit() async {
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
@@ -860,6 +867,8 @@ class MapDriverController extends GetxController {
timeOfOrder = Get.arguments['timeOfOrder'];
carType = Get.arguments['carType'];
kazan = Get.arguments['kazan'];
startNameLocation = Get.arguments['startNameLocation'];
endNameLocation = Get.arguments['endNameLocation'];
var coords = passengerLocation.split(',');
var coordDestination = passengerDestination.split(',');

View File

@@ -42,18 +42,18 @@ class SplashScreenController extends GetxController
startTimer();
}
void startTimer() {
Timer(const Duration(seconds: 5), () {
void startTimer() async {
debugPrint('onBoarding: ${box.read(BoxName.onBoarding)}');
debugPrint('emailDriver: ${box.read(BoxName.emailDriver)}');
debugPrint('phoneDriver: ${box.read(BoxName.phoneDriver)}');
debugPrint('phoneVerified: ${box.read(BoxName.phoneVerified)}');
Timer(const Duration(seconds: 5), () async {
box.read(BoxName.onBoarding) == null
? Get.off(() => OnBoardingPage())
: box.read(BoxName.emailDriver) != null
// todo
&&
: box.read(BoxName.emailDriver) != null &&
box.read(BoxName.phoneDriver) != null &&
box.read(BoxName.phoneVerified) == '1'
// ? Get.off(() => SmsSignupEgypt())
// ? Get.off(() => HomeCaptain())
? Get.put(LoginCaptinController()).loginFromSignInGoogle(
? await Get.put(LoginCaptinController()).loginFromSignInGoogle(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver))
: Get.off(() => LoginCaptin());