diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 3bdd739..b7de49b 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -80,7 +80,8 @@ class MapPassengerController extends GetxController { double widthMenu = 0; double heightPickerContainer = 90; double heightPointsPageForRider = 0; - double mainBottomMenuMap = Get.height * .2; + double mainBottomMenuMapHeight = Get.height * .2; + double wayPointSheetHeight = 0; bool startLocationFromMap = false; bool startLocationFromMap0 = false; bool startLocationFromMap1 = false; @@ -99,6 +100,7 @@ class MapPassengerController extends GetxController { bool isRideFinished = false; bool rideConfirm = false; bool isMainBottomMenuMap = true; + bool isWayPointSheet = false; double heightBottomSheetShown = 0; double cashConfirmPageShown = 250; late String driverId; @@ -132,6 +134,12 @@ class MapPassengerController extends GetxController { String hintTextwayPoint3 = 'Search for waypoint'.tr; String hintTextwayPoint4 = 'Search for waypoint'.tr; String currentLocationString = 'Current Location'.tr; + String currentLocationString0 = 'Current Location'.tr; + String currentLocationString1 = 'Current Location 1'.tr; + String currentLocationString2 = 'Current Location 2'.tr; + String currentLocationString3 = 'Current Location 3'.tr; + String currentLocationString4 = 'Current Location 4'.tr; + List currentLocationStringAll = []; String hintTextDestinationPoint = 'Search for your destination'.tr; late String rideId; bool noCarString = false; @@ -197,6 +205,7 @@ class MapPassengerController extends GetxController { update(); } else { hintTextwayPoint0 = wayPoint0[index]['name']; + currentLocationString0 = wayPoint1[index]['name']; double lat = wayPoint0[index]['geometry']['location']['lat']; double lng = wayPoint0[index]['geometry']['location']['lng']; newPointLocation0 = LatLng(lat, lng); @@ -210,6 +219,7 @@ class MapPassengerController extends GetxController { update(); } else { hintTextwayPoint1 = wayPoint1[index]['name']; + currentLocationString1 = wayPoint1[index]['name']; double lat = wayPoint1[index]['geometry']['location']['lat']; double lng = wayPoint1[index]['geometry']['location']['lng']; newPointLocation1 = LatLng(lat, lng); @@ -223,6 +233,7 @@ class MapPassengerController extends GetxController { update(); } else { hintTextwayPoint2 = wayPoint2[index]['name']; + currentLocationString2 = wayPoint1[index]['name']; double lat = wayPoint2[index]['geometry']['location']['lat']; double lng = wayPoint2[index]['geometry']['location']['lng']; newPointLocation2 = LatLng(lat, lng); @@ -236,6 +247,7 @@ class MapPassengerController extends GetxController { update(); } else { hintTextwayPoint3 = wayPoint3[index]['name']; + currentLocationString3 = wayPoint1[index]['name']; double lat = wayPoint3[index]['geometry']['location']['lat']; double lng = wayPoint3[index]['geometry']['location']['lng']; newPointLocation3 = LatLng(lat, lng); @@ -249,6 +261,7 @@ class MapPassengerController extends GetxController { update(); } else { hintTextwayPoint4 = wayPoint4[index]['name']; + currentLocationString4 = wayPoint1[index]['name']; double lat = wayPoint4[index]['geometry']['location']['lat']; double lng = wayPoint4[index]['geometry']['location']['lng']; newPointLocation4 = LatLng(lat, lng); @@ -830,7 +843,7 @@ class MapPassengerController extends GetxController { void changeMainBottomMenuMap() { isMainBottomMenuMap = !isMainBottomMenuMap; - mainBottomMenuMap = + mainBottomMenuMapHeight = isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7; if (heightMenuBool == true) { getDrawerMenu(); @@ -838,6 +851,15 @@ class MapPassengerController extends GetxController { update(); } + void changeWayPointSheet() { + isWayPointSheet = !isWayPointSheet; + wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .7; + // if (heightMenuBool == true) { + // getDrawerMenu(); + // } + update(); + } + changeHeightPlaces() { if (placesDestination.isEmpty) { height = 0; @@ -1473,18 +1495,7 @@ class MapPassengerController extends GetxController { List polylineCoordinate = []; String? cardNumber; - @override - void onInit() async { - mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); - await getLocation(); - await addToken(); - await getCarsLocationByPassenger(); - getNearestDriverByPassengerLocation(); - addCustomPicker(); - addCustomCarIcon(); - addCustomTripIcon(); - startMarkerReloading(); - cardNumber = await SecureStorage().readData(BoxName.cardNumber); + void readyWayPoints() { allTextEditingPlaces = [ wayPoint0Controller, wayPoint1Controller, @@ -1499,11 +1510,33 @@ class MapPassengerController extends GetxController { wayPoint3, wayPoint4 ]; - // placeListResponse.add(wayPoint0); + currentLocationStringAll = [ + currentLocationString0, + currentLocationString1, + currentLocationString2, + currentLocationString3, + currentLocationString4, + ]; // placeListResponse.add(wayPoint0); // placeListResponse.add(wayPoint1); // placeListResponse.add(wayPoint2); // placeListResponse.add(wayPoint3); // placeListResponse.add(wayPoint4); + } + + @override + void onInit() async { + mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); + await getLocation(); + await addToken(); + await getCarsLocationByPassenger(); + getNearestDriverByPassengerLocation(); + addCustomPicker(); + addCustomCarIcon(); + addCustomTripIcon(); + startMarkerReloading(); + cardNumber = await SecureStorage().readData(BoxName.cardNumber); + readyWayPoints(); + super.onInit(); } } diff --git a/lib/controller/home/points_for_rider_controller.dart b/lib/controller/home/points_for_rider_controller.dart index 84e672b..b4e057a 100644 --- a/lib/controller/home/points_for_rider_controller.dart +++ b/lib/controller/home/points_for_rider_controller.dart @@ -70,7 +70,9 @@ class WayPointController extends GetxController { update(); } else { Get.defaultDialog( - title: 'This is most WayPoints', titleStyle: AppStyle.title); + title: 'This is most WayPoints', + titleStyle: AppStyle.title, + middleText: ''); } update(); } diff --git a/lib/views/home/map_widget.dart/form_serch_multiy_point.dart b/lib/views/home/map_widget.dart/form_serch_multiy_point.dart index 30d4b3d..46286a9 100644 --- a/lib/views/home/map_widget.dart/form_serch_multiy_point.dart +++ b/lib/views/home/map_widget.dart/form_serch_multiy_point.dart @@ -28,7 +28,7 @@ GetBuilder formSearchPlaces0() { width: 2, )), suffixIcon: const Icon(Icons.search), - hintText: 'Search for waypoint'.tr, + hintText: controller.hintTextwayPoint0.tr, hintStyle: AppStyle.title, hintMaxLines: 1, prefixIcon: IconButton( @@ -86,9 +86,10 @@ GetBuilder formSearchPlaces0() { } controller.convertHintTextPlaces0(index); - controller.currentLocationString = res['name']; + controller.currentLocationString0 = res['name']; controller.wayPoint0 = []; controller.wayPoint0Controller.clear(); + Get.back(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -182,7 +183,7 @@ GetBuilder formSearchPlaces1() { width: 2, )), suffixIcon: const Icon(Icons.search), - hintText: 'Search for waypoint'.tr, + hintText: controller.hintTextwayPoint1.tr, hintStyle: AppStyle.title, hintMaxLines: 1, prefixIcon: IconButton( @@ -240,9 +241,10 @@ GetBuilder formSearchPlaces1() { } controller.convertHintTextPlaces1(index); - controller.currentLocationString = res['name']; - controller.wayPoint1 = []; - controller.wayPoint1Controller.clear(); + controller.currentLocationString1 = res['name']; + // controller.wayPoint1 = []; + // controller.wayPoint1Controller.clear(); + Get.back(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -336,7 +338,7 @@ GetBuilder formSearchPlaces2() { width: 2, )), suffixIcon: const Icon(Icons.search), - hintText: 'Search for waypoint'.tr, + hintText: controller.hintTextwayPoint2.tr, hintStyle: AppStyle.title, hintMaxLines: 1, prefixIcon: IconButton( @@ -394,9 +396,10 @@ GetBuilder formSearchPlaces2() { } controller.convertHintTextPlaces2(index); - controller.currentLocationString = res['name']; + controller.currentLocationString2 = res['name']; controller.wayPoint2 = []; controller.wayPoint2Controller.clear(); + Get.back(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -490,7 +493,7 @@ GetBuilder formSearchPlaces3() { width: 2, )), suffixIcon: const Icon(Icons.search), - hintText: 'Search for waypoint'.tr, + hintText: controller.hintTextwayPoint3.tr, hintStyle: AppStyle.title, hintMaxLines: 1, prefixIcon: IconButton( @@ -548,9 +551,10 @@ GetBuilder formSearchPlaces3() { } controller.convertHintTextPlaces3(index); - controller.currentLocationString = res['name']; + controller.currentLocationString3 = res['name']; controller.wayPoint3 = []; controller.wayPoint3Controller.clear(); + Get.back(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -644,7 +648,7 @@ GetBuilder formSearchPlaces4() { width: 2, )), suffixIcon: const Icon(Icons.search), - hintText: 'Search for waypoint'.tr, + hintText: controller.hintTextwayPoint4.tr, hintStyle: AppStyle.title, hintMaxLines: 1, prefixIcon: IconButton( @@ -702,9 +706,10 @@ GetBuilder formSearchPlaces4() { } controller.convertHintTextPlaces4(index); - controller.currentLocationString = res['name']; + controller.currentLocationString4 = res['name']; controller.wayPoint4 = []; controller.wayPoint4Controller.clear(); + Get.back(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), 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 28106b8..2601f0d 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 @@ -24,20 +24,9 @@ class MainBottomMenuMap extends StatelessWidget { left: 5, right: 5, child: AnimatedContainer( - duration: const Duration(milliseconds: 400), - height: controller.mainBottomMenuMap, - decoration: const BoxDecoration( - boxShadow: [ - BoxShadow( - color: AppColor.accentColor, offset: Offset(2, 2)), - BoxShadow( - color: AppColor.accentColor, offset: Offset(-2, -2)) - ], - color: AppColor.secondaryColor, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(15), - topRight: Radius.circular(15), - )), + duration: const Duration(milliseconds: 500), + height: controller.mainBottomMenuMapHeight, + decoration: AppStyle.boxDecoration, child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -272,7 +261,17 @@ class MainBottomMenuMap extends StatelessWidget { controller.showBottomSheet1(); Get.back(); controller.showBottomSheet1(); - }) + }), + TextButton( + onPressed: () { + controller.changeMainBottomMenuMap(); + controller.changeWayPointSheet(); + }, + child: Text( + "If you want add stop click here".tr, + style: AppStyle.title, + ), + ), ], ) ], diff --git a/lib/views/home/map_widget.dart/points_page_for_rider.dart b/lib/views/home/map_widget.dart/points_page_for_rider.dart index bb66b0e..cb60e4d 100644 --- a/lib/views/home/map_widget.dart/points_page_for_rider.dart +++ b/lib/views/home/map_widget.dart/points_page_for_rider.dart @@ -18,102 +18,146 @@ class PointsPageForRider extends StatelessWidget { Widget build(BuildContext context) { Get.put(WayPointController()); - return GetBuilder(builder: (wayPointController) { - return Container( - decoration: AppStyle.boxDecoration, - height: wayPointController.wayPointHeight, - child: ListView( - children: [ - const AppBarPointsPageForRider(), - SizedBox( - height: 300, - child: ReorderableListView( - // The children of the list are the text fields - children: - wayPointController.wayPoints.asMap().entries.map((entry) { - final index = entry.key; - final wayPoint = entry.value; - return Padding( - key: ValueKey(index), - padding: const EdgeInsets.all(6), - child: ListTile( - leading: Container( - decoration: BoxDecoration( - color: AppColor.deepPurpleAccent, - border: Border.all(), - shape: BoxShape.rectangle), - child: Padding( - padding: const EdgeInsets.all(2), - child: Text( - index.toString(), - style: AppStyle.title, - ), - )), - title: InkWell( - onTap: () { - // showAddLocationDialog(context); - Get.defaultDialog( - content: SizedBox( - width: Get.width, - height: 400, - child: mapPassengerController - .placeListResponse[index]), - ); - }, - child: Container( - decoration: BoxDecoration( - border: Border.all(), - color: AppColor.accentColor.withOpacity(.5)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - index == 0 - ? Text( - 'Current Location', - style: AppStyle.title, - ) - : Text( - '$wayPoint$index', - style: AppStyle.title, - ), - const Icon( - Icons.reorder, - size: 20, - ), - ], - ), - ), - ), - trailing: index > 0 - ? IconButton( - icon: const Icon(Icons.close), - onPressed: () { - wayPointController.removeTextField(index); - }, - ) - : IconButton( - icon: const Icon( - Icons.close, - color: AppColor.secondaryColor, - ), - onPressed: () {}, - )), - ); - }).toList(), - - // The callback when the user reorders the text fields - onReorder: (int oldIndex, int newIndex) { - wayPointController.reorderTextFields(oldIndex, newIndex); + return GetBuilder(builder: (controller) { + return Positioned( + bottom: 2, + left: 2, + right: 2, + child: AnimatedContainer( + duration: const Duration(milliseconds: 800), + height: controller.wayPointSheetHeight, + decoration: AppStyle.boxDecoration, + child: ListView( + children: [ + // const AppBarPointsPageForRider(), + IconButton( + onPressed: () { + mapPassengerController.changeWayPointSheet(); }, + icon: const Icon(Icons.arrow_drop_down_circle_outlined), ), - ), - ElevatedButton( - onPressed: () { - wayPointController.addWayPoints(); - }, - child: const Text('Add Text Field'), - ), - ], + SizedBox( + height: Get.height * .57, + child: GetBuilder( + builder: (wayPointController) { + return ReorderableListView( + // The children of the list are the text fields + children: wayPointController.wayPoints + .asMap() + .entries + .map((entry) { + final index = entry.key; + final wayPoint = entry.value; + return Padding( + key: ValueKey(index), + padding: const EdgeInsets.all(6), + child: ListTile( + leading: Container( + decoration: BoxDecoration( + color: AppColor.deepPurpleAccent, + border: Border.all(), + shape: BoxShape.rectangle), + child: Padding( + padding: const EdgeInsets.all(2), + child: Text( + index.toString(), + style: AppStyle.title, + ), + )), + title: InkWell( + onTap: () { + // showAddLocationDialog(context); + Get.defaultDialog( + content: SizedBox( + width: Get.width, + height: 400, + child: mapPassengerController + .placeListResponse[index]), + ); + }, + child: Container( + decoration: BoxDecoration( + border: Border.all(), + color: + AppColor.accentColor.withOpacity(.5)), + child: GetBuilder( + builder: (mapPassengerController) { + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + index == 0 + ? Text( + mapPassengerController + .currentLocationString0, + style: AppStyle.title, + ) + : index == 1 + ? Text( + mapPassengerController + .currentLocationString1, + style: AppStyle.title, + ) + : index == 2 + ? Text( + mapPassengerController + .currentLocationString2, + style: AppStyle.title, + ) + : index == 3 + ? Text( + mapPassengerController + .currentLocationString3, + style: AppStyle.title, + ) + : Text( + mapPassengerController + .currentLocationString4, + style: AppStyle.title, + ), + const Icon( + Icons.reorder, + size: 20, + ), + ], + ); + }), + ), + ), + trailing: index > 0 + ? IconButton( + icon: const Icon(Icons.close), + onPressed: () { + wayPointController.removeTextField(index); + }, + ) + : IconButton( + icon: const Icon( + Icons.close, + color: AppColor.secondaryColor, + ), + onPressed: () {}, + )), + ); + }).toList(), + + // The callback when the user reorders the text fields + onReorder: (int oldIndex, int newIndex) { + wayPointController.reorderTextFields(oldIndex, newIndex); + }, + ); + }), + ), + GetBuilder(builder: (wayPointController) { + return ElevatedButton( + onPressed: () { + wayPointController.addWayPoints(); + }, + child: const Text('Add Text Field'), + ); + }), + ], + ), ), ); });