From b9c9a8a12f92fe39e6af2fb517d31573215e6434 Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Mon, 22 Apr 2024 14:19:38 +0300 Subject: [PATCH] 4/22/1 --- lib/controller/firebase/firbase_messge.dart | 22 +++++----- .../home/captin/home_captain_controller.dart | 10 +++-- .../home/map_passenger_controller.dart | 14 ++++--- .../payment/payment_controller.dart | 12 +++--- .../payment/paymob/paymob_wallet.dart | 10 ++--- lib/views/Rate/rate_captain.dart | 26 ++++++++---- .../Captin/home_captain/call_controller.dart | 14 +++++-- .../Captin/home_captain/widget/call_page.dart | 14 +++---- .../Captin/home_captain/widget/connect.dart | 40 +++++++++++++++---- .../map_widget.dart/call_passenger_page.dart | 11 ++--- 10 files changed, 113 insertions(+), 60 deletions(-) diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 80da3d0..a107f6e 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -197,16 +197,16 @@ class FirebaseMessagesController extends GetxController { 'you will pay to Driver'.tr + ' ${driverList[3].toString()} \$'.tr, 'tone1'); Get.find().tripFinishedFromDriver(); - if (Get.find().isCashChecked == false && - Get.find().isWalletChecked == true) { - driverFinishTripDialoge(driverList); - } else { - Get.to(() => RateDriverFromPassenger(), arguments: { - 'driverId': driverList[0].toString(), - 'rideId': driverList[1].toString(), - 'price': driverList[3].toString() - }); - } + // if (Get.find().isCashChecked == false && + // Get.find().isWalletChecked == true) { + // // driverFinishTripDialoge(driverList); + // } else { + Get.to(() => RateDriverFromPassenger(), arguments: { + 'driverId': driverList[0].toString(), + 'rideId': driverList[1].toString(), + 'price': driverList[3].toString() + }); + // } } else if (message.notification!.title! == 'Call Income') { try { var myListString = message.data['passengerList']; @@ -254,7 +254,7 @@ class FirebaseMessagesController extends GetxController { 'Driver Cancel Your Trip'.tr, 'you will pay to Driver you will be pay the cost of driver time look to your SEFER Wallet' .tr, - 'order'); + 'cancel'); } Get.find().restCounter(); diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index 5ff9f2e..0944d1a 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -241,10 +241,14 @@ class HomeCaptainController extends GetxController { var res = await CRUD().get( link: AppLink.getDriverpaymentToday, payload: {'driverID': box.read(BoxName.driverID).toString()}); - data = jsonDecode(res); - totalMoneyToday = data['message'][0]['todayAmount']; + if (res != 'failure') { + data = jsonDecode(res); + totalMoneyToday = data['message'][0]['todayAmount']; - update(); + update(); + } else { + print(res); + } } getKazanPercent() async { diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index a8fa575..c6270c9 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -1074,7 +1074,8 @@ class MapPassengerController extends GetxController { var res = await getRideStatus(rideId); // print(res); // var decod = jsonDecode(res); - print(' 0000000000000000000000000000000000000000000000000'); + print( + ' 000000000000000000delayAndFetchRideStatus0000000000000000000000000000000'); print(res); if (res.toString() == 'Apply') { // getUpdatedRideForDriverApply(rideId); @@ -1107,7 +1108,7 @@ class MapPassengerController extends GetxController { var res = await getRideStatus(rideId); print(res); // var decod = jsonDecode(res); - // print(' 0000000000000000000000000000000000000000000000000'); + print('--------delayAndFetchRideStatusForAllDriverAvailable----'); // print(decod['data']); if (res.toString() == 'Apply') { getUpdatedRideForDriverApply(rideId); @@ -1256,6 +1257,7 @@ class MapPassengerController extends GetxController { ), ); driversToken.add(json['token']); + // driversToken = json['token']; } else { carLocationsModels[i] = model; markers[i] = Marker( @@ -1267,7 +1269,8 @@ class MapPassengerController extends GetxController { rotation: double.parse(json['heading']), icon: carIcon, ); - driversToken[i] = json['token']; + // driversToken = json['token']; + driversToken.add(json['token']); } } @@ -1411,8 +1414,6 @@ class MapPassengerController extends GetxController { "order_id": rideId.toString(), // Convert to String "status": 'Cancel' }); - FirebaseMessagesController().sendNotificationToDriverMAP( - 'Cancel Trip', 'Trip Cancelled'.tr, driverToken, []); } rideConfirm = false; shouldFetch = false; @@ -2507,7 +2508,8 @@ class MapPassengerController extends GetxController { link: AppLink.getPassengerRate, payload: {'passenger_id': box.read(BoxName.passengerID)}); if (res != 'failure') { - passengerRate = double.parse(jsonDecode(res)['message']['rating']) ?? 5; + print(jsonDecode(res)['message']['rating']); + passengerRate = jsonDecode(res)['message']['rating']; } } diff --git a/lib/controller/payment/payment_controller.dart b/lib/controller/payment/payment_controller.dart index 969c163..8687d7c 100644 --- a/lib/controller/payment/payment_controller.dart +++ b/lib/controller/payment/payment_controller.dart @@ -254,8 +254,8 @@ class PaymentController extends GetxController { MaterialPageRoute( builder: (BuildContext context) => UsePaypal( sandboxMode: true, - clientId: AK.payPalClientIdLive, - secretKey: AK.payPalSecretLive, + clientId: AK.payPalClientId, + secretKey: AK.payPalSecret, returnURL: AppInformation.website, cancelURL: "${AppInformation.website}/cancel", transactions: [ @@ -636,10 +636,10 @@ class PaymentController extends GetxController { billingData: PaymobBillingDataWallet(), onPayment: (PaymobResponseWallet response) { - print('Success: ${response.success}'); - print('Transaction ID: ${response.transactionID}'); - print('Response Code: ${response.responseCode}'); - print('Message: ${response.message}'); + // print('Success: ${response.success}'); + // print('Transaction ID: ${response.transactionID}'); + // print('Response Code: ${response.responseCode}'); + // print('Message: ${response.message}'); // print(box.read(BoxName.passengerWalletTotal));// // print(box.read(BoxName.name)); diff --git a/lib/controller/payment/paymob/paymob_wallet.dart b/lib/controller/payment/paymob/paymob_wallet.dart index 080fa2c..6ec87f4 100644 --- a/lib/controller/payment/paymob/paymob_wallet.dart +++ b/lib/controller/payment/paymob/paymob_wallet.dart @@ -30,7 +30,7 @@ class PaymobResponseWallet { class PaymobPaymentWallet { static PaymobPaymentWallet instance = PaymobPaymentWallet(); - bool _isInitialized = false; + bool _isInitializedWallet = false; final Dio _dio = Dio(); final _baseURL = 'https://accept.paymob.com/api/'; @@ -55,7 +55,7 @@ class PaymobPaymentWallet { /// The expiration time of this payment token in seconds. (The maximum is 3600 seconds which is an hour) int userTokenExpiration = 300, }) async { - if (_isInitialized) { + if (_isInitializedWallet) { return true; } _dio.options.baseUrl = _baseURL; @@ -65,9 +65,9 @@ class PaymobPaymentWallet { _iFrameID = iFrameID; _iFrameURL = 'https://accept.paymobsolutions.com/api/acceptance/iframes/$_iFrameID?payment_token='; - _isInitialized = true; + _isInitializedWallet = true; _userTokenExpiration = userTokenExpiration; - return _isInitialized; + return _isInitializedWallet; } /// Get authentication token, which is valid for one hour from the creation time. @@ -196,7 +196,7 @@ class PaymobPaymentWallet { /// The billing data related to the customer related to this payment. PaymobBillingDataWallet? billingData}) async { - if (!_isInitialized) { + if (!_isInitializedWallet) { throw Exception( 'PaymobPayment is not initialized call:`PaymobPayment.instance.initialize`'); } diff --git a/lib/views/Rate/rate_captain.dart b/lib/views/Rate/rate_captain.dart index 67fec39..1b018a9 100644 --- a/lib/views/Rate/rate_captain.dart +++ b/lib/views/Rate/rate_captain.dart @@ -6,6 +6,8 @@ import 'package:get/get.dart'; import '../../constant/colors.dart'; import '../../constant/style.dart'; +import '../../controller/firebase/firbase_messge.dart'; +import '../../controller/payment/payment_controller.dart'; import '../../controller/rate/rate_conroller.dart'; import '../../main.dart'; import '../widgets/elevated_btn.dart'; @@ -86,14 +88,24 @@ class RateDriverFromPassenger extends StatelessWidget { const SizedBox( height: 10, ), - Text( - 'Exclusive offers and discounts always with the Sefer app' - .tr, - style: AppStyle.title.copyWith( - color: AppColor.redColor, + Padding( + padding: const EdgeInsets.all(4.0), + child: Text( + 'Exclusive offers and discounts always with the Sefer app' + .tr, + style: AppStyle.title.copyWith( + color: AppColor.redColor, + ), + textAlign: TextAlign.center, ), - textAlign: TextAlign.center, - ) + ), + (Get.find().isCashChecked == + false && + Get.find() + .isWalletChecked == + true) + ? const DriverTipWidget() + : const SizedBox() ], ), )), diff --git a/lib/views/home/Captin/home_captain/call_controller.dart b/lib/views/home/Captin/home_captain/call_controller.dart index 6f7089a..0d92033 100644 --- a/lib/views/home/Captin/home_captain/call_controller.dart +++ b/lib/views/home/Captin/home_captain/call_controller.dart @@ -1,5 +1,6 @@ import 'package:SEFER/constant/api_key.dart'; import 'package:SEFER/controller/functions/crud.dart'; +import 'package:SEFER/controller/home/map_passenger_controller.dart'; import 'package:agora_rtc_engine/agora_rtc_engine.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -22,9 +23,16 @@ class CallController extends GetxController { @override void onInit() { super.onInit(); - channelName = Get.find().rideId; // 'sefer300'; // - remoteUid = int.parse(Get.find().passengerPhone); - uid = int.parse(box.read(BoxName.phoneDriver)); + channelName = box.read(BoxName.driverID) != null + ? Get.find().rideId + : Get.find().rideId; // 'sefer300'; // + remoteUid = box.read(BoxName.driverID) != null + ? int.parse(box.read(BoxName.phoneDriver)) + : int.parse(box.read(BoxName.phone)); + uid = box.read(BoxName.driverID) == null + ? int.parse(box.read(BoxName.phoneDriver)) + : int.parse(box.read(BoxName.phone)); + initAgoraFull(); } diff --git a/lib/views/home/Captin/home_captain/widget/call_page.dart b/lib/views/home/Captin/home_captain/widget/call_page.dart index 4dc98cc..0870bd6 100644 --- a/lib/views/home/Captin/home_captain/widget/call_page.dart +++ b/lib/views/home/Captin/home_captain/widget/call_page.dart @@ -8,9 +8,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; -import '../../../../../constant/box_name.dart'; -import '../../../../../main.dart'; - class CallPage extends StatelessWidget { const CallPage({super.key}); @@ -33,10 +30,13 @@ GetBuilder callPage() { padding: const EdgeInsets.all(15), child: Container( decoration: AppStyle.boxDecoration1, - child: Text( - 'No SIM card, no problem! Call your driver directly through our app. We use advanced technology to ensure your privacy.' - .tr, - style: AppStyle.title, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'No SIM card, no problem! Call your driver directly through our app. We use advanced technology to ensure your privacy.' + .tr, + style: AppStyle.title, + ), ), ), ), diff --git a/lib/views/home/Captin/home_captain/widget/connect.dart b/lib/views/home/Captin/home_captain/widget/connect.dart index 4b6beb5..66d997c 100644 --- a/lib/views/home/Captin/home_captain/widget/connect.dart +++ b/lib/views/home/Captin/home_captain/widget/connect.dart @@ -1,4 +1,6 @@ +import 'package:SEFER/controller/functions/tts.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart'; @@ -36,12 +38,33 @@ class ConnectWidget extends StatelessWidget { ? 'You dont have Points'.tr : 'You Are Stopped For this Day !'.tr, titleStyle: AppStyle.title, - content: Text( - double.parse(captainWalletController.totalPoints) < -300 - ? 'You must be recharge your Account'.tr - : 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!' - .tr, - style: AppStyle.title, + content: Column( + children: [ + IconButton( + onPressed: () async { + double.parse( + captainWalletController.totalPoints) < + -300 + ? await Get.find() + .speakText( + 'You must be recharge your Account' + .tr) + : await Get.find() + .speakText( + 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!' + .tr); + }, + icon: const Icon(Icons.headphones), + ), + Text( + double.parse(captainWalletController.totalPoints) < + -300 + ? 'You must be recharge your Account'.tr + : 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!' + .tr, + style: AppStyle.title, + ), + ], ), confirm: double.parse(captainWalletController.totalPoints) < @@ -60,7 +83,10 @@ class ConnectWidget extends StatelessWidget { })); }, color: CupertinoColors.destructiveRed, - child: Text('You are Stopped'.tr), + child: Text( + 'You are Stopped'.tr, + style: AppStyle.title, + ), ) : CupertinoButton( onPressed: homeCaptainController.onButtonSelected, diff --git a/lib/views/home/map_widget.dart/call_passenger_page.dart b/lib/views/home/map_widget.dart/call_passenger_page.dart index 6010d68..dbb6215 100644 --- a/lib/views/home/map_widget.dart/call_passenger_page.dart +++ b/lib/views/home/map_widget.dart/call_passenger_page.dart @@ -166,12 +166,13 @@ class _PassengerCallPageState extends State { Widget _status() { String statusText; - if (!_isJoined) - statusText = 'Join a channel'; - else if (_remoteUid == null) - statusText = 'Waiting for a remote user to join...'; - else + if (!_isJoined) { + statusText = 'Join a channel'.tr; + } else if (_remoteUid == null) { + statusText = 'Waiting for a remote user to join...'.tr; + } else { statusText = 'Connected to remote user, uid:$_remoteUid'; + } return Text( statusText,