This commit is contained in:
Hamza-Ayed
2024-01-08 23:46:03 +03:00
parent 7d9bd9f62a
commit 783ae1a0ac
5 changed files with 220 additions and 137 deletions

View File

@@ -80,7 +80,8 @@ class MapPassengerController extends GetxController {
double widthMenu = 0; double widthMenu = 0;
double heightPickerContainer = 90; double heightPickerContainer = 90;
double heightPointsPageForRider = 0; double heightPointsPageForRider = 0;
double mainBottomMenuMap = Get.height * .2; double mainBottomMenuMapHeight = Get.height * .2;
double wayPointSheetHeight = 0;
bool startLocationFromMap = false; bool startLocationFromMap = false;
bool startLocationFromMap0 = false; bool startLocationFromMap0 = false;
bool startLocationFromMap1 = false; bool startLocationFromMap1 = false;
@@ -99,6 +100,7 @@ class MapPassengerController extends GetxController {
bool isRideFinished = false; bool isRideFinished = false;
bool rideConfirm = false; bool rideConfirm = false;
bool isMainBottomMenuMap = true; bool isMainBottomMenuMap = true;
bool isWayPointSheet = false;
double heightBottomSheetShown = 0; double heightBottomSheetShown = 0;
double cashConfirmPageShown = 250; double cashConfirmPageShown = 250;
late String driverId; late String driverId;
@@ -132,6 +134,12 @@ class MapPassengerController extends GetxController {
String hintTextwayPoint3 = 'Search for waypoint'.tr; String hintTextwayPoint3 = 'Search for waypoint'.tr;
String hintTextwayPoint4 = 'Search for waypoint'.tr; String hintTextwayPoint4 = 'Search for waypoint'.tr;
String currentLocationString = 'Current Location'.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<String> currentLocationStringAll = [];
String hintTextDestinationPoint = 'Search for your destination'.tr; String hintTextDestinationPoint = 'Search for your destination'.tr;
late String rideId; late String rideId;
bool noCarString = false; bool noCarString = false;
@@ -197,6 +205,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
hintTextwayPoint0 = wayPoint0[index]['name']; hintTextwayPoint0 = wayPoint0[index]['name'];
currentLocationString0 = wayPoint1[index]['name'];
double lat = wayPoint0[index]['geometry']['location']['lat']; double lat = wayPoint0[index]['geometry']['location']['lat'];
double lng = wayPoint0[index]['geometry']['location']['lng']; double lng = wayPoint0[index]['geometry']['location']['lng'];
newPointLocation0 = LatLng(lat, lng); newPointLocation0 = LatLng(lat, lng);
@@ -210,6 +219,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
hintTextwayPoint1 = wayPoint1[index]['name']; hintTextwayPoint1 = wayPoint1[index]['name'];
currentLocationString1 = wayPoint1[index]['name'];
double lat = wayPoint1[index]['geometry']['location']['lat']; double lat = wayPoint1[index]['geometry']['location']['lat'];
double lng = wayPoint1[index]['geometry']['location']['lng']; double lng = wayPoint1[index]['geometry']['location']['lng'];
newPointLocation1 = LatLng(lat, lng); newPointLocation1 = LatLng(lat, lng);
@@ -223,6 +233,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
hintTextwayPoint2 = wayPoint2[index]['name']; hintTextwayPoint2 = wayPoint2[index]['name'];
currentLocationString2 = wayPoint1[index]['name'];
double lat = wayPoint2[index]['geometry']['location']['lat']; double lat = wayPoint2[index]['geometry']['location']['lat'];
double lng = wayPoint2[index]['geometry']['location']['lng']; double lng = wayPoint2[index]['geometry']['location']['lng'];
newPointLocation2 = LatLng(lat, lng); newPointLocation2 = LatLng(lat, lng);
@@ -236,6 +247,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
hintTextwayPoint3 = wayPoint3[index]['name']; hintTextwayPoint3 = wayPoint3[index]['name'];
currentLocationString3 = wayPoint1[index]['name'];
double lat = wayPoint3[index]['geometry']['location']['lat']; double lat = wayPoint3[index]['geometry']['location']['lat'];
double lng = wayPoint3[index]['geometry']['location']['lng']; double lng = wayPoint3[index]['geometry']['location']['lng'];
newPointLocation3 = LatLng(lat, lng); newPointLocation3 = LatLng(lat, lng);
@@ -249,6 +261,7 @@ class MapPassengerController extends GetxController {
update(); update();
} else { } else {
hintTextwayPoint4 = wayPoint4[index]['name']; hintTextwayPoint4 = wayPoint4[index]['name'];
currentLocationString4 = wayPoint1[index]['name'];
double lat = wayPoint4[index]['geometry']['location']['lat']; double lat = wayPoint4[index]['geometry']['location']['lat'];
double lng = wayPoint4[index]['geometry']['location']['lng']; double lng = wayPoint4[index]['geometry']['location']['lng'];
newPointLocation4 = LatLng(lat, lng); newPointLocation4 = LatLng(lat, lng);
@@ -830,7 +843,7 @@ class MapPassengerController extends GetxController {
void changeMainBottomMenuMap() { void changeMainBottomMenuMap() {
isMainBottomMenuMap = !isMainBottomMenuMap; isMainBottomMenuMap = !isMainBottomMenuMap;
mainBottomMenuMap = mainBottomMenuMapHeight =
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7; isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7;
if (heightMenuBool == true) { if (heightMenuBool == true) {
getDrawerMenu(); getDrawerMenu();
@@ -838,6 +851,15 @@ class MapPassengerController extends GetxController {
update(); update();
} }
void changeWayPointSheet() {
isWayPointSheet = !isWayPointSheet;
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .7;
// if (heightMenuBool == true) {
// getDrawerMenu();
// }
update();
}
changeHeightPlaces() { changeHeightPlaces() {
if (placesDestination.isEmpty) { if (placesDestination.isEmpty) {
height = 0; height = 0;
@@ -1473,18 +1495,7 @@ class MapPassengerController extends GetxController {
List<LatLng> polylineCoordinate = []; List<LatLng> polylineCoordinate = [];
String? cardNumber; String? cardNumber;
@override void readyWayPoints() {
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);
allTextEditingPlaces = [ allTextEditingPlaces = [
wayPoint0Controller, wayPoint0Controller,
wayPoint1Controller, wayPoint1Controller,
@@ -1499,11 +1510,33 @@ class MapPassengerController extends GetxController {
wayPoint3, wayPoint3,
wayPoint4 wayPoint4
]; ];
// placeListResponse.add(wayPoint0); currentLocationStringAll = [
currentLocationString0,
currentLocationString1,
currentLocationString2,
currentLocationString3,
currentLocationString4,
]; // placeListResponse.add(wayPoint0);
// placeListResponse.add(wayPoint1); // placeListResponse.add(wayPoint1);
// placeListResponse.add(wayPoint2); // placeListResponse.add(wayPoint2);
// placeListResponse.add(wayPoint3); // placeListResponse.add(wayPoint3);
// placeListResponse.add(wayPoint4); // 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(); super.onInit();
} }
} }

View File

@@ -70,7 +70,9 @@ class WayPointController extends GetxController {
update(); update();
} else { } else {
Get.defaultDialog( Get.defaultDialog(
title: 'This is most WayPoints', titleStyle: AppStyle.title); title: 'This is most WayPoints',
titleStyle: AppStyle.title,
middleText: '');
} }
update(); update();
} }

View File

@@ -28,7 +28,7 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
width: 2, width: 2,
)), )),
suffixIcon: const Icon(Icons.search), suffixIcon: const Icon(Icons.search),
hintText: 'Search for waypoint'.tr, hintText: controller.hintTextwayPoint0.tr,
hintStyle: AppStyle.title, hintStyle: AppStyle.title,
hintMaxLines: 1, hintMaxLines: 1,
prefixIcon: IconButton( prefixIcon: IconButton(
@@ -86,9 +86,10 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
} }
controller.convertHintTextPlaces0(index); controller.convertHintTextPlaces0(index);
controller.currentLocationString = res['name']; controller.currentLocationString0 = res['name'];
controller.wayPoint0 = []; controller.wayPoint0 = [];
controller.wayPoint0Controller.clear(); controller.wayPoint0Controller.clear();
Get.back();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
@@ -182,7 +183,7 @@ GetBuilder<MapPassengerController> formSearchPlaces1() {
width: 2, width: 2,
)), )),
suffixIcon: const Icon(Icons.search), suffixIcon: const Icon(Icons.search),
hintText: 'Search for waypoint'.tr, hintText: controller.hintTextwayPoint1.tr,
hintStyle: AppStyle.title, hintStyle: AppStyle.title,
hintMaxLines: 1, hintMaxLines: 1,
prefixIcon: IconButton( prefixIcon: IconButton(
@@ -240,9 +241,10 @@ GetBuilder<MapPassengerController> formSearchPlaces1() {
} }
controller.convertHintTextPlaces1(index); controller.convertHintTextPlaces1(index);
controller.currentLocationString = res['name']; controller.currentLocationString1 = res['name'];
controller.wayPoint1 = []; // controller.wayPoint1 = [];
controller.wayPoint1Controller.clear(); // controller.wayPoint1Controller.clear();
Get.back();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
@@ -336,7 +338,7 @@ GetBuilder<MapPassengerController> formSearchPlaces2() {
width: 2, width: 2,
)), )),
suffixIcon: const Icon(Icons.search), suffixIcon: const Icon(Icons.search),
hintText: 'Search for waypoint'.tr, hintText: controller.hintTextwayPoint2.tr,
hintStyle: AppStyle.title, hintStyle: AppStyle.title,
hintMaxLines: 1, hintMaxLines: 1,
prefixIcon: IconButton( prefixIcon: IconButton(
@@ -394,9 +396,10 @@ GetBuilder<MapPassengerController> formSearchPlaces2() {
} }
controller.convertHintTextPlaces2(index); controller.convertHintTextPlaces2(index);
controller.currentLocationString = res['name']; controller.currentLocationString2 = res['name'];
controller.wayPoint2 = []; controller.wayPoint2 = [];
controller.wayPoint2Controller.clear(); controller.wayPoint2Controller.clear();
Get.back();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
@@ -490,7 +493,7 @@ GetBuilder<MapPassengerController> formSearchPlaces3() {
width: 2, width: 2,
)), )),
suffixIcon: const Icon(Icons.search), suffixIcon: const Icon(Icons.search),
hintText: 'Search for waypoint'.tr, hintText: controller.hintTextwayPoint3.tr,
hintStyle: AppStyle.title, hintStyle: AppStyle.title,
hintMaxLines: 1, hintMaxLines: 1,
prefixIcon: IconButton( prefixIcon: IconButton(
@@ -548,9 +551,10 @@ GetBuilder<MapPassengerController> formSearchPlaces3() {
} }
controller.convertHintTextPlaces3(index); controller.convertHintTextPlaces3(index);
controller.currentLocationString = res['name']; controller.currentLocationString3 = res['name'];
controller.wayPoint3 = []; controller.wayPoint3 = [];
controller.wayPoint3Controller.clear(); controller.wayPoint3Controller.clear();
Get.back();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
@@ -644,7 +648,7 @@ GetBuilder<MapPassengerController> formSearchPlaces4() {
width: 2, width: 2,
)), )),
suffixIcon: const Icon(Icons.search), suffixIcon: const Icon(Icons.search),
hintText: 'Search for waypoint'.tr, hintText: controller.hintTextwayPoint4.tr,
hintStyle: AppStyle.title, hintStyle: AppStyle.title,
hintMaxLines: 1, hintMaxLines: 1,
prefixIcon: IconButton( prefixIcon: IconButton(
@@ -702,9 +706,10 @@ GetBuilder<MapPassengerController> formSearchPlaces4() {
} }
controller.convertHintTextPlaces4(index); controller.convertHintTextPlaces4(index);
controller.currentLocationString = res['name']; controller.currentLocationString4 = res['name'];
controller.wayPoint4 = []; controller.wayPoint4 = [];
controller.wayPoint4Controller.clear(); controller.wayPoint4Controller.clear();
Get.back();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),

View File

@@ -24,20 +24,9 @@ class MainBottomMenuMap extends StatelessWidget {
left: 5, left: 5,
right: 5, right: 5,
child: AnimatedContainer( child: AnimatedContainer(
duration: const Duration(milliseconds: 400), duration: const Duration(milliseconds: 500),
height: controller.mainBottomMenuMap, height: controller.mainBottomMenuMapHeight,
decoration: const BoxDecoration( decoration: AppStyle.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),
)),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@@ -272,7 +261,17 @@ class MainBottomMenuMap extends StatelessWidget {
controller.showBottomSheet1(); controller.showBottomSheet1();
Get.back(); Get.back();
controller.showBottomSheet1(); controller.showBottomSheet1();
}) }),
TextButton(
onPressed: () {
controller.changeMainBottomMenuMap();
controller.changeWayPointSheet();
},
child: Text(
"If you want add stop click here".tr,
style: AppStyle.title,
),
),
], ],
) )
], ],

View File

@@ -18,102 +18,146 @@ class PointsPageForRider extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Get.put(WayPointController()); Get.put(WayPointController());
return GetBuilder<WayPointController>(builder: (wayPointController) { return GetBuilder<MapPassengerController>(builder: (controller) {
return Container( return Positioned(
decoration: AppStyle.boxDecoration, bottom: 2,
height: wayPointController.wayPointHeight, left: 2,
child: ListView( right: 2,
children: [ child: AnimatedContainer(
const AppBarPointsPageForRider(), duration: const Duration(milliseconds: 800),
SizedBox( height: controller.wayPointSheetHeight,
height: 300, decoration: AppStyle.boxDecoration,
child: ReorderableListView( child: ListView(
// The children of the list are the text fields children: [
children: // const AppBarPointsPageForRider(),
wayPointController.wayPoints.asMap().entries.map((entry) { IconButton(
final index = entry.key; onPressed: () {
final wayPoint = entry.value; mapPassengerController.changeWayPointSheet();
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);
}, },
icon: const Icon(Icons.arrow_drop_down_circle_outlined),
), ),
), SizedBox(
ElevatedButton( height: Get.height * .57,
onPressed: () { child: GetBuilder<WayPointController>(
wayPointController.addWayPoints(); builder: (wayPointController) {
}, return ReorderableListView(
child: const Text('Add Text Field'), // 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<MapPassengerController>(
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<WayPointController>(builder: (wayPointController) {
return ElevatedButton(
onPressed: () {
wayPointController.addWayPoints();
},
child: const Text('Add Text Field'),
);
}),
],
),
), ),
); );
}); });