11/25/1
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/controller/home/captin/order_request_controller.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/widgets/elevated_btn.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
|
||||
@@ -21,6 +26,7 @@ class HomeCaptainController extends GetxController {
|
||||
String totalMoneyInSEFER = '0';
|
||||
String totalDurationToday = '0';
|
||||
Timer? timer;
|
||||
String countRefuse = '0';
|
||||
bool mapType = false;
|
||||
bool mapTrafficON = false;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
@@ -55,6 +61,52 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void getRefusedOrderByCaptain() async {
|
||||
DateTime today = DateTime.now();
|
||||
int todayDay = today.day;
|
||||
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT COUNT(*) AS count
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
''';
|
||||
|
||||
try {
|
||||
List<Map<String, dynamic>> results =
|
||||
await sql.getCustomQuery(customQuery);
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3) {
|
||||
locationController.stopLocationUpdates();
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
savePeriod(activeDuration);
|
||||
activeDuration = Duration.zero;
|
||||
update();
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
title: 'You Are Stopped For this Day !'.tr,
|
||||
content: Text(
|
||||
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error executing custom query: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void changeMapType() {
|
||||
mapType = !mapType;
|
||||
// heightButtomSheetShown = isButtomSheetShown == true ? 240 : 0;
|
||||
@@ -110,6 +162,7 @@ class HomeCaptainController extends GetxController {
|
||||
getPaymentToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
getRefusedOrderByCaptain();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/Rate/rate_passenger.dart';
|
||||
import '../../../views/home/Captin/home_captin.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
@@ -49,8 +49,8 @@ class MapDriverController extends GetxController {
|
||||
double progress = 0;
|
||||
double progressToPassenger = 0;
|
||||
bool isRideBegin = false;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 15;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 15;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 20;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 20;
|
||||
int remainingTimeToPassenger = 60;
|
||||
bool isDriverNearPassengerStart = false;
|
||||
GoogleMapController? mapController;
|
||||
@@ -60,7 +60,7 @@ class MapDriverController extends GetxController {
|
||||
double progressTimerRideBegin = 0;
|
||||
late Timer timer;
|
||||
String? mapAPIKEY;
|
||||
|
||||
final zones = <Zone>[];
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
myLocation = locationController.myLocation;
|
||||
|
||||
@@ -8,14 +8,15 @@ import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
|
||||
class OrderRequestController extends GetxController {
|
||||
double progress = 0;
|
||||
int duration = 15;
|
||||
int duration = 20;
|
||||
int remainingTime = 0;
|
||||
String countRefuse = '0';
|
||||
bool applied = false;
|
||||
|
||||
final locationController = Get.put(LocationController());
|
||||
@override
|
||||
void onInit() {
|
||||
getRefusedOrderByCaptain();
|
||||
@@ -47,6 +48,7 @@ class OrderRequestController extends GetxController {
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3) {
|
||||
locationController.stopLocationUpdates();
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../constant/style.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
import '../home_captain_controller.dart';
|
||||
import '../order_request_controller.dart';
|
||||
|
||||
@@ -19,7 +21,23 @@ class ConnectWidget extends StatelessWidget {
|
||||
int.parse(orderRequestController.countRefuse) > 3
|
||||
? CupertinoButton(
|
||||
child: Text('You are Stopped'.tr),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
title: 'You Are Stopped For this Day !'.tr,
|
||||
content: Text(
|
||||
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
},
|
||||
color: CupertinoColors.destructiveRed,
|
||||
)
|
||||
: CupertinoButton(
|
||||
|
||||
@@ -13,6 +13,24 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
left: 6,
|
||||
child: Column(
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
FontAwesome.map_signs,
|
||||
size: 24,
|
||||
color: Colors.black,
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:ride/views/home/map_page_passenger.dart';
|
||||
import '../../constant/api_key.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/info.dart';
|
||||
@@ -359,9 +360,21 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
startTimer();
|
||||
} else if (decod['data'].toString() == 'Refused') {
|
||||
carsOrder++;
|
||||
update();
|
||||
changeConfirmRide();
|
||||
if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||
carsOrder++;
|
||||
update();
|
||||
changeConfirmRide();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title: 'There no Captain Aplly your order sorry for that '.tr,
|
||||
middleText: 'try next time .',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () => Get.offAll(const MapPagePassenger()),
|
||||
));
|
||||
|
||||
// cancelRide();
|
||||
}
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
@@ -443,8 +456,11 @@ class MapPassengerController extends GetxController {
|
||||
noCarString = false;
|
||||
dataCarsLocationByPassenger = jsonDecode(res);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||
.toString();
|
||||
// }
|
||||
|
||||
// print('driverId==============$driverId');
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../onbording_page.dart';
|
||||
import '../../views/auth/captin/login_captin.dart';
|
||||
import '../../views/home/Captin/home_captin.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/map_page_passenger.dart';
|
||||
|
||||
class SplashScreenController extends GetxController
|
||||
|
||||
Reference in New Issue
Block a user