From 438082625394f50b9f1d84a55f4e918803eaa2f4 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 5 Sep 2023 11:24:45 +0300 Subject: [PATCH] 9/5/1 --- lib/constant/credential.dart | 3 + lib/controller/functions/crud.dart | 2 +- lib/controller/home/map_page_controller.dart | 38 ++- lib/controller/local/local_controller.dart | 5 +- .../payment/payment_controller.dart | 8 +- .../buttom_sheet_map_show.dart | 109 +++---- .../map_widget.dart/main_bottom_Menu_map.dart | 72 +++-- .../home/map_widget.dart/map_menu_widget.dart | 280 +++++++++++++----- .../home/my_wallet/passenger_wallet.dart | 59 ++++ 9 files changed, 418 insertions(+), 158 deletions(-) create mode 100644 lib/views/home/my_wallet/passenger_wallet.dart diff --git a/lib/constant/credential.dart b/lib/constant/credential.dart index f2aa832..5b25938 100644 --- a/lib/constant/credential.dart +++ b/lib/constant/credential.dart @@ -10,4 +10,7 @@ class AppCredintials { String getBasicAuthCredentials() { return base64Encode(utf8.encode(basicAuthCredentials)); } + + static const String transactionCloude = + 'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F'; } diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index a022b83..59b8993 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -26,7 +26,7 @@ class CRUD { if (response.statusCode == 200) { var jsonData = jsonDecode(response.body); if (jsonData['status'] == 'success') { - // print(jsonData); + print(jsonData); return response.body; } return jsonData['status']; diff --git a/lib/controller/home/map_page_controller.dart b/lib/controller/home/map_page_controller.dart index 40cee5a..db3f34a 100644 --- a/lib/controller/home/map_page_controller.dart +++ b/lib/controller/home/map_page_controller.dart @@ -6,12 +6,15 @@ import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_polyline_algorithm/google_polyline_algorithm.dart'; import 'package:location/location.dart'; +import 'package:path/path.dart'; import 'package:ride/constant/box_name.dart'; +import 'package:ride/constant/colors.dart'; import 'package:ride/constant/credential.dart'; import 'package:ride/constant/links.dart'; import 'package:ride/controller/firebase/firbase_messge.dart'; import 'package:ride/controller/functions/crud.dart'; import 'package:ride/controller/functions/secure_storage.dart'; +import 'package:ride/controller/functions/toast.dart'; import 'package:ride/views/widgets/elevated_btn.dart'; import '../../main.dart'; import '../../models/model/locations.dart'; @@ -36,6 +39,7 @@ class MapController extends GetxController { final location = Location(); late LocationData currentLocation; double heightMenu = 0; + double widthMenu = 0; double heightPickerContainer = 90; double mainBottomMenuMap = Get.height * .2; bool heightMenuBool = false; @@ -99,6 +103,7 @@ class MapController extends GetxController { void getDrawerMenu() { heightMenuBool = !heightMenuBool; heightMenu = heightMenuBool == true ? 100 : 0; + widthMenu = heightMenuBool == true ? 110 : 0; update(); } @@ -197,6 +202,9 @@ class MapController extends GetxController { isMainBottomMenuMap = !isMainBottomMenuMap; mainBottomMenuMap = isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .66; + if (heightMenuBool == true) { + getDrawerMenu(); + } update(); } @@ -430,7 +438,7 @@ class MapController extends GetxController { String duratioByPassenger = ''; void getNearestDriverByPassengerLocation() async { - if (polylines.isEmpty) { + if (polylines.isEmpty || data.isEmpty) { double nearestDistance = double.infinity; for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) { var carLocation = dataCarsLocationByPassenger['message'][i]; @@ -536,16 +544,18 @@ class MapController extends GetxController { getDistanceFromText(data[0]['distance']['text']); // Animate the camera to the adjusted bounds - if (distanceOfDestnation <= 10) { + if (distanceOfDestnation <= 5) { + mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14)); + } else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) { + mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 13)); + } else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) { mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12)); - } else if (distanceOfDestnation > 10 && distanceOfDestnation < 16) { + } else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) { mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11)); - } else if (distanceOfDestnation > 16 && distanceOfDestnation < 30) { + } else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) { mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10)); - } else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8)); - } else if (distanceOfDestnation > 100) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6)); + } else if (distanceOfDestnation >= 100) { + mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 7)); } if (polylines.isNotEmpty) { clearpolyline(); @@ -579,6 +589,17 @@ class MapController extends GetxController { CRUD().get(link: AppLink.getPassengersPromo, payload: { 'promo_code': promo.text, }).then((value) { + if (value == 'failure') { + Get.defaultDialog( + title: 'Promo End !'.tr, + confirm: MyElevatedButton( + title: 'Back', + onPressed: () { + Get.back(); + Get.back(); + }, + )); + } var decod = jsonDecode(value); if (decod["status"] == "success") { @@ -589,6 +610,7 @@ class MapController extends GetxController { promoTaken = true; update(); print(totalPassenger); + Get.back(); } }); } diff --git a/lib/controller/local/local_controller.dart b/lib/controller/local/local_controller.dart index 1fff609..55a4a43 100644 --- a/lib/controller/local/local_controller.dart +++ b/lib/controller/local/local_controller.dart @@ -3,11 +3,13 @@ import 'package:get/get.dart'; import '../../constant/box_name.dart'; import '../../main.dart'; -import '../firebase/firbase_messge.dart'; import '../themes/themes.dart'; class LocaleController extends GetxController { Locale? language; + void restartApp() { + runApp(const MyApp()); + } ThemeData appTheme = themeEnglish; @@ -35,6 +37,7 @@ class LocaleController extends GetxController { box.write(BoxName.lang, langcode); Get.changeTheme(appTheme); Get.updateLocale(locale); + restartApp(); update(); } diff --git a/lib/controller/payment/payment_controller.dart b/lib/controller/payment/payment_controller.dart index 08ed29d..55d6889 100644 --- a/lib/controller/payment/payment_controller.dart +++ b/lib/controller/payment/payment_controller.dart @@ -26,8 +26,7 @@ class PaymentController extends GetxController { box.write(BoxName.passengerWalletFound, isWalletFound); // totalPassengerWalletDetails = box.read(BoxName.passengerWalletDetails); - if (totalPassengerWalletDetails == null || - totalPassengerWalletDetails.isEmpty) { + if (totalPassengerWalletDetails.isEmpty) { await CRUD().get(link: AppLink.getWalletByPassenger, payload: { 'passenger_id': box.read(BoxName.pasengerID) }).then((value) { @@ -75,9 +74,8 @@ class PaymentController extends GetxController { } @override - void onInit() async { - await getPassengerWallet(); - + void onInit() { + getPassengerWallet(); super.onInit(); } } diff --git a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart index 61c6929..299a2d5 100644 --- a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart +++ b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart @@ -7,6 +7,7 @@ import 'package:ride/views/widgets/elevated_btn.dart'; import '../../../constant/colors.dart'; import '../../../constant/style.dart'; +import '../../../controller/functions/toast.dart'; import '../../../controller/home/map_page_controller.dart'; GetBuilder buttomSheetMapPage() { @@ -233,62 +234,70 @@ GetBuilder buttomSheetMapPage() { ), InkWell( onTap: () { - Get - .defaultDialog( - title: 'Add Promo' - .tr, - content: - Column( - children: [ - SizedBox( - width: Get.width * .7, - child: TextFormField( - controller: controller.promo, - decoration: InputDecoration( - labelText: 'Promo Code'.tr, - hintText: 'Enter promo code'.tr, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), + if (controller + .promoTaken == + false) { + Get.defaultDialog( + title: 'Add Promo'.tr, + content: Column( + children: [ + SizedBox( + width: + Get.width * .7, + child: + TextFormField( + controller: controller.promo, + decoration: InputDecoration( + labelText: 'Promo Code'.tr, + hintText: 'Enter promo code'.tr, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + filled: true, + fillColor: Colors.grey[200], + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: AppColor.primaryColor, + width: 2.0, ), - filled: true, - fillColor: Colors.grey[200], - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: AppColor.primaryColor, - width: 2.0, - ), - borderRadius: BorderRadius.circular(10), + borderRadius: BorderRadius.circular(10), + ), + errorBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.red, + width: 2.0, ), - errorBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.red, - width: 2.0, - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.grey, - width: 1.0, - ), - borderRadius: BorderRadius.circular(10), + borderRadius: BorderRadius.circular(10), + ), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.grey, + width: 1.0, ), + borderRadius: BorderRadius.circular(10), ), ), ), - MyElevatedButton( - title: 'Add Promo'.tr, - onPressed: () async { - if (controller.promoTaken == false) { - controller.applyPromoCodetoPassenger(); - Get.back(); - } else { - Get.defaultDialog(title: 'You have Promo ?.'.tr); - } - }, - ) - ], - )); + ), + MyElevatedButton( + title: + 'Add Promo'.tr, + onPressed: + () async { + controller.applyPromoCodetoPassenger(); + }, + ) + ], + )); + } else { + Get.snackbar( + 'You have promo!' + .tr, + '', + backgroundColor: + AppColor + .redColor); + } }, child: Text( 'Add Promo'.tr, diff --git a/lib/views/home/map_widget.dart/main_bottom_Menu_map.dart b/lib/views/home/map_widget.dart/main_bottom_Menu_map.dart index 0e43f1f..e860ea6 100644 --- a/lib/views/home/map_widget.dart/main_bottom_Menu_map.dart +++ b/lib/views/home/map_widget.dart/main_bottom_Menu_map.dart @@ -43,31 +43,32 @@ class MainBottomMenuMap extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.all(15), - child: Container( - width: Get.width * .8, - height: Get.height * .1, - decoration: const BoxDecoration( - boxShadow: [ - BoxShadow( - color: AppColor.accentColor, - blurRadius: 5, - offset: Offset(2, 4)), - BoxShadow( - color: AppColor.accentColor, - blurRadius: 5, - offset: Offset(-2, -2)) - ], - color: AppColor.secondaryColor, - borderRadius: BorderRadius.all( - Radius.elliptical(15, 30), + child: InkWell( + onTap: () => controller.changeMainBottomMenuMap(), + child: Container( + width: Get.width * .8, + height: Get.height * .1, + decoration: const BoxDecoration( + boxShadow: [ + BoxShadow( + color: AppColor.accentColor, + blurRadius: 5, + offset: Offset(2, 4)), + BoxShadow( + color: AppColor.accentColor, + blurRadius: 5, + offset: Offset(-2, -2)) + ], + color: AppColor.secondaryColor, + borderRadius: BorderRadius.all( + Radius.elliptical(15, 30), + ), ), - ), - child: GestureDetector( - onTap: () => controller.changeMainBottomMenuMap(), child: DefaultTextStyle( style: AppStyle.title, child: Center( child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 30, @@ -88,16 +89,33 @@ class MainBottomMenuMap extends StatelessWidget { }, ), ), - Text('Nearest Car for you about '.tr + - (controller.nearestCar != null - ? controller.nearestCar!.duration - .toString() - : 'N/A')) + Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text('Nearest Car for you about '.tr), + Container( + decoration: BoxDecoration( + border: Border.all( + color: AppColor.redColor, + width: 3)), + child: Padding( + padding: const EdgeInsets.all(4), + child: Text( + (controller.nearestCar != null + ? controller + .duratioByPassenger + .toString() + : 'N/A')), + ), + ), + ], + ) ], ), ), - ), - )), + )), + ), ), controller.isMainBottomMenuMap ? const FavioratePlacesDialogu() diff --git a/lib/views/home/map_widget.dart/map_menu_widget.dart b/lib/views/home/map_widget.dart/map_menu_widget.dart index d0a1206..4f668de 100644 --- a/lib/views/home/map_widget.dart/map_menu_widget.dart +++ b/lib/views/home/map_widget.dart/map_menu_widget.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart'; +import 'package:ride/constant/style.dart'; +import 'package:ride/views/home/my_wallet/passenger_wallet.dart'; import '../../../constant/colors.dart'; import '../../../controller/home/map_page_controller.dart'; @@ -16,76 +19,221 @@ class MapMenuWidget extends StatelessWidget { @override Widget build(BuildContext context) { return GetBuilder( - builder: (controller) => Positioned( - right: 60, - left: 60, - child: Padding( - padding: const EdgeInsets.only(right: 20), - child: Opacity( - alwaysIncludeSemantics: false, - opacity: 0.99, // Adjust the opacity value as needed - child: AnimatedContainer( - width: Get.width * .6, - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(12)), - color: AppColor.secondaryColor, - boxShadow: [ - BoxShadow( - color: AppColor.primaryColor, - offset: Offset(-7, -7), - blurRadius: 0, - spreadRadius: 0, - blurStyle: BlurStyle.outer), - BoxShadow( - color: AppColor.accentColor, - offset: Offset(3, 3), - blurRadius: 0, - spreadRadius: 0, - blurStyle: BlurStyle.outer) - ]), - transform: - Matrix4.translationValues(controller.heightMenu * .1, 1, 1), - curve: Curves.easeOutCubic, - clipBehavior: Clip.hardEdge, - duration: const Duration(milliseconds: 300), - height: controller.heightMenu, - child: controller.heightMenuBool - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - IconWidgetMenu( + builder: (controller) => Stack(children: [ + Positioned( + right: 60, + left: 60, + child: Padding( + padding: const EdgeInsets.only(right: 20), + child: Opacity( + alwaysIncludeSemantics: false, + opacity: 1, // Adjust the opacity value as needed + child: AnimatedContainer( + width: Get.width * .6, + 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) + ]), + transform: Matrix4.translationValues( + controller.heightMenu * .1, 1, 1), + curve: Curves.easeOutCubic, + clipBehavior: Clip.hardEdge, + duration: const Duration(milliseconds: 300), + height: controller.heightMenu, + child: controller.heightMenuBool + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconWidgetMenu( + onpressed: () { + Get.to( + () => const NotificationPage(), + transition: Transition.circularReveal, + ); + }, + title: 'Notifications'.tr, + icon: Icons.notifications), + IconWidgetMenu( onpressed: () { Get.to( - () => const NotificationPage(), - transition: Transition.circularReveal, + () => const PassengerProfilePage(), + transition: Transition.zoom, ); }, - title: 'Notifications'.tr, - icon: Icons.notifications), - IconWidgetMenu( - onpressed: () { - Get.to( - () => const PassengerProfilePage(), - transition: Transition.zoom, - ); - }, - icon: Icons.person, - title: 'Profile'.tr, - ), - IconWidgetMenu( - title: 'Home'.tr, - onpressed: () { - Get.to( - () => const HomePage(), - transition: Transition.downToUp, - curve: Curves.easeInOutExpo, - ); - }, - icon: Icons.home), - ], - ) - : const SizedBox(), // Choose the desired overlay color - )), + icon: Icons.person, + title: 'Profile'.tr, + ), + IconWidgetMenu( + title: 'Home'.tr, + onpressed: () { + Get.to( + () => const HomePage(), + transition: Transition.downToUp, + curve: Curves.easeInOutExpo, + ); + }, + icon: Icons.home), + ], + ) + : const SizedBox(), // Choose the desired overlay color + )), + ), + ), + Positioned( + right: 5, + top: 110, + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + 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) + ]), + width: controller.widthMenu, + height: Get.height * .3, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconMainPageMap( + onTap: () { + Get.to(() => const PassengerWallet()); + }, + title: 'My Wallet', + icon: Icons.wallet, + ), + IconMainPageMap( + onTap: () {}, + title: 'Order History', + icon: Icons.history, + ), + IconMainPageMap( + onTap: () {}, + title: 'Tariff', + icon: Icons.money, + ), + ], + ), + )), + Positioned( + left: 5, + top: 110, + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + 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) + ]), + width: controller.widthMenu, + height: Get.height * .3, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconMainPageMap( + onTap: () {}, + title: 'Settings', + icon: Icons.settings, + ), + IconMainPageMap( + onTap: () {}, + title: 'Feed Back', + icon: Icons.feedback, + ), + IconMainPageMap( + onTap: () {}, + title: 'Promos', + icon: Icons.monetization_on, + ), + ], + ), + )) + ]), + ); + } +} + +class IconMainPageMap extends StatelessWidget { + const IconMainPageMap({ + super.key, + required this.title, + required this.onTap, + required this.icon, + }); + + final String title; + final IconData icon; + final Callback onTap; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(4), + child: Container( + width: double.maxFinite, + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(16)), + color: AppColor.secondaryColor, + boxShadow: [ + BoxShadow( + color: AppColor.accentColor, + offset: Offset(3, 3), + blurRadius: 0, + spreadRadius: 0, + blurStyle: BlurStyle.outer, + ), + ], + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(icon), + Text( + title.tr, + style: AppStyle.subtitle, + ), + ], + ), + ), ), ), ); diff --git a/lib/views/home/my_wallet/passenger_wallet.dart b/lib/views/home/my_wallet/passenger_wallet.dart new file mode 100644 index 0000000..4c3840d --- /dev/null +++ b/lib/views/home/my_wallet/passenger_wallet.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:ride/constant/style.dart'; +import 'package:ride/controller/payment/payment_controller.dart'; +import 'package:ride/views/widgets/my_scafold.dart'; + +import '../../../constant/colors.dart'; + +class PassengerWallet extends StatelessWidget { + const PassengerWallet({super.key}); + + @override + Widget build(BuildContext context) { + Get.put(PaymentController()); + return MyScafolld( + title: 'My Wallet', + isleading: true, + body: [ + GetBuilder( + builder: (controller) => Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(12)), + color: AppColor.secondaryColor, + boxShadow: [ + BoxShadow( + color: AppColor.accentColor, + offset: Offset(-1, -1), + blurRadius: 0, + spreadRadius: 0, + blurStyle: BlurStyle.normal), + BoxShadow( + color: AppColor.accentColor, + offset: Offset(3, 3), + blurRadius: 1, + spreadRadius: 0, + blurStyle: BlurStyle.normal) + ]), + child: Padding( + padding: const EdgeInsets.all(10), + child: Text( + 'You Have ${controller.passengerTotalWalletAmount} JD in SEFER Wallet', + style: AppStyle.title, + ), + ), + ), + ], + ), + ], + ), + ) + ], + ); + } +}