10/17/1
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:location/location.dart';
|
|||||||
import 'package:ride/constant/box_name.dart';
|
import 'package:ride/constant/box_name.dart';
|
||||||
import 'package:ride/constant/links.dart';
|
import 'package:ride/constant/links.dart';
|
||||||
import 'package:ride/controller/functions/crud.dart';
|
import 'package:ride/controller/functions/crud.dart';
|
||||||
import 'package:ride/controller/home/captin/map_driver_controller.dart';
|
|
||||||
import 'package:ride/main.dart';
|
import 'package:ride/main.dart';
|
||||||
|
|
||||||
// LocationController.dart
|
// LocationController.dart
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class MapDriverController extends GetxController {
|
|||||||
late String durationToPassenger;
|
late String durationToPassenger;
|
||||||
late String walletChecked;
|
late String walletChecked;
|
||||||
late String direction;
|
late String direction;
|
||||||
|
late String durationOfRideValue;
|
||||||
late String status;
|
late String status;
|
||||||
bool isPassengerInfoWindow = false;
|
bool isPassengerInfoWindow = false;
|
||||||
bool isBtnRideBegin = false;
|
bool isBtnRideBegin = false;
|
||||||
@@ -50,7 +51,9 @@ class MapDriverController extends GetxController {
|
|||||||
bool isDriverNearPassengerStart = false;
|
bool isDriverNearPassengerStart = false;
|
||||||
GoogleMapController? mapController;
|
GoogleMapController? mapController;
|
||||||
late LatLng myLocation;
|
late LatLng myLocation;
|
||||||
|
int remainingTimeTimerRideBegin = 60;
|
||||||
|
String stringRemainingTimeRideBegin = '';
|
||||||
|
double progressTimerRideBegin = 0;
|
||||||
late Timer timer;
|
late Timer timer;
|
||||||
|
|
||||||
void onMapCreated(GoogleMapController controller) {
|
void onMapCreated(GoogleMapController controller) {
|
||||||
@@ -59,7 +62,7 @@ class MapDriverController extends GetxController {
|
|||||||
mapController = controller;
|
mapController = controller;
|
||||||
controller.getVisibleRegion();
|
controller.getVisibleRegion();
|
||||||
controller.animateCamera(
|
controller.animateCamera(
|
||||||
CameraUpdate.newLatLngZoom(myLocation, 10),
|
CameraUpdate.newLatLngZoom(myLocation, 15),
|
||||||
);
|
);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
@@ -173,12 +176,14 @@ class MapDriverController extends GetxController {
|
|||||||
isRideStarted = true;
|
isRideStarted = true;
|
||||||
isRideFinished = false;
|
isRideFinished = false;
|
||||||
box.write(BoxName.statusDriverLocation, 'on');
|
box.write(BoxName.statusDriverLocation, 'on');
|
||||||
|
|
||||||
update();
|
update();
|
||||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||||
'id': rideId,
|
'id': rideId,
|
||||||
'rideTimeStart': DateTime.now().toString(),
|
'rideTimeStart': DateTime.now().toString(),
|
||||||
'status': 'Begin'
|
'status': 'Begin'
|
||||||
});
|
});
|
||||||
|
rideIsBeginPassengerTimer();
|
||||||
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||||
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
||||||
}
|
}
|
||||||
@@ -204,6 +209,24 @@ class MapDriverController extends GetxController {
|
|||||||
// 'isRideFinished', box.read(BoxName.name).toString(), tokenPassenger);
|
// 'isRideFinished', box.read(BoxName.name).toString(), tokenPassenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rideIsBeginPassengerTimer() async {
|
||||||
|
// print('mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm');
|
||||||
|
// print(durationOfRideValue);
|
||||||
|
int durationOfRide = int.parse(durationOfRideValue);
|
||||||
|
|
||||||
|
for (int i = 0; i <= durationOfRide; i++) {
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
progressTimerRideBegin = i / durationOfRide;
|
||||||
|
remainingTimeTimerRideBegin = durationOfRide - i;
|
||||||
|
|
||||||
|
int minutes = (remainingTimeTimerRideBegin / 60).floor();
|
||||||
|
int seconds = remainingTimeTimerRideBegin % 60;
|
||||||
|
stringRemainingTimeRideBegin =
|
||||||
|
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateMarker() {
|
void updateMarker() {
|
||||||
// Remove the existing marker with the ID `MyLocation`.
|
// Remove the existing marker with the ID `MyLocation`.
|
||||||
markers.remove(MarkerId('MyLocation'.tr));
|
markers.remove(MarkerId('MyLocation'.tr));
|
||||||
@@ -310,6 +333,7 @@ class MapDriverController extends GetxController {
|
|||||||
direction = Get.arguments['direction'];
|
direction = Get.arguments['direction'];
|
||||||
durationToPassenger = Get.arguments['DurationToPassenger'];
|
durationToPassenger = Get.arguments['DurationToPassenger'];
|
||||||
rideId = Get.arguments['rideId'];
|
rideId = Get.arguments['rideId'];
|
||||||
|
durationOfRideValue = Get.arguments['durationOfRideValue'];
|
||||||
String lat = Get.find<LocationController>().myLocation.latitude.toString();
|
String lat = Get.find<LocationController>().myLocation.latitude.toString();
|
||||||
String lng = Get.find<LocationController>().myLocation.longitude.toString();
|
String lng = Get.find<LocationController>().myLocation.longitude.toString();
|
||||||
String origin = '$lat,$lng';
|
String origin = '$lat,$lng';
|
||||||
|
|||||||
@@ -308,7 +308,8 @@ class MapPassengerController extends GetxController {
|
|||||||
rideId,
|
rideId,
|
||||||
rideTimerBegin.toString(),
|
rideTimerBegin.toString(),
|
||||||
dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||||
.toString()
|
.toString(),
|
||||||
|
durationToRide.toString()
|
||||||
];
|
];
|
||||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||||
'Order',
|
'Order',
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ import 'package:ride/controller/home/captin/map_driver_controller.dart';
|
|||||||
import 'package:ride/main.dart';
|
import 'package:ride/main.dart';
|
||||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||||
|
|
||||||
import '../../../constant/links.dart';
|
|
||||||
import '../../../constant/style.dart';
|
import '../../../constant/style.dart';
|
||||||
import '../../../controller/functions/crud.dart';
|
|
||||||
import '../../../controller/functions/launch.dart';
|
import '../../../controller/functions/launch.dart';
|
||||||
|
|
||||||
class PassengerInfoWindow extends StatelessWidget {
|
class PassengerInfoWindow extends StatelessWidget {
|
||||||
|
|||||||
@@ -76,37 +76,71 @@ class PassengerLocationMapPage extends StatelessWidget {
|
|||||||
right: 5,
|
right: 5,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: AppStyle.boxDecoration,
|
decoration: AppStyle.boxDecoration,
|
||||||
height: 60,
|
height: 100,
|
||||||
width: 200,
|
width: 200,
|
||||||
child: Row(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.social_distance),
|
Column(
|
||||||
Text(
|
children: [
|
||||||
mapDriverController.distance.toString() +
|
const Icon(Icons.social_distance),
|
||||||
' ' +
|
Text(
|
||||||
'KM'.tr,
|
mapDriverController.distance.toString() +
|
||||||
style: AppStyle.title,
|
' ' +
|
||||||
|
'KM'.tr,
|
||||||
|
style: AppStyle.title,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mapDriverController
|
||||||
|
.remainingTimeTimerRideBegin <
|
||||||
|
60
|
||||||
|
? MyElevatedButton(
|
||||||
|
title: 'End Ride'.tr,
|
||||||
|
onPressed: () {
|
||||||
|
mapDriverController
|
||||||
|
.finishRideFromDriver();
|
||||||
|
},
|
||||||
|
kolor: AppColor.redColor,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.timelapse),
|
||||||
|
Text(
|
||||||
|
mapDriverController.duration
|
||||||
|
.toString() +
|
||||||
|
' ' +
|
||||||
|
'Minute'.tr,
|
||||||
|
style: AppStyle.title),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
MyElevatedButton(
|
Stack(
|
||||||
title: 'End Ride'.tr,
|
|
||||||
onPressed: () {
|
|
||||||
mapDriverController.finishRideFromDriver();
|
|
||||||
},
|
|
||||||
kolor: AppColor.redColor,
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.timelapse),
|
LinearProgressIndicator(
|
||||||
Text(
|
backgroundColor: AppColor.accentColor,
|
||||||
mapDriverController.duration.toString() +
|
color: mapDriverController
|
||||||
' ' +
|
.remainingTimeTimerRideBegin <
|
||||||
'Minute'.tr,
|
60
|
||||||
style: AppStyle.title),
|
? AppColor.redColor
|
||||||
|
: AppColor.greenColor,
|
||||||
|
minHeight: 40,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
value: mapDriverController
|
||||||
|
.progressTimerRideBegin
|
||||||
|
.toDouble(),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
mapDriverController
|
||||||
|
.stringRemainingTimeRideBegin,
|
||||||
|
style: AppStyle.title,
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ class OrderRequestPage extends StatelessWidget {
|
|||||||
'rideId': myList[16].toString(),
|
'rideId': myList[16].toString(),
|
||||||
'passengerId': myList[7].toString(),
|
'passengerId': myList[7].toString(),
|
||||||
'driverId': myList[18].toString(),
|
'driverId': myList[18].toString(),
|
||||||
|
'durationOfRideValue': myList[19].toString(),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user