2/4/1
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
@@ -13,9 +14,11 @@ import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
@@ -99,7 +102,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
if (message.data.isNotEmpty) {
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
// If the app is in the background or terminated, show a system tray message
|
||||
RemoteNotification? notification = message.notification;
|
||||
@@ -108,7 +111,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
if (notification != null && android != null) {
|
||||
// print('onMessageOpenedApp: ${notification.title} ${notification.body}');
|
||||
if (message.data.isNotEmpty) {
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -117,11 +120,11 @@ class FirebaseMessagesController extends GetxController {
|
||||
// print(
|
||||
// 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||
RemoteNotification? notification = message.notification;
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
});
|
||||
}
|
||||
|
||||
void firebasetitles(RemoteMessage message) {
|
||||
void fireBaseTitles(RemoteMessage message) {
|
||||
if (message.notification!.title!.contains('Order')) {
|
||||
var myListString = message.data['DriverList'];
|
||||
print(myListString);
|
||||
@@ -181,13 +184,49 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
|
||||
// mapController.driverArrivePassenger();
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('Captain Finish Trip')) {
|
||||
// MapPassengerController mapController =
|
||||
// Get.find<MapPassengerController>();
|
||||
Get.snackbar('Ride Finished'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
// mapController.isRideFinished = true;//todo fix that for dfinish ride in passenger app
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Your fee is ${Get.find<MapPassengerController>().totalPassenger.toStringAsFixed(2)}'),
|
||||
Text('Do you want to pay Tips for this Driver'.tr)
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': '1',
|
||||
});
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'1\$ tips',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.offAll(() => RateCaptainFromPassenger());
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,61 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> sendVerificationRequest(String phoneNumber) async {
|
||||
final accountSid = "ACb4ad857efe0903bfd6238a763a2ce4d1";
|
||||
final authToken = "14f39ef4628bb8a4f18469f462f8af75";
|
||||
final verifySid = "VAf6e6022a7e95186aa5b1da25411859bd";
|
||||
|
||||
final Uri verificationUri = Uri.parse(
|
||||
'https://verify.twilio.com/v2/Services/$verifySid/Verifications');
|
||||
|
||||
// Send the verification request
|
||||
final response = await http.post(
|
||||
verificationUri,
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ' + base64Encode(utf8.encode('$accountSid:$authToken')),
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: {
|
||||
'To': phoneNumber,
|
||||
'Channel': 'sms',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
print('Verification request sent');
|
||||
} else {
|
||||
print('Failed to send verification request');
|
||||
}
|
||||
|
||||
// Prompt the user to enter the OTP
|
||||
final otpCode = "123456"; // Replace with user input
|
||||
|
||||
// Check the verification code
|
||||
final checkUri = Uri.parse(
|
||||
'https://verify.twilio.com/v2/Services/$verifySid/VerificationCheck');
|
||||
|
||||
final checkResponse = await http.post(
|
||||
checkUri,
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ' + base64Encode(utf8.encode('$accountSid:$authToken')),
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: {
|
||||
'To': phoneNumber,
|
||||
'Code': otpCode,
|
||||
},
|
||||
);
|
||||
|
||||
if (checkResponse.statusCode == 201) {
|
||||
print('Verification successful');
|
||||
} else {
|
||||
print('Verification failed');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getGoogleApi({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
@@ -220,7 +275,7 @@ class CRUD {
|
||||
url,
|
||||
body: payload,
|
||||
);
|
||||
//print(response.request);
|
||||
print(response.request);
|
||||
var jsonData = jsonDecode(response.body);
|
||||
// //print(jsonData);
|
||||
if (jsonData['status'] == 'OK') {
|
||||
|
||||
@@ -267,10 +267,14 @@ class MapDriverController extends GetxController {
|
||||
'passengerId': passengerId,
|
||||
'driverId': driverId
|
||||
});
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'Captain Finish Trip',
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Driver Finish Trip',
|
||||
box.read(BoxName.name).toString(),
|
||||
tokenPassenger);
|
||||
tokenPassenger, [
|
||||
box.read(BoxName.driverID),
|
||||
rideId,
|
||||
box.read(BoxName.tokenDriver),
|
||||
]);
|
||||
}
|
||||
|
||||
void cancelCheckRidefromPassenger() async {
|
||||
|
||||
@@ -93,6 +93,8 @@ class MapPassengerController extends GetxController {
|
||||
double mainBottomMenuMapHeight = Get.height * .2;
|
||||
double wayPointSheetHeight = 0;
|
||||
bool startLocationFromMap = false;
|
||||
bool workLocationFromMap = false;
|
||||
bool homeLocationFromMap = false;
|
||||
bool startLocationFromMap0 = false;
|
||||
bool startLocationFromMap1 = false;
|
||||
bool startLocationFromMap2 = false;
|
||||
@@ -161,7 +163,7 @@ class MapPassengerController extends GetxController {
|
||||
List<String> currentLocationStringAll = [];
|
||||
List<String> hintTextwayPointStringAll = [];
|
||||
var placesCoordinate = <String>[];
|
||||
String hintTextDestinationPoint = 'Search for your destination'.tr;
|
||||
String hintTextDestinationPoint = 'Select your destination'.tr;
|
||||
late String rideId;
|
||||
bool noCarString = false;
|
||||
bool isCashSelectedBeforeConfirmRide = false;
|
||||
@@ -218,6 +220,7 @@ class MapPassengerController extends GetxController {
|
||||
durationToRide = 0;
|
||||
distanceOfDestnation = 0;
|
||||
wayPointSheetHeight = 0;
|
||||
haveSteps = true;
|
||||
for (var i = 0; i < Get.find<WayPointController>().wayPoints.length; i++) {
|
||||
if (placesCoordinate[i + 1].toString() != '') {
|
||||
await getMapPoints(
|
||||
@@ -346,6 +349,16 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void convertHintTextDestinationNewPlacesFromRecent(
|
||||
List recentLocations, int index) {
|
||||
hintTextDestinationPoint = recentLocations[index]['name'];
|
||||
double lat = recentLocations[index]['latitude'];
|
||||
double lng = recentLocations[index]['longitude'];
|
||||
newMyLocation = LatLng(lat, lng);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
// final mainBottomMenuMap = GlobalKey<AnimatedContainer>();
|
||||
void changeBottomSheetShown() {
|
||||
isBottomSheetShown = !isBottomSheetShown;
|
||||
@@ -486,10 +499,10 @@ class MapPassengerController extends GetxController {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * totalPassenger).toString()
|
||||
});
|
||||
Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
'driverId': driverId.toString(),
|
||||
'rideId': rideId.toString(),
|
||||
});
|
||||
// Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
// 'driverId': driverId.toString(),
|
||||
// 'rideId': rideId.toString(),
|
||||
// });
|
||||
}
|
||||
|
||||
void getBeginRideFromDriver() async {
|
||||
@@ -634,7 +647,7 @@ class MapPassengerController extends GetxController {
|
||||
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
totalPassenger.toString(),
|
||||
totalDriver.toString(),
|
||||
duration.toString(),
|
||||
durationToRide.toString(),
|
||||
distance.toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||
.toString(),
|
||||
@@ -985,7 +998,7 @@ class MapPassengerController extends GetxController {
|
||||
} else {
|
||||
isMainBottomMenuMap = !isMainBottomMenuMap;
|
||||
mainBottomMenuMapHeight =
|
||||
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .6;
|
||||
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .5;
|
||||
isWayPointSheet = false;
|
||||
if (heightMenuBool == true) {
|
||||
getDrawerMenu();
|
||||
@@ -1499,10 +1512,10 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
double distanceOfDestnation = 0;
|
||||
bool haveSteps = false;
|
||||
late LatLng latestPosition;
|
||||
late LatLng latestPosition = LatLng(0, 0);
|
||||
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
haveSteps = true;
|
||||
// haveSteps = true;
|
||||
await getCarsLocationByPassenger();
|
||||
// isLoading = true;
|
||||
update();
|
||||
@@ -1521,9 +1534,11 @@ class MapPassengerController extends GetxController {
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
|
||||
if (points[i][0].toString() != '') {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
|
||||
}
|
||||
}
|
||||
// Define the northeast and southwest coordinates
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ class CaptainWalletController extends GetxController {
|
||||
|
||||
//check if account bank is created or not
|
||||
Future checkAccountCaptainBank() async {
|
||||
isLoading = false;
|
||||
update();
|
||||
if (box.read(BoxName.accountIdStripeConnect).toString().isEmpty) {
|
||||
var res = await CRUD().get(link: AppLink.getAccount, payload: {
|
||||
'id': box.read(BoxName.driverID).toString(),
|
||||
@@ -83,6 +85,8 @@ class CaptainWalletController extends GetxController {
|
||||
d['message'][0]['accountBank'].toString());
|
||||
}
|
||||
}
|
||||
isLoading = true;
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user