12/31/2
This commit is contained in:
@@ -13,11 +13,6 @@ import '../../constant/style.dart';
|
|||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
import '../../views/home/profile/promos_passenger_page.dart';
|
import '../../views/home/profile/promos_passenger_page.dart';
|
||||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||||
import '../../views/widgets/elevated_btn.dart';
|
|
||||||
import '../functions/crud.dart';
|
|
||||||
import '../functions/launch.dart';
|
|
||||||
import '../home/captin/map_driver_controller.dart';
|
|
||||||
import '../home/map_passenger_controller.dart';
|
|
||||||
|
|
||||||
class FirebaseMessagesController extends GetxController {
|
class FirebaseMessagesController extends GetxController {
|
||||||
final fcmToken = FirebaseMessaging.instance;
|
final fcmToken = FirebaseMessaging.instance;
|
||||||
@@ -203,19 +198,19 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
}
|
}
|
||||||
// If the app is in the background or terminated, show a system tray message
|
// If the app is in the background or terminated, show a system tray message
|
||||||
RemoteNotification? notification = message.notification;
|
RemoteNotification? notification = message.notification;
|
||||||
AndroidNotification? android = message.notification?.android;
|
AndroidNotification? android = notification?.android;
|
||||||
// if (notification != null && android != null) {
|
// if (notification != null && android != null) {
|
||||||
if (notification != null && android != null) {
|
if (notification != null && android != null) {
|
||||||
print('onMessageOpenedApp: ${notification.title} ${notification.body}');
|
// print('onMessageOpenedApp: ${notification.title} ${notification.body}');
|
||||||
if (message.data.isNotEmpty) {
|
if (message.data.isNotEmpty) {
|
||||||
if (message.notification!.title!.contains('Order')) {
|
if (message.notification!.title!.contains('Order')) {
|
||||||
var myListString = message.data['DriverList'];
|
var myListString = message.data['DriverList'];
|
||||||
print(myListString);
|
// print(myListString);
|
||||||
print('9999999999999myListString999999999999999');
|
// print('9999999999999myListString999999999999999');
|
||||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||||
driverToken = myList[14].toString();
|
driverToken = myList[14].toString();
|
||||||
update();
|
update();
|
||||||
print('driverToken==============$driverToken');
|
// print('driverToken==============$driverToken');
|
||||||
Get.to(() => OrderRequestPage(), arguments: {
|
Get.to(() => OrderRequestPage(), arguments: {
|
||||||
'myListString': myListString,
|
'myListString': myListString,
|
||||||
'DriverList': myList,
|
'DriverList': myList,
|
||||||
@@ -223,8 +218,8 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
});
|
});
|
||||||
} else if (message.notification!.title!.contains('Apply Ride')) {
|
} else if (message.notification!.title!.contains('Apply Ride')) {
|
||||||
var passengerList = message.data['passengerList'];
|
var passengerList = message.data['passengerList'];
|
||||||
print(passengerList);
|
// print(passengerList);
|
||||||
print('9999999999999my Apply Ride 999999999999999');
|
// print('9999999999999my Apply Ride 999999999999999');
|
||||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||||
driverID = myList[2].toString();
|
driverID = myList[2].toString();
|
||||||
|
|
||||||
@@ -313,18 +308,18 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
});
|
});
|
||||||
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||||
print(
|
// print(
|
||||||
'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
// 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||||
RemoteNotification? notification = message.notification;
|
RemoteNotification? notification = message.notification;
|
||||||
if (message.data.isNotEmpty) {
|
if (message.data.isNotEmpty) {
|
||||||
if (message.notification!.title!.contains('Order')) {
|
if (notification!.title!.contains('Order')) {
|
||||||
var myListString = message.data['DriverList'];
|
var myListString = message.data['DriverList'];
|
||||||
print(myListString);
|
// print(myListString);
|
||||||
print('9999999999999myListString999999999999999');
|
// print('9999999999999myListString999999999999999');
|
||||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||||
driverToken = myList[14].toString();
|
driverToken = myList[14].toString();
|
||||||
update();
|
update();
|
||||||
print('driverToken==============$driverToken');
|
// print('driverToken==============$driverToken');
|
||||||
Get.to(() => OrderRequestPage(), arguments: {
|
Get.to(() => OrderRequestPage(), arguments: {
|
||||||
'myListString': myListString,
|
'myListString': myListString,
|
||||||
'DriverList': myList,
|
'DriverList': myList,
|
||||||
@@ -332,8 +327,8 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
});
|
});
|
||||||
} else if (message.notification!.title!.contains('Apply Ride')) {
|
} else if (message.notification!.title!.contains('Apply Ride')) {
|
||||||
var passengerList = message.data['passengerList'];
|
var passengerList = message.data['passengerList'];
|
||||||
print(passengerList);
|
// print(passengerList);
|
||||||
print('9999999999999my Apply Ride 999999999999999');
|
// print('9999999999999my Apply Ride 999999999999999');
|
||||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||||
driverID = myList[2].toString();
|
driverID = myList[2].toString();
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,18 @@ class MapPassengerController extends GetxController {
|
|||||||
late String driverToken;
|
late String driverToken;
|
||||||
int carsOrder = 0;
|
int carsOrder = 0;
|
||||||
String? mapAPIKEY;
|
String? mapAPIKEY;
|
||||||
|
late double totalME = 0;
|
||||||
|
late double tax = 0;
|
||||||
|
late double totalPassenger = 0;
|
||||||
|
late double totalDriver = 0;
|
||||||
|
late double averageDuration = 0;
|
||||||
|
late double costDuration = 0;
|
||||||
|
late double cost = 0;
|
||||||
|
late double distance = 0;
|
||||||
|
late double duration = 0;
|
||||||
|
|
||||||
|
late Duration durationToAdd;
|
||||||
|
late DateTime newTime = DateTime.now();
|
||||||
|
|
||||||
void onChangedPassengerCount(int newValue) {
|
void onChangedPassengerCount(int newValue) {
|
||||||
selectedPassengerCount = newValue;
|
selectedPassengerCount = newValue;
|
||||||
@@ -116,6 +128,7 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
void getCurrentLocationFormString() async {
|
void getCurrentLocationFormString() async {
|
||||||
currentLocationToFormPlaces = true;
|
currentLocationToFormPlaces = true;
|
||||||
|
currentLocationString = 'Waiting for your location'.tr;
|
||||||
await getLocation();
|
await getLocation();
|
||||||
currentLocationString = myLocation.toString();
|
currentLocationString = myLocation.toString();
|
||||||
newStartPointLocation = myLocation;
|
newStartPointLocation = myLocation;
|
||||||
@@ -401,7 +414,7 @@ class MapPassengerController extends GetxController {
|
|||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
Get.defaultDialog(
|
Get.defaultDialog(
|
||||||
title: 'No Car or Captain Found in your area.'.tr,
|
title: 'No Car or Driver Found in your area.'.tr,
|
||||||
titleStyle: AppStyle.title,
|
titleStyle: AppStyle.title,
|
||||||
middleText: 'Please Try anther time '.tr,
|
middleText: 'Please Try anther time '.tr,
|
||||||
middleTextStyle: AppStyle.title.copyWith(color: AppColor.yellowColor),
|
middleTextStyle: AppStyle.title.copyWith(color: AppColor.yellowColor),
|
||||||
@@ -436,7 +449,7 @@ class MapPassengerController extends GetxController {
|
|||||||
changeConfirmRide();
|
changeConfirmRide();
|
||||||
} else {
|
} else {
|
||||||
Get.defaultDialog(
|
Get.defaultDialog(
|
||||||
title: 'There no Captain Aplly your order sorry for that '.tr,
|
title: 'There no Driver Aplly your order sorry for that '.tr,
|
||||||
middleText: 'try next time .',
|
middleText: 'try next time .',
|
||||||
confirm: MyElevatedButton(
|
confirm: MyElevatedButton(
|
||||||
title: 'Back',
|
title: 'Back',
|
||||||
@@ -503,30 +516,19 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
var res =
|
var res =
|
||||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
|
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
|
||||||
'southwestLat': southwest.latitude.toString(),
|
'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
'southwestLon': southwest.longitude.toString(),
|
'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
'northeastLat': northeast.latitude.toString(),
|
'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
'northeastLon': northeast.longitude.toString(),
|
'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
});
|
});
|
||||||
if (res == 'failure') {
|
if (res == 'failure') {
|
||||||
noCarString = true;
|
noCarString = true;
|
||||||
dataCarsLocationByPassenger = res;
|
dataCarsLocationByPassenger = res;
|
||||||
update();
|
update();
|
||||||
// Get.snackbar('No Car in your site.Sorry!'.tr, '',
|
|
||||||
// backgroundColor: AppColor.redColor);
|
|
||||||
// Get.defaultDialog(
|
|
||||||
// title: 'No Car in your site.Sorry!'.tr,
|
|
||||||
// middleText: '',
|
|
||||||
// confirm: MyElevatedButton(
|
|
||||||
// title: 'Back',
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
// markerReloadingTimer.cancel();
|
|
||||||
// }));
|
|
||||||
} else {
|
} else {
|
||||||
noCarString = false;
|
noCarString = false;
|
||||||
dataCarsLocationByPassenger = jsonDecode(res);
|
dataCarsLocationByPassenger = jsonDecode(res);
|
||||||
// print(dataCarsLocationByPassenger);
|
print(dataCarsLocationByPassenger);
|
||||||
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||||
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||||
.toString();
|
.toString();
|
||||||
@@ -569,7 +571,7 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
Future runEvery30SecondsUntilConditionMet() async {
|
Future runEvery30SecondsUntilConditionMet() async {
|
||||||
// Calculate the duration of the trip in minutes.
|
// Calculate the duration of the trip in minutes.
|
||||||
double tripDurationInMinutes = duration1 / 30;
|
double tripDurationInMinutes = duration1 / 20;
|
||||||
int loopCount = tripDurationInMinutes.ceil();
|
int loopCount = tripDurationInMinutes.ceil();
|
||||||
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
||||||
for (var i = 0; i < loopCount; i++) {
|
for (var i = 0; i < loopCount; i++) {
|
||||||
@@ -769,7 +771,7 @@ class MapPassengerController extends GetxController {
|
|||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: Size(Get.width * .6, Get.height * .6),
|
size: Size(Get.width * .6, Get.height * .6),
|
||||||
);
|
);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png')
|
BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png')
|
||||||
.then((value) {
|
.then((value) {
|
||||||
tripIcon = value;
|
tripIcon = value;
|
||||||
update();
|
update();
|
||||||
@@ -1133,18 +1135,6 @@ class MapPassengerController extends GetxController {
|
|||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
late double totalME = 0;
|
|
||||||
late double tax = 0;
|
|
||||||
late double totalPassenger = 0;
|
|
||||||
late double totalDriver = 0;
|
|
||||||
late double averageDuration = 0;
|
|
||||||
late double costDuration = 0;
|
|
||||||
late double cost = 0;
|
|
||||||
late double distance = 0;
|
|
||||||
late double duration = 0;
|
|
||||||
|
|
||||||
late Duration durationToAdd;
|
|
||||||
late DateTime newTime = DateTime.now();
|
|
||||||
Future bottomSheet() async {
|
Future bottomSheet() async {
|
||||||
if (data.isNotEmpty) {
|
if (data.isNotEmpty) {
|
||||||
String distanceText = await data[0]['distance']['text'];
|
String distanceText = await data[0]['distance']['text'];
|
||||||
|
|||||||
@@ -47,19 +47,31 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
|
|||||||
],
|
],
|
||||||
borderRadius: const BorderRadius.all(
|
borderRadius: const BorderRadius.all(
|
||||||
Radius.circular(15))),
|
Radius.circular(15))),
|
||||||
child: Row(
|
child: ListView.builder(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
itemCount:
|
||||||
|
controller.dataCarsLocationByPassenger.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: Get.width * .15,
|
width: Get.width * .15,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Image.asset(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(controller
|
||||||
|
.dataCarsLocationByPassenger
|
||||||
|
.toString()),
|
||||||
|
Image.asset(
|
||||||
'assets/images/jeep.png',
|
'assets/images/jeep.png',
|
||||||
width: 50,
|
width: 50,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
repeat: ImageRepeat.repeatX,
|
repeat: ImageRepeat.repeatX,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -100,7 +112,8 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
|
|||||||
),
|
),
|
||||||
controller.promoTaken
|
controller.promoTaken
|
||||||
? const Icon(
|
? const Icon(
|
||||||
Icons.filter_vintage_rounded,
|
Icons
|
||||||
|
.filter_vintage_rounded,
|
||||||
color: AppColor.redColor,
|
color: AppColor.redColor,
|
||||||
)
|
)
|
||||||
: const SizedBox(
|
: const SizedBox(
|
||||||
@@ -111,6 +124,8 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
|||||||
markerId: MarkerId('MyLocation'.tr),
|
markerId: MarkerId('MyLocation'.tr),
|
||||||
position: controller.newStartPointLocation,
|
position: controller.newStartPointLocation,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
icon: controller.tripIcon,
|
icon: controller.markerIcon,
|
||||||
infoWindow: const InfoWindow(
|
infoWindow: const InfoWindow(
|
||||||
title: 'Time',
|
title: 'Time',
|
||||||
// snippet: controller.durationFromDriverToPassenger
|
// snippet: controller.durationFromDriverToPassenger
|
||||||
@@ -166,7 +166,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
|||||||
markerId: MarkerId('Destination'.tr),
|
markerId: MarkerId('Destination'.tr),
|
||||||
position: controller.newMyLocation,
|
position: controller.newMyLocation,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
icon: controller.tripIcon,
|
icon: controller.markerIcon,
|
||||||
infoWindow: const InfoWindow(
|
infoWindow: const InfoWindow(
|
||||||
title: 'Time',
|
title: 'Time',
|
||||||
// snippet: controller.durationFromDriverToPassenger
|
// snippet: controller.durationFromDriverToPassenger
|
||||||
|
|||||||
@@ -82,15 +82,15 @@ class MainBottomMenuMap extends StatelessWidget {
|
|||||||
controller.startLocationFromMap =
|
controller.startLocationFromMap =
|
||||||
false;
|
false;
|
||||||
controller.isPickerShown = false;
|
controller.isPickerShown = false;
|
||||||
print(controller.myLocation);
|
// print(controller.myLocation);
|
||||||
print(controller
|
// print(controller
|
||||||
.newStartPointLocation);
|
// .newStartPointLocation);
|
||||||
} else {
|
} else {
|
||||||
controller.newMyLocation =
|
controller.newMyLocation =
|
||||||
controller.newMyLocation;
|
controller.newMyLocation;
|
||||||
controller.isPickerShown = false;
|
controller.isPickerShown = false;
|
||||||
print(controller.myLocation);
|
// print(controller.myLocation);
|
||||||
print(controller.newMyLocation);
|
// print(controller.newMyLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// await controller.getMap(
|
// await controller.getMap(
|
||||||
|
|||||||
@@ -203,6 +203,9 @@ class IconMainPageMap extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: Future.delayed(const Duration(milliseconds: 400)),
|
||||||
|
builder: (context, snapshot) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -237,5 +240,6 @@ class IconMainPageMap extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,17 +45,6 @@ class MyScafolld extends StatelessWidget {
|
|||||||
style: AppStyle.title.copyWith(fontSize: 30),
|
style: AppStyle.title.copyWith(fontSize: 30),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(child: Stack(children: body)));
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: Get.height,
|
|
||||||
width: Get.width,
|
|
||||||
child: Stack(children: body))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user