This commit is contained in:
Hamza-Ayed
2024-02-09 02:56:37 +03:00
parent d4d4592944
commit 8c61a79de3
15 changed files with 397 additions and 71 deletions

View File

@@ -20,6 +20,7 @@ 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';
import '../home/payment/captain_wallet_controller.dart';
class FirebaseMessagesController extends GetxController {
final fcmToken = FirebaseMessaging.instance;
@@ -102,15 +103,15 @@ class FirebaseMessagesController extends GetxController {
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
if (message.notification != null && message.data.isNotEmpty) {
fireBaseTitles(message);
}
// if (message.notification != null && message.data.isNotEmpty) {
// fireBaseTitles(message);
// }
// If the app is in the background or terminated, show a system tray message
RemoteNotification? notification = message.notification;
AndroidNotification? android = notification?.android;
// if (notification != null && android != null) {
if (message.data.isNotEmpty) {
if (message.data.isNotEmpty && message.notification != null) {
fireBaseTitles(message);
}
});
@@ -221,6 +222,14 @@ class FirebaseMessagesController extends GetxController {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * tip).toString()
});
await CRUD().post(link: AppLink.addDriversWallet, payload: {
'driverID': driverList[0].toString(),
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
'amount': (tip * 100).toString(),
'paymentMethod': 'visa-tip',
});
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'You Have Tips',
@@ -238,8 +247,10 @@ class FirebaseMessagesController extends GetxController {
cancel: MyElevatedButton(
title: 'No,I want'.tr,
onPressed: () {
Get.back();
Get.off(() => RateCaptainFromPassenger());
Get.to(() => RateCaptainFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
},
kolor: AppColor.redColor,
));

View File

@@ -37,7 +37,7 @@ class LocationController extends GetxController {
// if (isActive) {
if (double.parse(totalPoints) > -100) {
print('total point is ll$totalPoints');
print('total point is $totalPoints');
await getLocation();
await CRUD().post(link: AppLink.addCarsLocationByPassenger, payload: {

View File

@@ -22,6 +22,8 @@ import '../../functions/location_controller.dart';
class MapDriverController extends GetxController {
bool isLoading = true;
final formKey1 = GlobalKey<FormState>();
final sosEmergincyNumberCotroller = TextEditingController();
List data = [];
List dataDestination = [];
LatLngBounds? boundsData;
@@ -478,6 +480,20 @@ class MapDriverController extends GetxController {
polyLines.add(polyline);
// rideConfirm = false;
// Define the northeast and southwest coordinates
final bounds = response["routes"][0]["bounds"];
LatLng northeast =
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
LatLng southwest =
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
// Create the LatLngBounds object
LatLngBounds boundsData =
LatLngBounds(northeast: northeast, southwest: southwest);
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 130);
mapController!.animateCamera(cameraUpdate);
update();
}
}
@@ -519,6 +535,8 @@ class MapDriverController extends GetxController {
// updateCameraFromBoundsAfterGetMap(dataBounds);
// polyLinesDestination.add(polyline);
// rideConfirm = false;
// Define the northeast and southwest coordinates
update();
}
}

View File

@@ -10,10 +10,29 @@ import 'package:ride/main.dart';
class CaptainWalletController extends GetxController {
bool isLoading = false;
Map walletDate = {};
Map walletDateVisa = {};
Map walletDriverPointsDate = {};
final formKey = GlobalKey<FormState>();
String totalAmount = '0';
String totalAmountVisa = '0';
String totalPoints = '0';
final amountFromBudgetController = TextEditingController();
payFromBudget() async {
if (formKey.currentState!.validate()) {
var pointFromBudget = int.parse((amountFromBudgetController.text)) * 100;
await addDriverPayment('fromBudgetToPoints',
int.parse((amountFromBudgetController.text)) * -1);
Future.delayed(const Duration(seconds: 2));
await addDriverWallet('fromBudget', pointFromBudget.toString());
update();
Get.back();
getCaptainWalletFromRide();
getCaptainWalletFromBuyPoints();
checkAccountCaptainBank();
}
}
Future getCaptainWalletFromRide() async {
isLoading = true;
@@ -26,6 +45,16 @@ class CaptainWalletController extends GetxController {
totalAmount = walletDate['message'][0]['total_amount'].toString() == null
? '0'
: walletDate['message'][0]['total_amount'];
print(totalAmount);
var res1 = await CRUD().get(
link: AppLink.getAllPaymentVisa,
payload: {'driverID': box.read(BoxName.driverID)});
walletDateVisa = jsonDecode(res1);
totalAmountVisa = walletDateVisa['message'][0]['diff'].toString() == null
? '0'
: walletDateVisa['message'][0]['diff'];
print(totalAmountVisa);
isLoading = false;
update();
}
@@ -60,7 +89,7 @@ class CaptainWalletController extends GetxController {
});
var d = jsonDecode(res);
paymentID = d['message'].toString();
// print(paymentID);
print('paymentID $paymentID');
}
Future addDriverWallet(String paymentMethod, point) async {

View File

@@ -125,8 +125,8 @@ class PaymentController extends GetxController {
late String clientSecret;
Future<void> makePaymentStripe(
int amount, String currency, Function method) async {
var newAmount = amount * 100;
double amount, String currency, Function method) async {
var newAmount = (amount * 100).toInt();
try {
// Check if local authentication is available
@@ -427,7 +427,7 @@ class PaymentController extends GetxController {
final body = {
'amount': amount, //amount
'currency': 'aed',
'currency': 'usd',
'destination': account //'acct_1OKIjQRgcWrsdyDT' //account id
};