From 1f333852ac461607a5209ce46354645533bc3bab Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Thu, 18 Apr 2024 00:53:16 +0300 Subject: [PATCH] 4/18/1 --- lib/controller/local/translations.dart | 7 +- .../payment/payment_controller.dart | 3 + lib/controller/payment/paymob.dart | 64 ++++- .../Captin/history/history_details_page.dart | 268 +++++++++++------- lib/views/home/Captin/settings_captain.dart | 20 +- lib/views/home/home_page.dart | 88 +++--- .../map_widget.dart/left_main_menu_icons.dart | 2 +- .../home/my_wallet/passenger_wallet.dart | 95 ++++--- .../my_wallet/passenger_wallet_dialoge.dart | 2 +- lib/views/home/profile/order_history.dart | 118 ++++---- .../home/profile/passenger_profile_page.dart | 81 +++++- 11 files changed, 493 insertions(+), 255 deletions(-) diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 3861358..505091e 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -160,7 +160,7 @@ class MyTranslation extends Translations { "Copy this Promo to use it in your Ride!": "انسخ هذا العرض لاستخدامه في رحلتك!", "To change some Settings": "لتغيير بعض الإعدادات", - "To change Languge the App": "لتغيير لغة التطبيق", + "To change Language the App": "لتغيير لغة التطبيق", "Order Request Page": "صفحة طلب الطلب", "Rouats of Trip": "طرق الرحلة", "Passenger Name is ": "اسم الراكب هو ", @@ -688,6 +688,9 @@ class MyTranslation extends Translations { "إذا كنت تريد أن تفتح تطبيق خرائط جوجل مباشرة عند طلب الخدمة", "You can change the language of the app": "يمكنك تغيير لغة التطبيق", 'Your Budget less than needed': 'القيمه المدخله اقل من رصيدك', + 'You can change the Country to get all features': + 'يمكنك تغيير البلد للحصول على جميع الميزات', + 'Change Country': '‏تغيير الدولة', }, "tr": { "Choose Language": "Dil Seçin", @@ -849,7 +852,7 @@ class MyTranslation extends Translations { "Copy this Promo to use it in your Ride!": "Bu Promosyonu seyahatinizde kullanmak için kopyalayın!", "To change some Settings": "Bazı ayarları değiştirmek için", - "To change Languge the App": "Uygulama dilini değiştirmek için", + "To change Language the App": "Uygulama dilini değiştirmek için", "Order Request Page": "Sipariş istek sayfası", "Rouats of Trip": "Seyahat yolları", "Passenger Name is ": "Yolcu adı ", diff --git a/lib/controller/payment/payment_controller.dart b/lib/controller/payment/payment_controller.dart index c5bf497..d8a8638 100644 --- a/lib/controller/payment/payment_controller.dart +++ b/lib/controller/payment/payment_controller.dart @@ -496,6 +496,7 @@ class PaymentController extends GetxController { ), confirm: MyElevatedButton( title: 'OK'.tr, + kolor: AppColor.greenColor, onPressed: () async { Get.back(); method(); @@ -543,11 +544,13 @@ class PaymentController extends GetxController { barrierDismissible: false, title: 'Payment Successful'.tr, titleStyle: AppStyle.title, + // backgroundColor: AppColor.greenColor, content: Text( 'The payment was approved.'.tr, style: AppStyle.title, ), confirm: MyElevatedButton( + kolor: AppColor.greenColor, title: 'OK'.tr, onPressed: () async { Get.back(); diff --git a/lib/controller/payment/paymob.dart b/lib/controller/payment/paymob.dart index bca93d2..0947351 100644 --- a/lib/controller/payment/paymob.dart +++ b/lib/controller/payment/paymob.dart @@ -39,15 +39,67 @@ class PaymobManager extends GetxController { } Future payWithPayMob(int amount, String currency) async { - String key = await PaymobManager().getPaymentKey(amount, currency); - await launchUrl( - Uri.parse( - 'https://accept.paymob.com/api/acceptance/iframes/837992?payment_token=$key'), - ); + // 1. Fetch Payment Key (Assuming PaymobManager is a custom class) + String paymentToken; + try { + paymentToken = await PaymobManager().getPaymentKey(amount, currency); + } on Exception catch (e) { + // Handle errors gracefully, e.g., display error message to user + print("Error fetching payment key: $e"); + return; + } - // String paymentStatus = await _getStatusAfterPaid(); + // 2. Prepare Payment Data Payload + final Map data = { + "source": { + "identifier": "01010101010", // Replace with actual source identifier + "subtype": "WALLET", + }, + "payment_token": paymentToken, + }; + + // 3. Make Payment Request using Dio + final dio = Dio(); + try { + final response = await dio.post( + 'https://accept.paymob.com/api/acceptance/payments/pay', + data: data, + ); + + // 4. Handle Payment Response + if (response.statusCode == 200) { + // Payment successful: Process response data (e.g., transaction ID) + final paymentData = response.data; // Assuming JSON response + print("Payment successful: $paymentData"); + // Navigate to success screen or display success message + } else { + // Payment failed: Handle errors (e.g., display error message) + print("Payment failed: ${response.statusCode} - ${response.data}"); + } + } on DioError catch (e) { + // Handle network or Dio-related errors + print("Error making payment request: $e"); + } } + // Future payWithPayMob(int amount, String currency) async { + // String key = await PaymobManager().getPaymentKey(amount, currency); + // await launchUrl(Uri.parse( + // // 'https://accept.paymob.com/api/acceptance/iframes/837992?payment_token=$key'), + // 'https://accept.paymob.com/api/acceptance/payments/pay')); + // print(key); + // final dio.Response response = await Dio() + // .post('https://accept.paymob.com/api/acceptance/payments/pay', data: { + // "source": { + // "identifier": "01010101010", + // "subtype": "WALLET", + // }, + // "payment_token": key, // token obtained in step 3 + // }); + // + // // String paymentStatus = await _getStatusAfterPaid(); + // } + Future _getStatusAfterPaid() async { print(authanticationToken1); print(orderId1); diff --git a/lib/views/home/Captin/history/history_details_page.dart b/lib/views/home/Captin/history/history_details_page.dart index 93392f2..d8de8ec 100644 --- a/lib/views/home/Captin/history/history_details_page.dart +++ b/lib/views/home/Captin/history/history_details_page.dart @@ -1,3 +1,4 @@ +import 'package:SEFER/controller/functions/location_controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/colors.dart'; @@ -5,6 +6,7 @@ import 'package:SEFER/constant/style.dart'; import 'package:SEFER/controller/auth/captin/history_captain.dart'; import 'package:SEFER/controller/functions/launch.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import '../../../widgets/mycircular.dart'; @@ -20,133 +22,181 @@ class HistoryDetailsPage extends StatelessWidget { GetBuilder( builder: (historyCaptainController) { var res = historyCaptainController.historyDetailsData['data']; - return Expanded( - child: historyCaptainController.isloading - ? const MyCircularProgressIndicator() - : SingleChildScrollView( - child: Column( - children: [ - Container( - width: Get.width * .8, - decoration: BoxDecoration( - border: Border.all( - color: AppColor.blueColor, width: 2)), - child: TextButton( - onPressed: () { - String mapUrl = - 'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/'; - print(mapUrl); - showInBrowser(mapUrl); - }, - child: Text( - 'Trip on Map Click here'.tr, - style: AppStyle.title, - ), + return historyCaptainController.isloading + ? const MyCircularProgressIndicator() + : SingleChildScrollView( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: Get.width * .8, + decoration: BoxDecoration( + border: Border.all( + color: AppColor.blueColor, width: 2)), + child: TextButton( + onPressed: () { + String mapUrl = + 'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/'; + print(mapUrl); + showInBrowser(mapUrl); + }, + child: Column( + children: [ + SizedBox( + height: Get.height * .2, + width: Get.width * .75, + child: GoogleMap( + initialCameraPosition: CameraPosition( + target: Get.find() + .myLocation, // Assuming passenger location is available + tilt: 80, zoom: 13, + ), + zoomControlsEnabled: true, + // liteModeEnabled: true, + polylines: { + Polyline( + zIndex: 2, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: const PolylineId('route'), + points: [ + LatLng( + double.parse(res['start_location'] + .toString() + .split(',')[0]), + double.parse(res['start_location'] + .toString() + .split(',')[1]), + ), + LatLng( + double.parse(res['end_location'] + .toString() + .split(',')[0]), + double.parse(res['end_location'] + .toString() + .split(',')[1]), + ) + ], + color: AppColor.primaryColor, + width: 5, + ), + }, + ), + ), + const SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Text( + '${'Order ID'.tr} ${res['id']}', + style: AppStyle.title, + ), + Text( + res['date'].toString(), + style: AppStyle.title, + ), + ], + ), + ], ), ), - const SizedBox( - height: 10, - ), - Row( + ), + const SizedBox( + height: 10, + ), + Container( + width: Get.width * .8, + decoration: BoxDecoration( + border: Border.all( + color: AppColor.greenColor, width: 2)), + child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( - '${'Order ID'.tr} ${res['id']}', + '${'Price is'.tr} ${res['price_for_driver']}', style: AppStyle.title, ), Text( - res['date'].toString(), + '${'Distance is'.tr} ${res['distance']} KM', style: AppStyle.title, ), ], ), - const SizedBox( - height: 10, - ), - Container( - width: Get.width * .8, - decoration: BoxDecoration( - border: Border.all( - color: AppColor.greenColor, width: 2)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Text( - '${'Price is'.tr} ${res['price_for_driver']}', - style: AppStyle.title, - ), - Text( - '${'Distance is'.tr} ${res['distance']} KM', - style: AppStyle.title, - ), - ], - ), - ), - const SizedBox( - height: 10, - ), - Text( - 'Times of Trip'.tr, - style: AppStyle.title, - ), - const SizedBox( - height: 10, - ), - Container( - width: Get.width * .8, - decoration: BoxDecoration( - border: Border.all( - color: AppColor.redColor, width: 2)), - child: Column( - children: [ - Text( - '${'Time to Passenger is'.tr} ${res['DriverIsGoingToPassenger']}', - style: AppStyle.title, - ), - Text( - '${'TimeStart is'.tr} ${res['rideTimeStart']}', - style: AppStyle.title, - ), - Text( - '${'Time Finish is'.tr} ${res['rideTimeFinish']}', - style: AppStyle.title, - ), - ], - ), - ), - const SizedBox( - height: 10, - ), - Container( - width: Get.width * .8, - decoration: BoxDecoration( - border: Border.all( - color: AppColor.greenColor, width: 2)), - child: Center( - child: Text( - '${'Passenger Name is'.tr} ${res['first_name']} ${res['last_name']} ', + ), + const SizedBox( + height: 10, + ), + Text( + 'Times of Trip'.tr, + style: AppStyle.title, + ), + const SizedBox( + height: 10, + ), + Container( + width: Get.width * .8, + decoration: BoxDecoration( + border: Border.all( + color: AppColor.redColor, width: 2)), + child: Column( + children: [ + Text( + '${'Time to Passenger is'.tr} ${res['DriverIsGoingToPassenger']}', style: AppStyle.title, ), - ), - ), - const SizedBox( - height: 10, - ), - Container( - width: Get.width * .8, - decoration: BoxDecoration( - border: Border.all( - color: AppColor.yellowColor, width: 2)), - child: Center( - child: Text( - '${'Status is'.tr} ${res['status']}', + Text( + '${'TimeStart is'.tr} ${res['rideTimeStart']}', style: AppStyle.title, ), + Text( + '${'Time Finish is'.tr} ${res['rideTimeFinish']}', + style: AppStyle.title, + ), + ], + ), + ), + const SizedBox( + height: 10, + ), + Container( + width: Get.width * .8, + decoration: BoxDecoration( + border: Border.all( + color: AppColor.greenColor, width: 2)), + child: Center( + child: Text( + '${'Passenger Name is'.tr} ${res['first_name']} ${res['last_name']} ', + style: AppStyle.title, ), ), - ], - ), - )); + ), + const SizedBox( + height: 10, + ), + Container( + width: Get.width * .8, + decoration: BoxDecoration( + border: Border.all( + color: AppColor.yellowColor, width: 2)), + child: Center( + child: Text( + '${'Status is'.tr} ${res['status']}', + style: AppStyle.title, + ), + ), + ), + ], + ), + ), + ); }) ], isleading: true, diff --git a/lib/views/home/Captin/settings_captain.dart b/lib/views/home/Captin/settings_captain.dart index 625c483..25b8a50 100644 --- a/lib/views/home/Captin/settings_captain.dart +++ b/lib/views/home/Captin/settings_captain.dart @@ -1,5 +1,6 @@ import 'package:SEFER/constant/colors.dart'; import 'package:SEFER/controller/profile/setting_controller.dart'; +import 'package:SEFER/views/home/profile/passenger_profile_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_font_icons/flutter_font_icons.dart'; @@ -25,13 +26,30 @@ class SettingsCaptain extends StatelessWidget { 'Language'.tr, style: AppStyle.headTitle2, ), - subtitle: Text('ou can change the language of the app'.tr), + subtitle: Text('You can change the language of the app'.tr), onTap: () => Get.to(const Language()), ), const Divider( endIndent: 44, indent: 44, ), + ListTile( + leading: const Icon(Icons.place_outlined), + title: Text( + 'Change Country'.tr, + style: AppStyle.headTitle2, + ), + subtitle: + Text('You can change the Country to get all features'.tr), + onTap: () => Get.to(MyScafolld( + title: 'Change Country'.tr, + body: [CountryPickerFromSetting()], + isleading: true)), + ), + const Divider( + endIndent: 44, + indent: 44, + ), ListTile( leading: const Icon( MaterialCommunityIcons.map_marker_radius, diff --git a/lib/views/home/home_page.dart b/lib/views/home/home_page.dart index 3325e5f..37134b7 100644 --- a/lib/views/home/home_page.dart +++ b/lib/views/home/home_page.dart @@ -5,6 +5,8 @@ import 'package:SEFER/constant/style.dart'; import 'package:SEFER/views/lang/languages.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; +import 'profile/passenger_profile_page.dart'; + class HomePage extends StatelessWidget { const HomePage({super.key}); @@ -16,47 +18,57 @@ class HomePage extends StatelessWidget { body: [ Column( children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), - child: ListTile( - title: Text( - 'Settings'.tr, - style: AppStyle.title, - ), - subtitle: Text('To change some Settings'.tr), - trailing: const Icon( - Icons.arrow_forward_ios, - size: 30, - color: AppColor.primaryColor, - ), - leading: const Icon( - Icons.settings, - color: AppColor.primaryColor, - ), + // Padding( + // padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), + // child: ListTile( + // title: Text( + // 'Settings'.tr, + // style: AppStyle.headTitle2, + // ), + // subtitle: Text('To change some Settings'.tr), + // trailing: const Icon( + // Icons.arrow_forward_ios, + // size: 30, + // color: AppColor.primaryColor, + // ), + // leading: const Icon( + // Icons.settings, + // color: AppColor.primaryColor, + // ), + // ), + // ), + ListTile( + onTap: () { + Get.to(() => const Language()); + }, + title: Text( + 'Language'.tr, + style: AppStyle.headTitle2, + ), + subtitle: Text('To change Language the App'.tr), + trailing: const Icon( + Icons.arrow_forward_ios, + size: 30, + color: AppColor.primaryColor, + ), + leading: const Icon( + Icons.language_sharp, + color: AppColor.primaryColor, ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), - child: ListTile( - onTap: () { - Get.to(() => const Language()); - }, - title: Text( - 'Language'.tr, - style: AppStyle.title, - ), - subtitle: Text('To change Languge the App'.tr), - trailing: const Icon( - Icons.arrow_forward_ios, - size: 30, - color: AppColor.primaryColor, - ), - leading: const Icon( - Icons.language_sharp, - color: AppColor.primaryColor, - ), + ListTile( + leading: const Icon(Icons.place_outlined), + title: Text( + 'Change Country'.tr, + style: AppStyle.headTitle2, ), - ) + subtitle: + Text('You can change the Country to get all features'.tr), + onTap: () => Get.to(MyScafolld( + title: 'Change Country'.tr, + body: [CountryPickerFromSetting()], + isleading: true)), + ), ], ), ], diff --git a/lib/views/home/map_widget.dart/left_main_menu_icons.dart b/lib/views/home/map_widget.dart/left_main_menu_icons.dart index a9272e0..03437e4 100644 --- a/lib/views/home/map_widget.dart/left_main_menu_icons.dart +++ b/lib/views/home/map_widget.dart/left_main_menu_icons.dart @@ -113,7 +113,7 @@ GetBuilder leftMainMenuIcons() { borderRadius: BorderRadius.circular(15)), child: IconButton( onPressed: () async { - // await PaymobManager().payWithPayMob(100, 'EGP'); + await PaymobManager().payWithPayMob(100, 'EGP'); // await Get.find() // .payWithPayMob(context, '1100', 'EGP'); // Initiates a payment with a card using the FlutterPaymob instance diff --git a/lib/views/home/my_wallet/passenger_wallet.dart b/lib/views/home/my_wallet/passenger_wallet.dart index 8937d1a..4c685f3 100644 --- a/lib/views/home/my_wallet/passenger_wallet.dart +++ b/lib/views/home/my_wallet/passenger_wallet.dart @@ -82,52 +82,55 @@ class CardSeferWallet extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: Get.width * .85, - height: Get.height * .3, - decoration: BoxDecoration( - color: AppColor.deepPurpleAccent, - borderRadius: const BorderRadius.all(Radius.circular(12)), - gradient: const LinearGradient( - colors: [AppColor.blueColor, AppColor.primaryColor]), + return GetBuilder(builder: (paymentController) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: Get.width * .85, + height: Get.height * .3, + 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( + children: [ + Text( + '${AppInformation.appName} Wallet', + style: AppStyle.headTitle + .copyWith(color: AppColor.primaryColor), + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '${box.read(BoxName.passengerWalletTotal)} \$' ?? + '0.0 \$', + style: AppStyle.headTitle2, + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + box.read(BoxName.name), + style: AppStyle.title, + ) + ], + ) + ], + ), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Row( - children: [ - Text( - '${AppInformation.appName} Wallet', - style: AppStyle.headTitle - .copyWith(color: AppColor.primaryColor), - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '${box.read(BoxName.passengerWalletTotal)} \$' ?? '0.0 \$', - style: AppStyle.headTitle2, - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - box.read(BoxName.name), - style: AppStyle.title, - ) - ], - ) - ], - ), - ), - ], - ); + ], + ); + }); } } diff --git a/lib/views/home/my_wallet/passenger_wallet_dialoge.dart b/lib/views/home/my_wallet/passenger_wallet_dialoge.dart index 0a92d35..5148415 100644 --- a/lib/views/home/my_wallet/passenger_wallet_dialoge.dart +++ b/lib/views/home/my_wallet/passenger_wallet_dialoge.dart @@ -64,7 +64,7 @@ class PassengerWalletDialoge extends StatelessWidget { Text( box.read(BoxName.countryCode) == 'Egypt' ? '100 ${'LE'.tr}'.tr - : '10\$ and get 3% discount', + : '10 ${'JOD'.tr}'.tr, style: AppStyle.title, ), ], diff --git a/lib/views/home/profile/order_history.dart b/lib/views/home/profile/order_history.dart index e43334e..d14ce97 100644 --- a/lib/views/home/profile/order_history.dart +++ b/lib/views/home/profile/order_history.dart @@ -37,26 +37,29 @@ class OrderHistory extends StatelessWidget { itemCount: orderHistoryController .orderHistoryListPassenger.length, itemBuilder: (BuildContext context, int index) { - final rides = orderHistoryController - .orderHistoryListPassenger[index]; + // Use integer index here + final rides = + orderHistoryController.orderHistoryListPassenger[ + index]; // Access data using index + return Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: AppStyle.boxDecoration1, - child: 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: SizedBox( + child: InkWell( + onTap: () { + String mapUrl = + 'https://www.google.com/maps/dir/${rides['start_location']}/${rides['end_location']}/'; + // print(mapUrl); + showInBrowser(mapUrl); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + SizedBox( height: Get.height * .2, width: Get.width * .75, child: GoogleMap( @@ -66,6 +69,8 @@ class OrderHistory extends StatelessWidget { .passengerLocation, // Assuming passenger location is available zoom: 15, ), + zoomControlsEnabled: true, + liteModeEnabled: true, polylines: { Polyline( zIndex: 2, @@ -78,15 +83,25 @@ class OrderHistory extends StatelessWidget { const PolylineId('route'), points: [ LatLng( - rides['start_location'] - ['latitude'], - rides['start_location'] - ['longitude']), + double.parse( + rides['start_location'] + .toString() + .split(',')[0]), + double.parse( + rides['start_location'] + .toString() + .split(',')[1]), + ), LatLng( - rides['end_location'] - ['latitude'], - rides['end_location'] - ['longitude']), + double.parse( + rides['end_location'] + .toString() + .split(',')[0]), + double.parse( + rides['end_location'] + .toString() + .split(',')[1]), + ) ], color: AppColor.primaryColor, width: 5, @@ -94,32 +109,35 @@ class OrderHistory extends StatelessWidget { }, ), ), - ), - 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, - ), - ], - ), - ], + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + 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/passenger_profile_page.dart b/lib/views/home/profile/passenger_profile_page.dart index 9d0bb06..6f6672b 100644 --- a/lib/views/home/profile/passenger_profile_page.dart +++ b/lib/views/home/profile/passenger_profile_page.dart @@ -363,8 +363,10 @@ class CountryPicker extends StatelessWidget { Get.find().saveCountryCode(controller .selectedCountry .toString()); // No conversion needed - box.write(BoxName.countryCode, + box.write( + BoxName.countryCode, // controller.selectedCountry); // Already saved in English + Get.snackbar(controller.selectedCountry.toString().tr, ''); Get.off(LoginPage()); }, ) @@ -373,3 +375,80 @@ class CountryPicker extends StatelessWidget { }); } } + +class CountryPickerFromSetting extends StatelessWidget { + final ProfileController controller = Get.put(ProfileController()); + final LoginController loginController = Get.put(LoginController()); + + final List countryOptions = [ + 'Jordan', + 'USA', + 'Egypt', + 'Turkey', + 'Saudi Arabia', + 'Qatar', + 'Bahrain', + 'Kuwait', + ]; + + CountryPickerFromSetting({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GetBuilder(builder: (controller) { + return ListView( + children: [ + const SizedBox( + height: 20, + ), + Text("Select Your Country".tr), + // const SizedBox( + // height: 20, + // ), + Padding( + padding: const EdgeInsets.all(10), + child: Text( + "To ensure you receive the most accurate information for your location, please select your country below. This will help tailor the app experience and content to your country." + .tr), + ), + SizedBox( + height: 200, + child: CupertinoPicker( + itemExtent: 32, + onSelectedItemChanged: (int index) { + controller.setCountry(countryOptions[index]); + box.write(BoxName.countryCode, + countryOptions[index]); // Save in English + }, + children: List.generate( + countryOptions.length, + (index) => Center( + child: Text( + countryOptions[index] + .tr, // Display translated if not English + style: AppStyle.title, + ), + ), + ), + ), + ), + + MyElevatedButton( + title: 'Select Country'.tr, // Use translated text for button + onPressed: () async { + loginController.saveCountryCode(controller.selectedCountry + .toString()); // No conversion needed + box.write( + BoxName.countryCode, // + controller.selectedCountry); // Already saved in English + Get.snackbar(controller.selectedCountry.toString().tr, '', + backgroundColor: AppColor.greenColor); + // Get.back();// + // Get.back(); + }, + ) + ], + ); + }); + } +}