From 4e35874f2b37359dbb3948e8a45a08d1d75be85e Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Fri, 12 Apr 2024 23:06:59 +0300 Subject: [PATCH] 4/12/7 --- lib/constant/links.dart | 4 +- lib/controller/firebase/firbase_messge.dart | 1 + .../home/captin/map_driver_controller.dart | 1 + .../home/map_passenger_controller.dart | 1 + .../profile/order_history_controller.dart | 2 +- lib/controller/local/translations.dart | 1 + .../passenger_wallet_history_controller.dart | 24 ++- lib/views/home/map_page_passenger.dart | 3 +- .../car_details_widget_to_go.dart | 2 +- .../payment_history_passenger_page.dart | 62 ++++--- lib/views/home/profile/order_history.dart | 163 +++++++++++------- lib/views/home/profile/taarif_page.dart | 23 ++- 12 files changed, 177 insertions(+), 110 deletions(-) diff --git a/lib/constant/links.dart b/lib/constant/links.dart index d9242c3..377c0ce 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -14,8 +14,8 @@ class AppLink { static String addTokensDriver = "$server/ride/firebase/addDriver.php"; //=======================Wallet=================== - static String wallet = '$server/ride/passengerWallet/'; - static String walletDriver = '$server/ride/driverWallet/'; + static String wallet = '$server/ride/passengerWallet'; + static String walletDriver = '$server/ride/driverWallet'; static String getAllPassengerTransaction = "$wallet/getAllPassengerTransaction.php"; static String getWalletByPassenger = "$wallet/getWalletByPassenger.php"; diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index c510908..80da3d0 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -173,6 +173,7 @@ class FirebaseMessagesController extends GetxController { } else if (message.notification!.title! == 'RideIsBegin') { Get.find().getBeginRideFromDriver(); // Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor); + box.write(BoxName.passengerWalletTotal, '0'); NotificationController() .showNotification('Trip is Begin'.tr, ''.tr, 'start'); update(); diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index 4c6e0fd..2e9a25a 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -481,6 +481,7 @@ class MapDriverController extends GetxController { }); print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); } + double pointsSubstraction = 0; pointsSubstraction = double.parse(paymentAmount) * (-1) * diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 23c5fda..87bb13f 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -668,6 +668,7 @@ class MapPassengerController extends GetxController { rideTimerBegin = false; box.write(BoxName.arrivalTime, ''); remainingTimeTimerRideBegin = 0; + box.write(BoxName.passengerWalletTotal, '0'); update(); } diff --git a/lib/controller/home/profile/order_history_controller.dart b/lib/controller/home/profile/order_history_controller.dart index 249e66b..dcddec4 100644 --- a/lib/controller/home/profile/order_history_controller.dart +++ b/lib/controller/home/profile/order_history_controller.dart @@ -21,7 +21,7 @@ class OrderHistoryController extends GetxController { 'passenger_id': box.read(BoxName.passengerID).toString(), }); if (res.toString() == 'failure') { - Get.snackbar('failure', 'message'); + // Get.snackbar('failure', 'message'); isloading = false; update(); } else { diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 39ce329..e475aad 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -440,6 +440,7 @@ class MyTranslation extends Translations { 'Submit Question': "طرح السؤال", 'Please enter your Question.': "الرجاء إدخال سؤالك.", 'Help Details': "تفاصيل المساعدة", + 'No trip yet found': 'لم يتم حجز أي رحلة بعد ', 'No Response yet.': "لا يوجد رد بعد.", ' You Earn today is ': " ما حصلت عليه اليوم هو", ' You Have in': "لديك في", diff --git a/lib/controller/payment/passenger_wallet_history_controller.dart b/lib/controller/payment/passenger_wallet_history_controller.dart index d914695..12d9454 100644 --- a/lib/controller/payment/passenger_wallet_history_controller.dart +++ b/lib/controller/payment/passenger_wallet_history_controller.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:SEFER/constant/style.dart'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/links.dart'; @@ -16,11 +18,23 @@ class PassengerWalletHistoryController extends GetxController { var res = await CRUD().get( link: AppLink.getPassengerWalletArchive, payload: {'passenger_id': box.read(BoxName.passengerID)}); - - archive = jsonDecode(res)['message']; - print(archive); - isLoading = false; - update(); + if (res != 'failure') { + archive = jsonDecode(res)['message']; + print(archive); + isLoading = false; + update(); + } else {} + Get.defaultDialog( + barrierDismissible: false, + title: 'No wallet record found'.tr, + titleStyle: AppStyle.title, + middleText: '', + confirm: MyElevatedButton( + title: 'OK'.tr, + onPressed: () { + Get.back(); + Get.back(); + })); } @override diff --git a/lib/views/home/map_page_passenger.dart b/lib/views/home/map_page_passenger.dart index 060ac68..f4a65b0 100644 --- a/lib/views/home/map_page_passenger.dart +++ b/lib/views/home/map_page_passenger.dart @@ -42,7 +42,8 @@ class MapPagePassenger extends StatelessWidget { const MapMenuWidget(), const MenuIconMapPageWidget(), buttomSheetMapPage(), - CarDetailsTypeToChoose(), const Burc(), + CarDetailsTypeToChoose(), + const Burc(), const ApplyOrderWidget(), // hexagonClipper(), const CancelRidePageShow(), diff --git a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart index e91c56e..ec669e5 100644 --- a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart +++ b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart @@ -422,7 +422,7 @@ class Burc extends StatelessWidget { ' in your' .tr + ' ${AppInformation.appName}' - '\n wallet due to a previous trip.' + ' wallet due to a previous trip.' .tr, textAlign: TextAlign.center, style: AppStyle.subtitle, diff --git a/lib/views/home/my_wallet/payment_history_passenger_page.dart b/lib/views/home/my_wallet/payment_history_passenger_page.dart index a6c8aba..2ecc4a0 100644 --- a/lib/views/home/my_wallet/payment_history_passenger_page.dart +++ b/lib/views/home/my_wallet/payment_history_passenger_page.dart @@ -18,34 +18,42 @@ class PaymentHistoryPassengerPage extends StatelessWidget { GetBuilder( builder: (controller) => controller.isLoading ? const MyCircularProgressIndicator() - : ListView.builder( - itemCount: controller.archive.length, - itemBuilder: (BuildContext context, int index) { - var list = controller.archive[index]; - return Padding( - padding: const EdgeInsets.all(4), - child: Container( - decoration: BoxDecoration( - color: double.parse(list['balance']) < 0 - ? AppColor.redColor.withOpacity(.4) - : AppColor.greenColor.withOpacity(.4)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - list['balance'], - style: AppStyle.title, - ), - Text( - list['created_at'], - style: AppStyle.title, - ), - ], - ), + : controller.archive.isEmpty + ? Center( + child: Text( + 'No wallet record found'.tr, + style: AppStyle.title, ), - ); - }, - ), + ) + : ListView.builder( + itemCount: controller.archive.length, + itemBuilder: (BuildContext context, int index) { + var list = controller.archive[index]; + return Padding( + padding: const EdgeInsets.all(4), + child: Container( + decoration: BoxDecoration( + color: double.parse(list['balance']) < 0 + ? AppColor.redColor.withOpacity(.4) + : AppColor.greenColor.withOpacity(.4)), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + list['balance'], + style: AppStyle.title, + ), + Text( + list['created_at'], + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ), ) ], isleading: true); diff --git a/lib/views/home/profile/order_history.dart b/lib/views/home/profile/order_history.dart index 093c768..e43334e 100644 --- a/lib/views/home/profile/order_history.dart +++ b/lib/views/home/profile/order_history.dart @@ -1,8 +1,11 @@ +import 'package:SEFER/controller/home/map_passenger_controller.dart'; +import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/style.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; import 'package:SEFER/views/widgets/mycircular.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import '../../../constant/colors.dart'; import '../../../controller/functions/launch.dart'; @@ -23,80 +26,106 @@ class OrderHistory extends StatelessWidget { GetBuilder( builder: (orderHistoryController) => orderHistoryController.isloading ? const MyCircularProgressIndicator() - : ListView.builder( - itemCount: - orderHistoryController.orderHistoryListPassenger.length, - itemBuilder: (BuildContext context, int index) { - final rides = - orderHistoryController.orderHistoryListPassenger[index]; - return Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(12)), - color: AppColor.secondaryColor, - boxShadow: [ - BoxShadow( - color: AppColor.accentColor, - offset: Offset(-3, -3), - blurRadius: 0, - spreadRadius: 0, - blurStyle: BlurStyle.outer), - BoxShadow( - color: AppColor.accentColor, - offset: Offset(3, 3), - blurRadius: 0, - spreadRadius: 0, - blurStyle: BlurStyle.outer) - ]), - child: Padding( + : orderHistoryController.orderHistoryListPassenger.isEmpty + ? Center( + child: Text( + 'No trip yet found'.tr, + style: AppStyle.headTitle2, + ), + ) + : ListView.builder( + itemCount: orderHistoryController + .orderHistoryListPassenger.length, + itemBuilder: (BuildContext context, int index) { + final rides = orderHistoryController + .orderHistoryListPassenger[index]; + return Padding( padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - onTap: () { - String mapUrl = - 'https://www.google.com/maps/dir/${rides['start_location']}/${rides['end_location']}/'; - // print(mapUrl); - showInBrowser(mapUrl); - }, - child: Text( - 'Click here to Show it in Map'.tr, - style: AppStyle.title, - ), - ), - Column( + child: Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text( - rides['date'], - style: AppStyle.subtitle, + InkWell( + onTap: () { + String mapUrl = + 'https://www.google.com/maps/dir/${rides['start_location']}/${rides['end_location']}/'; + // print(mapUrl); + showInBrowser(mapUrl); + }, + child: SizedBox( + height: Get.height * .2, + width: Get.width * .75, + child: GoogleMap( + initialCameraPosition: CameraPosition( + target: Get.find< + MapPassengerController>() + .passengerLocation, // Assuming passenger location is available + zoom: 15, + ), + polylines: { + Polyline( + zIndex: 2, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: + const PolylineId('route'), + points: [ + LatLng( + rides['start_location'] + ['latitude'], + rides['start_location'] + ['longitude']), + LatLng( + rides['end_location'] + ['latitude'], + rides['end_location'] + ['longitude']), + ], + color: AppColor.primaryColor, + width: 5, + ), + }, + ), + ), ), - Text( - rides['time'], - style: AppStyle.subtitle, - ), - Text( - rides['status'], - style: rides['status'] != 'Canceled'.tr - ? AppStyle.subtitle.copyWith( - color: AppColor.greenColor) - : AppStyle.subtitle - .copyWith(color: AppColor.redColor), - ), - Text( - '${'Price is'.tr} ${rides['price']}', - style: AppStyle.subtitle, + Column( + children: [ + Text( + rides['date'], + style: AppStyle.subtitle, + ), + Text( + rides['time'], + style: AppStyle.subtitle, + ), + Text( + rides['status'], + style: rides['status'] != 'Canceled'.tr + ? AppStyle.subtitle.copyWith( + color: AppColor.greenColor) + : AppStyle.subtitle.copyWith( + color: AppColor.redColor), + ), + Text( + '${'Price is'.tr} ${rides['price']}', + style: AppStyle.subtitle, + ), + ], ), ], ), - ], + ), ), - ), - ), - ); - }, - ), + ); + }, + ), ) ], ); diff --git a/lib/views/home/profile/taarif_page.dart b/lib/views/home/profile/taarif_page.dart index 1aa1b18..5090573 100644 --- a/lib/views/home/profile/taarif_page.dart +++ b/lib/views/home/profile/taarif_page.dart @@ -1,3 +1,5 @@ +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/style.dart'; @@ -25,25 +27,34 @@ class TaarifPage extends StatelessWidget { // decoration: AppStyle.boxDecoration, children: [ Text('Minimum fare'.tr, style: AppStyle.title), - Text('1 ${'JOD'.tr}', style: AppStyle.title), + box.read(BoxName.countryCode) == 'Jordan' + ? Text('1 ${'JOD'.tr}', style: AppStyle.title) + : Text('20 ${'LE'.tr}', style: AppStyle.title), ], ), TableRow( children: [ Text('Maximum fare'.tr, style: AppStyle.title), - Text('200 ${'JOD'.tr}', style: AppStyle.title), + box.read(BoxName.countryCode) == 'Jordan' + ? Text('200 ${'JOD'.tr}', style: AppStyle.title) + : Text('15000 ${'LE'.tr}', style: AppStyle.title), ], ), TableRow( children: [ Text('Flag-down fee'.tr, style: AppStyle.title), - Text('0.47 ${'JOD'.tr}', style: AppStyle.title), + box.read(BoxName.countryCode) == 'Jordan' + ? Text('0.47 ${'JOD'.tr}', style: AppStyle.title) + : Text('15 ${'LE'.tr}', style: AppStyle.title), ], ), TableRow( children: [ - Text('0.05 ${'JOD'.tr}/min and 0.21 ${'JOD'.tr}/km', - style: AppStyle.title), + box.read(BoxName.countryCode) == 'Jordan' + ? Text('0.05 ${'JOD'.tr}/min and 0.21 ${'JOD'.tr}/km', + style: AppStyle.title) + : Text('1 ${'LE'.tr}/min and 4 ${'LE'.tr}/km', + style: AppStyle.title), Text('Including Tax'.tr, style: AppStyle.title), ], ), @@ -52,7 +63,7 @@ class TaarifPage extends StatelessWidget { const SizedBox(height: 10), Text('BookingFee'.tr, style: AppStyle.headTitle2), const SizedBox(height: 10), - Text('4.17%', style: AppStyle.title), + Text('10%', style: AppStyle.title), const SizedBox(height: 20), Text('Morning'.tr, style: AppStyle.headTitle2), const SizedBox(height: 10),