diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 685602d..830efb7 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 30 + 31 CFBundleSignature ???? CFBundleURLTypes @@ -36,7 +36,7 @@ CFBundleVersion - 4.0.01 + 4.0.02 FirebaseAppDelegateProxyEnabled NO GMSApiKey diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 47493bb..a79c80b 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -420,7 +420,7 @@ class FirebaseMessagesController extends GetxController { // }); // } // } - +//android/app/src/main/res/raw/iphone_ringtone.wav void sendNotificationToPassengerToken( String title, body, token, List map) async { try { @@ -458,6 +458,43 @@ class FirebaseMessagesController extends GetxController { } } + void sendNotificationToPassengerTokenCALL( + String title, body, token, List map) async { + try { + final response = await http.post( + Uri.parse('https://fcm.googleapis.com/fcm/send'), + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'key=${AK.serverAPI}' + }, + body: jsonEncode({ + 'notification': { + 'title': title, + 'body': body, + 'sound': 'iphone_ringtone.wav' + }, + 'data': { + 'passengerList': map, + }, + 'priority': 'high', + 'to': token, + }), + ); + + if (response.statusCode == 200) { + // Notification sent successfully + print('Notification sent successfully'); + } else { + // Handle error response + print( + 'Failed to send notification. Status code: ${response.statusCode}'); + } + } catch (e) { + // Handle other exceptions + print('sendNotification() error: $e'); + } + } + void sendNotificationToAnyWithoutData( String title, String body, String token) async { try { diff --git a/lib/controller/functions/call_controller.dart b/lib/controller/functions/call_controller.dart index c67f0ea..8d2fe77 100644 --- a/lib/controller/functions/call_controller.dart +++ b/lib/controller/functions/call_controller.dart @@ -38,8 +38,8 @@ class CallController extends GetxController { // Set up an instance of Agora engine setupVoiceSDKEngine(); // join(); - FirebaseMessagesController().sendNotificationToPassengerToken( - 'Call Income from Passenger', + FirebaseMessagesController().sendNotificationToPassengerTokenCALL( + 'Call Income', '${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}', Get.find().tokenPassenger, [ @@ -79,8 +79,8 @@ class CallController extends GetxController { }, onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) { // Get.snackbar("Remote user uid:$remoteUid joined the channel", ''); - status = '${Get.find().passengerName}' - ' joined' + status = '${Get.find().passengerName} ' + 'joined' .tr; remoteUid = remoteUid; update(); @@ -88,7 +88,7 @@ class CallController extends GetxController { onUserOffline: (RtcConnection connection, int? remoteUid, UserOfflineReasonType reason) { // Get.snackbar("Remote user uid:$remoteUid left the channel", ''); - status = 'Call left'.tr; + status = 'Call Left'.tr; remoteUid = null; update(); }, diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index 4d1a7ea..8f53ebb 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -48,9 +48,9 @@ class CRUD { required String uid, }) async { var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver); - var res = await http.get( - Uri.parse( - 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'), + var res = await http.get(Uri.parse( + // 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'), + 'https://orca-app-b2i85.ondigitalocean.app/token?channelName=$channelName'), headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'}); if (res.statusCode == 200) { diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index c686cab..b438d33 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -398,6 +398,15 @@ class MapDriverController extends GetxController { 'passengerID': passengerId, 'driverID': box.read(BoxName.driverID).toString(), }); + + var res1 = + await CRUD().post(link: AppLink.addDriversWalletPoints, payload: { + 'paymentID': 'rideId$rideId', + 'amount': (costOfWaiting5Minute).toStringAsFixed(0), + 'paymentMethod': 'wait', + 'driverID': box.read(BoxName.driverID).toString(), + }); + print(res1); if (res != 'failure') { Get.snackbar( 'You will get cost of your work for this trip'.tr, @@ -515,6 +524,7 @@ class MapDriverController extends GetxController { 'passengerId': passengerId, 'rideId': rideId, 'price': price.toString(), + 'walletChecked': walletChecked }); // Get.back(); // } @@ -581,15 +591,19 @@ class MapDriverController extends GetxController { ? (i ~/ 60) + (recentDistanceToDash * Get.find().comfortPrice) - : carType == 'Mashwari' + : carType == 'Delivery' ? (i ~/ 60) + (recentDistanceToDash * Get.find().deliveryPrice) - : (i ~/ 60) + - (recentDistanceToDash * - Get.find() - .mashwariPrice); // $1 for each minute + $4 for each km - price = (price * .10) + price; // Add 10% tax + : carType == 'Rayeh Gai' + ? (i ~/ 60) + + (recentDistanceToDash * + Get.find().speedPrice) + : (i ~/ 60) + + (recentDistanceToDash * + Get.find() + .mashwariPrice); // $1 for each minute + $4 for each km + price = (price * double.parse(kazan)) + price; // Add 10% tax speed = Get.find().speed * 3.6; progressTimerRideBegin = i / durationOfRide; remainingTimeTimerRideBegin = durationOfRide - i; diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index 5a58020..ae5a847 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -79,6 +79,22 @@ class OrderRequestController extends GetxController { } } + void getSQL() async { + DateTime today = DateTime.now(); + int todayDay = today.day; + + String driverId = box.read(BoxName.driverID).toString(); + + String customQuery = ''' + SELECT * + FROM ${TableName.driverOrdersRefuse} + WHERE driver_id = '$driverId' + AND created_at LIKE '%$todayDay%' + '''; + List> results = await sql.getCustomQuery(customQuery); + print(results); + } + void startTimer(String driverID, orderID) async { for (int i = 0; i <= duration; i++) { await Future.delayed(const Duration(seconds: 1)); diff --git a/lib/controller/home/payment/captain_wallet_controller.dart b/lib/controller/home/payment/captain_wallet_controller.dart index c22829b..9a77e45 100644 --- a/lib/controller/home/payment/captain_wallet_controller.dart +++ b/lib/controller/home/payment/captain_wallet_controller.dart @@ -17,6 +17,7 @@ class CaptainWalletController extends GetxController { String totalAmountVisa = '0'; String totalPoints = '0'; final amountFromBudgetController = TextEditingController(); + final issurWallet = TextEditingController(); payFromBudget() async { if (formKey.currentState!.validate()) { diff --git a/lib/controller/home/payment/paymob_payout.dart b/lib/controller/home/payment/paymob_payout.dart new file mode 100644 index 0000000..d8f6671 --- /dev/null +++ b/lib/controller/home/payment/paymob_payout.dart @@ -0,0 +1,120 @@ +import 'dart:convert'; + +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/constant/colors.dart'; +import 'package:SEFER/main.dart'; +import 'package:get/get.dart'; +import 'package:http/http.dart' as http; + +import '../../../constant/links.dart'; +import '../../functions/crud.dart'; +import 'captain_wallet_controller.dart'; + +class PaymobPayout extends GetxController { + bool isLoading = false; + + Future getToken() async { + var headers = { + 'Content-Type': 'application/x-www-form-urlencoded', + // 'Cookie': + // 'csrftoken=74iZJ8XYyuTm5WRq2W4tpWX5eqoJLZVK5QhuDrChWpDtzpgGA269bbCWuEcW85t4' + }; + var body = { + 'grant_type': 'password', + 'username': 'sefer_api_checker', + 'password': '#c3pSwbUxOKpQnr5hHZAgpkSW', + 'client_id': 'kmNWU5gKsL8LKVhsJFbOGTEb3YQ5sQhvBoB8pqoW', + 'client_secret': + 'htV6nFANLDd658ueTEuMrIqwjcXsocMXmBLAYof7FuutBcSxdTdoNqFl3EAvO6zrOgGPLdiMrofNp2V9ASVRpjoSlFjDNRzY7hfPunAJEgf2N5ZUuknN4QniaqIZvaNt' + }; + var res = await http.post( + Uri.parse( + 'https://stagingpayouts.paymobsolutions.com/api/secure/o/token/'), + headers: headers, + body: body, + ); + String token = ''; + if (res.statusCode == 200) { + var decode = jsonDecode(res.body); + token = decode['access_token']; + } + print('token = $token'); + return token; + } + + payToDriverWallet( + String token, String amount, String issuer, String msisdn) async { + var headers = { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }; + var body = json.encode({ + "amount": amount, //"10.00", + "issuer": issuer, //"vodafone", + "msisdn": msisdn, // "01023456789" + }); + var res = await http.post( + Uri.parse( + 'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'), + headers: headers, + body: body, + ); + print(jsonDecode(res.body)); + print('-----'); + var dec = jsonDecode(res.body); + if (dec['disbursement_status'] == 'successful') { + await CRUD().post(link: AppLink.addDriverpayment, payload: { + 'rideId': DateTime.now().toIso8601String(), + 'amount': ((-1) * double.parse(dec['amount'])).toStringAsFixed(0), + 'payment_method': 'payout', + 'passengerID': 'myself', + 'driverID': box.read(BoxName.driverID).toString(), + }); + Get.snackbar('Transaction successful'.tr, + '${'Transaction successful'.tr} ${dec['amount']}', + backgroundColor: AppColor.greenColor); + Get.find().getCaptainWalletFromRide(); + } else if (dec['disbursement_status'] == 'failed') { + Get.snackbar('Transaction successful'.tr, 'Transaction failed'.tr, + backgroundColor: AppColor.redColor); + } + } + + payToDriverBankAccount(String token, String amount, String bankCardNumber, + String bankCode) async { + var headers = { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }; + var body = { + "issuer": "bank_card", + "amount": amount, //9.0, + "full_name": box.read(BoxName.nameDriver).toString(), + "bank_card_number": bankCardNumber, //"1111-2222-3333-4444", + "bank_code": bankCode, //"CIB", + "bank_transaction_type": "cash_transfer" + }; + var res = await http + .post( + Uri.parse( + 'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'), + headers: headers, + body: body, + ) + .then((value) { + print(value); + }); + } + + Future payToWalletDriverAll( + String amount, String issuer, String msisdn) async { + String token = await getToken(); + await payToDriverWallet(token, amount, issuer, msisdn); + } + + Future payToBankDriverAll( + String amount, String bankCardNumber, String bankCode) async { + String token = await getToken(); + await payToDriverBankAccount(token, amount, bankCardNumber, bankCode); + } +} diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 87d7515..011ae32 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -4,6 +4,27 @@ class MyTranslation extends Translations { @override Map> get keys => { "ar": { + "Transaction failed": "فشل المعاملة", + "Wallet Type": "نوع المحفظة", + "Enter your wallet number": "أدخل رقم محفظتك", + "The Amount is less than": "المبلغ أقل من", + "Cash Out": "صرف", + "Transaction successful": "تمت العملية بنجاح", + "Do you want to collect your earnings?": + "هل تريد استلام أموالك؟", // Corrected grammar + "Total wallet is ": "إجمالي المحفظة هو ", + "Remainder": "المتبقي", + "Call Page": "صفحة المكالمة", + "Call End": "إنهاء المكالمة", + "Call Left": "مكالمات متبقية", + "Rayeh Gai": "رايح جاي ", + "cost is ": " التكلفة هي ", + "Total budgets on month": "إجمالي الميزانيات لهذا الشهر", + "Counts of budgets on days": "عدد الميزانيات حسب الأيام", + "Wallet Added": "تم إضافة المحفظة", + "The price must be over than ": "يجب أن يكون السعر أكثر من ", + "Total Cost": "إجمالي التكلفة", + "This Trip Cancelled": "تم إلغاء هذه الرحلة", "Total price from ": "إجمالي السعر من ", "Wallet Add": "إضافة إلى المحفظة", "Press here": "اضغط هنا", @@ -567,7 +588,7 @@ class MyTranslation extends Translations { "Best choice for comfort car and flexible route and stops point": "أفضل خيار للسيارة المريحة والطريق المرن ونقطة التوقف", "Insert": "إدراج", - ' Total weekly points is ': '‏ ‏تفاصيل الرصيد التشغيل ', + ' Total weekly points is ': " مجموع النقاط الأسبوعية هو ", 'you can buy ': '‏يمكنك شراء', "Which method you will pay": '‏أي طريقة الدفع تفضل', "This is for delivery or a motorcycle.": diff --git a/lib/controller/rate/rate_conroller.dart b/lib/controller/rate/rate_conroller.dart index 0034cb0..099fbd3 100644 --- a/lib/controller/rate/rate_conroller.dart +++ b/lib/controller/rate/rate_conroller.dart @@ -1,3 +1,5 @@ +import 'package:SEFER/constant/colors.dart'; +import 'package:SEFER/controller/firebase/firbase_messge.dart'; import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; @@ -14,10 +16,11 @@ import 'package:SEFER/views/widgets/elevated_btn.dart'; class RateController extends GetxController { double selectedRateItemId = -1; TextEditingController comment = TextEditingController(); - TextEditingController passenggerPayAmount = TextEditingController(); + TextEditingController passengerPayAmount = TextEditingController(); String? rideId, passengerId, driverId, price; late GlobalKey formKey; bool ispassengerWantWalletFromDriver = false; + String walletChecked = ''; @override void onInit() { formKey = GlobalKey(); @@ -25,7 +28,7 @@ class RateController extends GetxController { rideId = Get.arguments['rideId']; driverId = Get.arguments['driverId']; price = Get.arguments['price']; - + walletChecked = Get.arguments['walletChecked']; super.onInit(); } @@ -38,16 +41,52 @@ class RateController extends GetxController { if (formKey.currentState!.validate()) { var priceOfTrip = double.parse(Get.find().paymentAmount); - double remainingFee = - double.parse(passenggerPayAmount.text) - priceOfTrip; - await CRUD().post(link: AppLink.addPassengersWallet, payload: { - 'passenger_id': passengerId, - 'balance': remainingFee.toString() - }).then((value) { - if (value != 'failure') { - Get.snackbar('Wallet Add', ''); - } - }); + double remainingFee = double.parse(passengerPayAmount.text) - priceOfTrip; + if (remainingFee > 0) { + await CRUD().post(link: AppLink.addPassengersWallet, payload: { + 'passenger_id': passengerId, + 'balance': remainingFee.toString() + }).then((value) async { + if (value != 'failure') { + Get.snackbar('Wallet Added'.tr, '', + backgroundColor: AppColor.greenColor); + + await CRUD().post(link: AppLink.addDriverpayment, payload: { + 'rideId': 'remain$rideId', + 'amount': remainingFee.toString(), + 'payment_method': 'Remainder', + 'passengerID': passengerId, + 'driverID': box.read(BoxName.driverID).toString(), + }); + + double pointsSubstraction = 0; + pointsSubstraction = remainingFee * (-1); // for eygpt /100 + var res = await CRUD() + .post(link: AppLink.addDriversWalletPoints, payload: { + 'paymentID': 'rideId$rideId', + 'amount': (pointsSubstraction).toStringAsFixed(0), + 'paymentMethod': 'Remainder', + 'driverID': box.read(BoxName.driverID).toString(), + }); + + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'Wallet Added', + 'Wallet Added'.tr, + Get.find().tokenPassenger); + walletChecked == 'true'; + update(); + } + }); + } else { + Get.defaultDialog( + title: '${'The price must be over than '.tr}$priceOfTrip', + middleText: '', + confirm: MyElevatedButton( + title: 'Ok'.tr, + onPressed: () { + Get.back(); + })); + } } } diff --git a/lib/views/Rate/rate_passenger.dart b/lib/views/Rate/rate_passenger.dart index dd60653..f90224c 100644 --- a/lib/views/Rate/rate_passenger.dart +++ b/lib/views/Rate/rate_passenger.dart @@ -93,56 +93,61 @@ class RatePassenger extends StatelessWidget { ], )), ), - controller.ispassengerWantWalletFromDriver - ? Container( - decoration: AppStyle.boxDecoration1, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Text( - "How much Passenger pay?".tr, - style: AppStyle.title, - ), - Form( - key: controller.formKey, - child: MyTextForm( - controller: - controller.passenggerPayAmount, - label: "passenger amount to me".tr, - hint: "passenger amount to me".tr, - type: - const TextInputType.numberWithOptions( - decimal: true)), - ), - MyElevatedButton( - title: "Press here".tr, - onPressed: () { - controller.addPassengerWallet(); - }) - ], - ), - ), - ) - : Container( - width: Get.width * .73, - decoration: AppStyle.boxDecoration1, - child: Column( - children: [ - Text( - "Would the passenger like to settle the remaining fare using their wallet?" - .tr, - style: AppStyle.title, - textAlign: TextAlign.center, - ), - MyElevatedButton( - title: "Press here".tr, - onPressed: () { - controller.passengerWantPay(); - }) - ], - ), - ), + controller.walletChecked != 'true' + ? GetBuilder(builder: (controller) { + return controller.ispassengerWantWalletFromDriver + ? Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Text( + "How much Passenger pay?".tr, + style: AppStyle.title, + ), + Form( + key: controller.formKey, + child: MyTextForm( + controller: + controller.passengerPayAmount, + label: + "passenger amount to me".tr, + hint: "passenger amount to me".tr, + type: const TextInputType + .numberWithOptions( + decimal: true)), + ), + MyElevatedButton( + title: "Press here".tr, + onPressed: () { + controller.addPassengerWallet(); + }) + ], + ), + ), + ) + : Container( + width: Get.width * .73, + decoration: AppStyle.boxDecoration1, + child: Column( + children: [ + Text( + "Would the passenger like to settle the remaining fare using their wallet?" + .tr, + style: AppStyle.title, + textAlign: TextAlign.center, + ), + MyElevatedButton( + title: "Press here".tr, + onPressed: () { + controller.passengerWantPay(); + }) + ], + ), + ); + }) + : const SizedBox(), const SizedBox( height: 20, ), diff --git a/lib/views/Rate/ride_calculate_driver.dart b/lib/views/Rate/ride_calculate_driver.dart index 82623d6..e4fd378 100644 --- a/lib/views/Rate/ride_calculate_driver.dart +++ b/lib/views/Rate/ride_calculate_driver.dart @@ -237,7 +237,7 @@ class RideCalculateDriver extends StatelessWidget { ), bottomTitles: AxisTitles( axisNameWidget: Text( - '${"Total rides on month".tr} = ${durationController.jsonData2['message'][0]['totalCount'].toString()}' + '${"Total budgets on month".tr} = ${durationController.jsonData2['message'][0]['totalPrice'].toString()}' .tr, style: AppStyle.title, ), @@ -246,7 +246,7 @@ class RideCalculateDriver extends StatelessWidget { reservedSize: 30, showTitles: true)), leftTitles: AxisTitles( axisNameWidget: Text( - 'Counts of rides on days'.tr, + 'Counts of budgets on days'.tr, style: AppStyle.title, ), axisNameSize: 30, diff --git a/lib/views/home/Captin/home_captain/home_captin.dart b/lib/views/home/Captin/home_captain/home_captin.dart index 873ab7d..486b7c6 100644 --- a/lib/views/home/Captin/home_captain/home_captin.dart +++ b/lib/views/home/Captin/home_captain/home_captin.dart @@ -41,7 +41,7 @@ class HomeCaptain extends StatelessWidget { style: AppStyle.title, ))), IconButton( - // onPressed: () => box.remove(BoxName.periods), + // onPressed: () => Get.find().getSQL(), onPressed: () => sql.deleteAllData(TableName.driverOrdersRefuse), icon: const Icon(Icons.remove)), // GetBuilder( 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 379897e..ecc6b36 100644 --- a/lib/views/home/Captin/home_captain/widget/call_page.dart +++ b/lib/views/home/Captin/home_captain/widget/call_page.dart @@ -7,23 +7,22 @@ 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 '../../../../../controller/functions/call_controller.dart'; -import '../../../../../main.dart'; class CallPage extends StatelessWidget { const CallPage({super.key}); @override Widget build(BuildContext context) { - return MyScafolld(title: 'Call Page', isleading: true, body: [callPage()]); + return MyScafolld( + title: 'Call Page'.tr, isleading: true, body: [callPage()]); } } GetBuilder callPage() { CallController callController = Get.put(CallController()); Get.put(MapDriverController()); - callController.initAgoraFull(); + // callController.join(); return GetBuilder( builder: (controller) => Positioned( top: Get.height * .2, @@ -35,19 +34,6 @@ GetBuilder callPage() { children: [ GestureDetector( onTap: () async { - // await callController.initAgoraFull(); - // callController.join(); - FirebaseMessagesController().sendNotificationToPassengerToken( - 'Call Income', - 'You have call from driver ${box.read(BoxName.nameDriver)}', - Get.find().tokenPassenger, - [ - callController.token, - callController.channelName, - callController.uid.toString(), - callController.remoteUid.toString(), - ], - ); callController.join(); }, child: Container( diff --git a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart index 185a196..734f9aa 100644 --- a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart +++ b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart @@ -123,12 +123,12 @@ class PassengerInfoWindow extends StatelessWidget { controller.hours > 1 ? '⌚️ ${controller.hours}h ${controller.minutes}m' // Ride Duration with emoji : '⌚️ ${controller.minutes}m', // Short ride duration - style: AppStyle.title, + style: AppStyle.number, ), ), ), const SizedBox( - width: 16.0), // Add spacing between sections + width: 10.0), // Add spacing between sections Container( decoration: AppStyle.boxDecoration1, width: Get.width * .22, @@ -136,7 +136,7 @@ class PassengerInfoWindow extends StatelessWidget { padding: const EdgeInsets.all(4), child: Text( ' ${controller.distance} km', // Distance with emoji - style: AppStyle.title, + style: AppStyle.number, ), ), ), @@ -166,11 +166,11 @@ class PassengerInfoWindow extends StatelessWidget { padding: const EdgeInsets.all(4), child: Row( children: [ - Text('Total Cost is '.tr, + Text("cost is ".tr, style: AppStyle.title), Text( controller.totalPassenger.toString(), - style: AppStyle.title, + style: AppStyle.number, ), ], ), @@ -181,7 +181,7 @@ class PassengerInfoWindow extends StatelessWidget { width: Get.width * .4, child: Padding( padding: const EdgeInsets.all(4), - child: Text(controller.carType, + child: Text(controller.carType.tr, style: AppStyle.title), ), ), diff --git a/lib/views/home/Captin/mapDriverWidgets/sos_connect.dart b/lib/views/home/Captin/mapDriverWidgets/sos_connect.dart index c89177d..6c78ba6 100644 --- a/lib/views/home/Captin/mapDriverWidgets/sos_connect.dart +++ b/lib/views/home/Captin/mapDriverWidgets/sos_connect.dart @@ -99,7 +99,7 @@ class SosConnect extends StatelessWidget { } else { launchCommunication( 'whatsapp', - '+02${box.read(BoxName.sosPhoneDriver)}', //todo add number from driver + '+2${box.read(BoxName.sosPhoneDriver)}', //todo add number from driver "${"Hello this is Driver".tr} ${box.read(BoxName.nameDriver)}.${" My current location is:".tr} https://www.google.com/maps/place/${Get.find().myLocation.latitude},${Get.find().myLocation.longitude}${" \nand I have a trip on".tr} ${AppInformation.appName} ${"App \nwith Passenger ".tr}${mapDriverController.passengerName}"); } }, diff --git a/lib/views/home/my_wallet/walet_captain.dart b/lib/views/home/my_wallet/walet_captain.dart index cee131b..0ad5dff 100644 --- a/lib/views/home/my_wallet/walet_captain.dart +++ b/lib/views/home/my_wallet/walet_captain.dart @@ -1,5 +1,6 @@ import 'package:SEFER/controller/functions/tts.dart'; import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; +import 'package:SEFER/controller/home/payment/paymob_payout.dart'; import 'package:SEFER/views/home/my_wallet/payment_history_driver_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -433,50 +434,178 @@ class CardSeferWalletDriver extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - width: Get.width * .85, - height: Get.height * .25, - decoration: BoxDecoration( - color: AppColor.deepPurpleAccent, - borderRadius: const BorderRadius.all(Radius.circular(12)), - gradient: const LinearGradient( - colors: [AppColor.blueColor, AppColor.primaryColor]), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Row( + GetBuilder(builder: (captainWalletController) { + return InkWell( + onTap: () { + Get.defaultDialog( + barrierDismissible: false, + title: 'Do you want to collect your earnings?'.tr, + titleStyle: AppStyle.title, + content: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Total wallet is '.tr, + style: AppStyle.title, + ), + const SizedBox( + width: 5, + ), + Text( + Get.find().totalAmountVisa, + style: AppStyle.number, + ), + ], + ), + const SizedBox( + height: 5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Wallet Type'.tr, + style: AppStyle.title, + ), + const SizedBox( + width: 5, + ), + MyDropDown(), + ], + ), + Form( + key: captainWalletController.formKey, + child: MyTextForm( + controller: captainWalletController.issurWallet, + label: "Enter your wallet number".tr, + hint: "Enter your wallet number".tr, + type: TextInputType.phone, + ), + ) + ], + ), + confirm: MyElevatedButton( + title: 'Ok'.tr, + onPressed: () async { + if (captainWalletController.formKey.currentState! + .validate()) { + if (double.parse(Get.find() + .totalAmountVisa) > + 100) { + Get.back(); + await Get.put(PaymobPayout()).payToWalletDriverAll( + Get.find().totalAmountVisa, + captainWalletController.issurWallet.toString(), + captainWalletController.issurWallet.toString(), + ); + } else { + Get.snackbar( + '${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}', + '', + backgroundColor: AppColor.yellowColor); + } + } + }, + kolor: AppColor.greenColor, + ), + cancel: MyElevatedButton( + title: 'cancel'.tr, + onPressed: () { + Get.back(); + }, + kolor: AppColor.redColor, + )); + }, + child: Container( + width: Get.width * .85, + height: Get.height * .25, + decoration: BoxDecoration( + color: AppColor.deepPurpleAccent, + borderRadius: const BorderRadius.all(Radius.circular(12)), + gradient: const LinearGradient( + colors: [AppColor.blueColor, AppColor.primaryColor]), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - '${AppInformation.appName} Wallet', - style: AppStyle.headTitle - .copyWith(color: AppColor.primaryColor), + Row( + children: [ + Text( + '${AppInformation.appName} Wallet', + style: AppStyle.headTitle + .copyWith(color: AppColor.primaryColor), + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '${Get.find().totalAmountVisa}\$' ?? + '0.0 \$', + style: AppStyle.headTitle2, + ) + ], + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + box.read(BoxName.nameDriver), + style: AppStyle.title, + ), + Text( + "Cash Out".tr, + style: AppStyle.title, + ) + ], + ), ) ], ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '${Get.find().totalAmountVisa}\$' ?? - '0.0 \$', - style: AppStyle.headTitle2, - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - box.read(BoxName.nameDriver), - style: AppStyle.title, - ) - ], - ) - ], - ), - ), + ), + ); + }), ], ); } } + +class MyDropDown extends StatefulWidget { + @override + _MyDropDownState createState() => _MyDropDownState(); +} + +class _MyDropDownState extends State { + String dropdownValue = 'Itsalate'; + + @override + Widget build(BuildContext context) { + return DropdownButton( + value: dropdownValue, + icon: const Icon(Icons.arrow_drop_down), + elevation: 16, + style: const TextStyle(color: Colors.deepPurple), + underline: Container( + height: 2, + color: Colors.deepPurpleAccent, + ), + onChanged: (String? newValue) { + setState(() { + dropdownValue = newValue!; + }); + }, + items: ['Itsalate', 'We', 'Orange', 'Vodafone'] + .map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ); + } +} diff --git a/lib/views/home/my_wallet/weekly_payment_page.dart b/lib/views/home/my_wallet/weekly_payment_page.dart index 709ec2a..c8f0033 100644 --- a/lib/views/home/my_wallet/weekly_payment_page.dart +++ b/lib/views/home/my_wallet/weekly_payment_page.dart @@ -4,6 +4,7 @@ import 'package:SEFER/constant/colors.dart'; import 'package:SEFER/constant/style.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; import 'package:SEFER/views/widgets/mycircular.dart'; +import 'package:intl/intl.dart'; import '../../../controller/payment/driver_payment_controller.dart'; @@ -27,12 +28,18 @@ class WeeklyPaymentPage extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - decoration: AppStyle.boxDecoration1, - child: Text( - controller.weeklyList[0]['totalAmount'] - .toString(), - style: AppStyle.title, + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + controller.weeklyList[0]['totalAmount'] + .toString(), + style: AppStyle.number, + ), + ), ), ), Text( @@ -57,28 +64,45 @@ class WeeklyPaymentPage extends StatelessWidget { decoration: AppStyle.boxDecoration1, child: Padding( padding: const EdgeInsets.all(4), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + child: Column( children: [ - Text( - list['amount'], - style: AppStyle.title, - ), - Text( - list['dateUpdated'], - style: AppStyle.title, - ), Card( elevation: 2, color: list['paymentMethod'] == 'visa' ? AppColor.blueColor : AppColor.secondaryColor, - child: Text( - list['paymentMethod'], - style: AppStyle.title, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + list['paymentMethod'] == 'Remainder' + ? 'Remainder'.tr + : list['paymentMethod'], + style: AppStyle.title, + ), ), ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Card( + child: Padding( + padding: + const EdgeInsets.all(8.0), + child: Text( + list['amount'], + style: AppStyle.number, + ), + ), + ), + Text( + DateFormat('yyyy-MM-dd hh:mm a') + .format(DateTime.parse( + list['dateUpdated'])), + style: AppStyle.number, + ), + ], + ), ], ), ),