This commit is contained in:
Hamza-Ayed
2024-01-10 03:08:32 +03:00
parent 783ae1a0ac
commit c73c01aa81
7 changed files with 303 additions and 728 deletions

View File

@@ -36,10 +36,6 @@ class RegisterCaptainController extends GetxController {
late String stateCode;
late String expireDate;
late String dob;
@override
void onInit() {
super.onInit();
}
getBirthDate() {
Get.defaultDialog(

View File

@@ -49,10 +49,10 @@ class MapPassengerController extends GetxController {
List<List<dynamic>> placeListResponseAll = [];
List<Widget> placeListResponse = [
formSearchPlaces1(),
formSearchPlaces2(),
formSearchPlaces3(),
formSearchPlaces4(),
formSearchPlaces(0),
formSearchPlaces(1),
formSearchPlaces(2),
formSearchPlaces(3),
];
LatLngBounds? boundsdata;
List<Marker> markers = [];
@@ -67,6 +67,12 @@ class MapPassengerController extends GetxController {
late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773);
LatLng myDestination = const LatLng(32.115295, 36.064773);
final List<LatLng> polylineCoordinates = [];
final List<LatLng> polylineCoordinates0 = [];
final List<LatLng> polylineCoordinates1 = [];
final List<LatLng> polylineCoordinates2 = [];
final List<LatLng> polylineCoordinates3 = [];
final List<LatLng> polylineCoordinates4 = [];
List<List<LatLng>> polylineCoordinatesPointsAll = [];
List<LatLng> carsLocationByPassenger = [];
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
@@ -88,6 +94,7 @@ class MapPassengerController extends GetxController {
bool startLocationFromMap2 = false;
bool startLocationFromMap3 = false;
bool startLocationFromMap4 = false;
List startLocationFromMapAll = [];
bool heightMenuBool = false;
bool isPickerShown = false;
bool isPointsPageForRider = false;
@@ -135,11 +142,18 @@ class MapPassengerController extends GetxController {
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;
String currentLocationString1 = 'Add Location 1'.tr;
String currentLocationString2 = 'Add Location 2'.tr;
String currentLocationString3 = 'Add Location 3'.tr;
String currentLocationString4 = 'Add Location 4'.tr;
String placesCoordinate0 = ''.tr;
String placesCoordinate1 = ''.tr;
String placesCoordinate2 = ''.tr;
String placesCoordinate3 = ''.tr;
String placesCoordinate4 = ''.tr;
List<String> currentLocationStringAll = [];
List<String> hintTextwayPointStringAll = [];
var placesCoordinate = <String>[];
String hintTextDestinationPoint = 'Search for your destination'.tr;
late String rideId;
bool noCarString = false;
@@ -151,6 +165,7 @@ class MapPassengerController extends GetxController {
bool currentLocationToFormPlaces2 = false;
bool currentLocationToFormPlaces3 = false;
bool currentLocationToFormPlaces4 = false;
List currentLocationToFormPlacesAll = [];
late String driverToken;
int carsOrder = 0;
String? mapAPIKEY;
@@ -199,17 +214,23 @@ class MapPassengerController extends GetxController {
}
}
void convertHintTextPlaces0(int index) {
if (wayPoint0.isEmpty) {
hintTextwayPoint0 = 'Search for your Start point'.tr;
void convertHintTextPlaces(int index, var res) {
if (placeListResponseAll[index].isEmpty) {
placeListResponseAll[index] = res;
hintTextwayPointStringAll[index] = 'Search for your Start point'.tr;
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);
hintTextwayPointStringAll[index] = res['name'];
currentLocationStringAll[index] = res['name'];
placesCoordinate[index] =
'${res['geometry']['location']['lat']},${res['geometry']['location']['lng']}';
placeListResponseAll[index] = [];
allTextEditingPlaces[index].clear();
// double lat = wayPoint0[index]['geometry']['location']['lat'];
// double lng = wayPoint0[index]['geometry']['location']['lng'];
// newPointLocation0 = LatLng(lat, lng);
update();
Get.back();
}
}
@@ -451,9 +472,9 @@ class MapPassengerController extends GetxController {
update();
}
void clearPlaces0() {
wayPoint0 = [];
hintTextwayPoint0 = 'Search for waypoint'.tr;
void clearPlaces(int index) {
placeListResponseAll[index] = [];
hintTextwayPointStringAll[index] = 'Search for waypoint'.tr;
update();
}
@@ -853,7 +874,7 @@ class MapPassengerController extends GetxController {
void changeWayPointSheet() {
isWayPointSheet = !isWayPointSheet;
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .7;
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4;
// if (heightMenuBool == true) {
// getDrawerMenu();
// }
@@ -878,8 +899,8 @@ class MapPassengerController extends GetxController {
update();
}
changeHeightPlaces0() {
if (wayPoint0.isEmpty) {
changeHeightPlacesAll(int index) {
if (placeListResponseAll[index].isEmpty) {
height = 0;
update();
}
@@ -953,13 +974,14 @@ class MapPassengerController extends GetxController {
update();
}
Future getPlacesListsWayPoint0() async {
Future getPlacesListsWayPoint(int index) async {
var url =
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint0Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
var response = await CRUD().getGoogleApi(link: url, payload: {});
wayPoint0 = response['results'];
placeListResponseAll[index] = response['results'];
print(wayPoint0);
update();
}
@@ -1279,13 +1301,6 @@ class MapPassengerController extends GetxController {
late LatLngBounds boundsData;
getMap(String origin, destination) async {
var origin1 = fromString(origin);
var destination1 = fromString(destination);
isLoading = true;
update();
myDestination = destination1;
myLocation = origin1;
await getCarsLocationByPassenger();
// print(carsLocationByPassenger);
isLoading = false;
@@ -1295,7 +1310,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
print(data);
// print(data);
isLoading = false;
update();
durationToRide = data[0]['duration']['value'];
@@ -1352,6 +1367,72 @@ class MapPassengerController extends GetxController {
}
}
getMapPoints(String origin, destination, int index) async {
await getCarsLocationByPassenger();
isLoading = false;
update();
var url =
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// print(data);
isLoading = false;
update();
durationToRide = data[0]['duration']['value'];
final points =
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
for (int i = 0; i < points.length; i++) {
double lat = points[i][0].toDouble();
double lng = points[i][1].toDouble();
polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
}
// Define the northeast and southwest coordinates
final bounds = response["routes"][0]["bounds"];
LatLng northeast =
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
LatLng southwest =
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
// Create the LatLngBounds object
boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
// Calculate the zoom level based on the distance and screen size
double distanceOfDestnation =
getDistanceFromText(data[0]['distance']['text']);
// Animate the camera to the adjusted bounds
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 >= 16 && distanceOfDestnation < 30) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
} else if (distanceOfDestnation >= 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
}
if (polyLines.isNotEmpty) {
clearPolyline();
} else {
var polyline = Polyline(
polylineId: PolylineId(response["routes"][0]["summary"]),
points: polylineCoordinatesPointsAll[index],
width: 10,
color: Colors.blue,
);
polyLines.add(polyline);
rideConfirm = false;
update();
}
}
showBottomSheet1() async {
bottomSheet();
isBottomSheetShown = true;
@@ -1490,12 +1571,26 @@ class MapPassengerController extends GetxController {
await CRUD().post(link: AppLink.addTokens, payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
}).then((value) => print('cccc'));
});
}
List<LatLng> polylineCoordinate = [];
String? cardNumber;
void readyWayPoints() {
hintTextwayPointStringAll = [
hintTextwayPoint0,
hintTextwayPoint1,
hintTextwayPoint2,
hintTextwayPoint3,
hintTextwayPoint4,
];
polylineCoordinatesPointsAll = [
polylineCoordinates0,
polylineCoordinates1,
polylineCoordinates2,
polylineCoordinates3,
polylineCoordinates4,
];
allTextEditingPlaces = [
wayPoint0Controller,
wayPoint1Controller,
@@ -1503,6 +1598,13 @@ class MapPassengerController extends GetxController {
wayPoint3Controller,
wayPoint4Controller,
];
currentLocationToFormPlacesAll = [
currentLocationToFormPlaces0,
currentLocationToFormPlaces1,
currentLocationToFormPlaces2,
currentLocationToFormPlaces3,
currentLocationToFormPlaces4,
];
placeListResponseAll = [
wayPoint0,
wayPoint1,
@@ -1510,22 +1612,34 @@ class MapPassengerController extends GetxController {
wayPoint3,
wayPoint4
];
startLocationFromMapAll = [
startLocationFromMap0,
startLocationFromMap1,
startLocationFromMap2,
startLocationFromMap3,
startLocationFromMap4,
];
currentLocationStringAll = [
currentLocationString0,
currentLocationString1,
currentLocationString2,
currentLocationString3,
currentLocationString4,
]; // placeListResponse.add(wayPoint0);
// placeListResponse.add(wayPoint1);
// placeListResponse.add(wayPoint2);
// placeListResponse.add(wayPoint3);
// placeListResponse.add(wayPoint4);
];
placesCoordinate = [
placesCoordinate0,
placesCoordinate1,
placesCoordinate2,
placesCoordinate3,
placesCoordinate4,
];
update();
}
@override
void onInit() async {
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
readyWayPoints();
await getLocation();
await addToken();
await getCarsLocationByPassenger();
@@ -1535,7 +1649,6 @@ class MapPassengerController extends GetxController {
addCustomTripIcon();
startMarkerReloading();
cardNumber = await SecureStorage().readData(BoxName.cardNumber);
readyWayPoints();
super.onInit();
}

View File

@@ -59,6 +59,7 @@ class WayPointController extends GetxController {
TextEditingController textSearchCotroller = TextEditingController();
// A list of places corresponding to each text field
final places = <String>[];
final hintTextPointList = <String>[];
late LatLng myLocation;

View File

@@ -30,7 +30,7 @@ class MapPagePassenger extends StatelessWidget {
body: SafeArea(
child: Stack(
children: [
const GoogleMapPassengerWidget(),
GoogleMapPassengerWidget(),
leftMainMenuIcons(),
const PickerIconOnMap(),
// PickerAnimtionContainerFormPlaces(),

View File

@@ -8,7 +8,7 @@ import '../../../controller/functions/toast.dart';
import '../../../controller/home/map_passenger_controller.dart';
import '../../../main.dart';
GetBuilder<MapPassengerController> formSearchPlaces0() {
GetBuilder<MapPassengerController> formSearchPlaces(int index) {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
@@ -33,8 +33,8 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.wayPoint0Controller.clear();
controller.clearPlaces0();
controller.allTextEditingPlaces[index].clear();
controller.clearPlaces(index);
},
icon: Icon(
Icons.clear,
@@ -42,21 +42,22 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
),
),
),
controller: controller.wayPoint0Controller,
controller: controller.allTextEditingPlaces[index],
onChanged: (value) {
if (controller.wayPoint0Controller.text.length > 5) {
controller.getPlacesListsWayPoint0();
controller.changeHeightPlaces0();
if (controller.allTextEditingPlaces[index].text.length >
5) {
controller.getPlacesListsWayPoint(index);
controller.changeHeightPlacesAll(index);
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.wayPoint0.isEmpty
controller.placeListResponseAll[index].isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap0 = true;
controller.startLocationFromMapAll[index] = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
@@ -68,16 +69,19 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
)
: const SizedBox(),
Container(
height: controller.wayPoint0.isNotEmpty ? controller.height : 0,
height: controller.placeListResponseAll[index].isNotEmpty
? controller.height
: 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.wayPoint0.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.wayPoint0[index];
itemCount: controller.placeListResponseAll[index].length,
itemBuilder: (BuildContext context, int i) {
var res = controller.placeListResponseAll[index][i];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
if (controller.currentLocationToFormPlaces0 == true) {
if (controller.currentLocationToFormPlacesAll[index] ==
true) {
controller.newStartPointLocation =
controller.myLocation;
} else {
@@ -85,631 +89,7 @@ GetBuilder<MapPassengerController> formSearchPlaces0() {
controller.newStartPointLocation;
}
controller.convertHintTextPlaces0(index);
controller.currentLocationString0 = res['name'];
controller.wayPoint0 = [];
controller.wayPoint0Controller.clear();
Get.back();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Image.network(
res['icon'],
width: 20,
),
IconButton(
onPressed: () async {
await sql.insertData({
'latitude': res['geometry']
['location']['lat'],
'longitude': res['geometry']
['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
}, TableName.placesFavorite);
Toast.show(
context,
'${res['name']} ${'Saved Sucssefully'.tr}',
AppColor.primaryColor);
},
icon: const Icon(Icons.favorite_border),
),
],
),
Column(
children: [
Text(
res['name'].toString(),
style: AppStyle.title,
),
Text(
res['vicinity'].toString(),
style: AppStyle.subtitle,
),
],
),
Column(
children: [
Text(
'rate',
style: AppStyle.subtitle,
),
Text(
res['rating'].toString(),
style: AppStyle.subtitle,
),
],
),
],
),
const Divider(
thickness: 1,
)
],
),
),
);
},
),
)
],
));
}
GetBuilder<MapPassengerController> formSearchPlaces1() {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Container(
decoration:
const BoxDecoration(color: AppColor.secondaryColor),
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(
borderRadius: BorderRadius.only(),
gapPadding: 4,
borderSide: BorderSide(
color: AppColor.redColor,
width: 2,
)),
suffixIcon: const Icon(Icons.search),
hintText: controller.hintTextwayPoint1.tr,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.wayPoint1Controller.clear();
controller.clearPlaces1();
},
icon: Icon(
Icons.clear,
color: Colors.red[300],
),
),
),
controller: controller.wayPoint1Controller,
onChanged: (value) {
if (controller.wayPoint1Controller.text.length > 5) {
controller.getPlacesListsWayPoint1();
controller.changeHeightPlaces1();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.wayPoint1.isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap1 = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
child: Text(
'Choose from Map'.tr,
style:
AppStyle.title.copyWith(color: AppColor.blueColor),
),
)
: const SizedBox(),
Container(
height: controller.wayPoint1.isNotEmpty ? controller.height : 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.wayPoint1.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.wayPoint1[index];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
if (controller.currentLocationToFormPlaces1 == true) {
controller.newStartPointLocation =
controller.myLocation;
} else {
controller.myLocation =
controller.newStartPointLocation;
}
controller.convertHintTextPlaces1(index);
controller.currentLocationString1 = res['name'];
// controller.wayPoint1 = [];
// controller.wayPoint1Controller.clear();
Get.back();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Image.network(
res['icon'],
width: 20,
),
IconButton(
onPressed: () async {
await sql.insertData({
'latitude': res['geometry']
['location']['lat'],
'longitude': res['geometry']
['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
}, TableName.placesFavorite);
Toast.show(
context,
'${res['name']} ${'Saved Sucssefully'.tr}',
AppColor.primaryColor);
},
icon: const Icon(Icons.favorite_border),
),
],
),
Column(
children: [
Text(
res['name'].toString(),
style: AppStyle.title,
),
Text(
res['vicinity'].toString(),
style: AppStyle.subtitle,
),
],
),
Column(
children: [
Text(
'rate',
style: AppStyle.subtitle,
),
Text(
res['rating'].toString(),
style: AppStyle.subtitle,
),
],
),
],
),
const Divider(
thickness: 1,
)
],
),
),
);
},
),
)
],
));
}
GetBuilder<MapPassengerController> formSearchPlaces2() {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Container(
decoration:
const BoxDecoration(color: AppColor.secondaryColor),
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(
borderRadius: BorderRadius.only(),
gapPadding: 4,
borderSide: BorderSide(
color: AppColor.redColor,
width: 2,
)),
suffixIcon: const Icon(Icons.search),
hintText: controller.hintTextwayPoint2.tr,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.wayPoint2Controller.clear();
controller.clearPlaces2();
},
icon: Icon(
Icons.clear,
color: Colors.red[300],
),
),
),
controller: controller.wayPoint2Controller,
onChanged: (value) {
if (controller.wayPoint2Controller.text.length > 5) {
controller.getPlacesListsWayPoint2();
controller.changeHeightPlaces2();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.wayPoint2.isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap2 = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
child: Text(
'Choose from Map'.tr,
style:
AppStyle.title.copyWith(color: AppColor.blueColor),
),
)
: const SizedBox(),
Container(
height: controller.wayPoint2.isNotEmpty ? controller.height : 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.wayPoint2.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.wayPoint2[index];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
if (controller.currentLocationToFormPlaces2 == true) {
controller.newStartPointLocation =
controller.myLocation;
} else {
controller.myLocation =
controller.newStartPointLocation;
}
controller.convertHintTextPlaces2(index);
controller.currentLocationString2 = res['name'];
controller.wayPoint2 = [];
controller.wayPoint2Controller.clear();
Get.back();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Image.network(
res['icon'],
width: 20,
),
IconButton(
onPressed: () async {
await sql.insertData({
'latitude': res['geometry']
['location']['lat'],
'longitude': res['geometry']
['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
}, TableName.placesFavorite);
Toast.show(
context,
'${res['name']} ${'Saved Sucssefully'.tr}',
AppColor.primaryColor);
},
icon: const Icon(Icons.favorite_border),
),
],
),
Column(
children: [
Text(
res['name'].toString(),
style: AppStyle.title,
),
Text(
res['vicinity'].toString(),
style: AppStyle.subtitle,
),
],
),
Column(
children: [
Text(
'rate',
style: AppStyle.subtitle,
),
Text(
res['rating'].toString(),
style: AppStyle.subtitle,
),
],
),
],
),
const Divider(
thickness: 1,
)
],
),
),
);
},
),
)
],
));
}
GetBuilder<MapPassengerController> formSearchPlaces3() {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Container(
decoration:
const BoxDecoration(color: AppColor.secondaryColor),
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(
borderRadius: BorderRadius.only(),
gapPadding: 4,
borderSide: BorderSide(
color: AppColor.redColor,
width: 2,
)),
suffixIcon: const Icon(Icons.search),
hintText: controller.hintTextwayPoint3.tr,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.wayPoint3Controller.clear();
controller.clearPlaces3();
},
icon: Icon(
Icons.clear,
color: Colors.red[300],
),
),
),
controller: controller.wayPoint3Controller,
onChanged: (value) {
if (controller.wayPoint3Controller.text.length > 5) {
controller.getPlacesListsWayPoint3();
controller.changeHeightPlaces3();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.wayPoint3.isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap3 = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
child: Text(
'Choose from Map'.tr,
style:
AppStyle.title.copyWith(color: AppColor.blueColor),
),
)
: const SizedBox(),
Container(
height: controller.wayPoint3.isNotEmpty ? controller.height : 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.wayPoint3.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.wayPoint3[index];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
if (controller.currentLocationToFormPlaces3 == true) {
controller.newStartPointLocation =
controller.myLocation;
} else {
controller.myLocation =
controller.newStartPointLocation;
}
controller.convertHintTextPlaces3(index);
controller.currentLocationString3 = res['name'];
controller.wayPoint3 = [];
controller.wayPoint3Controller.clear();
Get.back();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Image.network(
res['icon'],
width: 20,
),
IconButton(
onPressed: () async {
await sql.insertData({
'latitude': res['geometry']
['location']['lat'],
'longitude': res['geometry']
['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
}, TableName.placesFavorite);
Toast.show(
context,
'${res['name']} ${'Saved Sucssefully'.tr}',
AppColor.primaryColor);
},
icon: const Icon(Icons.favorite_border),
),
],
),
Column(
children: [
Text(
res['name'].toString(),
style: AppStyle.title,
),
Text(
res['vicinity'].toString(),
style: AppStyle.subtitle,
),
],
),
Column(
children: [
Text(
'rate',
style: AppStyle.subtitle,
),
Text(
res['rating'].toString(),
style: AppStyle.subtitle,
),
],
),
],
),
const Divider(
thickness: 1,
)
],
),
),
);
},
),
)
],
));
}
GetBuilder<MapPassengerController> formSearchPlaces4() {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Container(
decoration:
const BoxDecoration(color: AppColor.secondaryColor),
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(
borderRadius: BorderRadius.only(),
gapPadding: 4,
borderSide: BorderSide(
color: AppColor.redColor,
width: 2,
)),
suffixIcon: const Icon(Icons.search),
hintText: controller.hintTextwayPoint4.tr,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.wayPoint4Controller.clear();
controller.clearPlaces4();
},
icon: Icon(
Icons.clear,
color: Colors.red[300],
),
),
),
controller: controller.wayPoint4Controller,
onChanged: (value) {
if (controller.wayPoint4Controller.text.length > 5) {
controller.getPlacesListsWayPoint4();
controller.changeHeightPlaces4();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.wayPoint4.isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap4 = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
child: Text(
'Choose from Map'.tr,
style:
AppStyle.title.copyWith(color: AppColor.blueColor),
),
)
: const SizedBox(),
Container(
height: controller.wayPoint4.isNotEmpty ? controller.height : 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.wayPoint4.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.wayPoint4[index];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
if (controller.currentLocationToFormPlaces4 == true) {
controller.newStartPointLocation =
controller.myLocation;
} else {
controller.myLocation =
controller.newStartPointLocation;
}
controller.convertHintTextPlaces4(index);
controller.currentLocationString4 = res['name'];
controller.wayPoint4 = [];
controller.wayPoint4Controller.clear();
Get.back();
controller.convertHintTextPlaces(index, res);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:ride/controller/home/points_for_rider_controller.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
@@ -9,10 +10,10 @@ import '../../widgets/elevated_btn.dart';
import '../../widgets/mycircular.dart';
class GoogleMapPassengerWidget extends StatelessWidget {
const GoogleMapPassengerWidget({
GoogleMapPassengerWidget({
super.key,
});
WayPointController wayPointController = Get.put(WayPointController());
@override
Widget build(BuildContext context) {
return GetBuilder<MapPassengerController>(
@@ -199,6 +200,55 @@ class GoogleMapPassengerWidget extends StatelessWidget {
color: AppColor.primaryColor,
width: 5,
),
Polyline(
zIndex: 1,
consumeTapEvents: true,
geodesic: true,
endCap: Cap.buttCap,
startCap: Cap.buttCap,
visible: true,
polylineId: const PolylineId('route0'),
points: controller.polylineCoordinatesPointsAll[0],
color: AppColor.blueColor,
width: 5,
),
Polyline(
zIndex: 2,
consumeTapEvents: true,
geodesic: true,
endCap: Cap.buttCap,
startCap: Cap.buttCap,
visible: true,
polylineId: const PolylineId('route1'),
points: controller.polylineCoordinatesPointsAll[1],
color: AppColor.yellowColor,
width: 5,
),
Polyline(
zIndex: 2,
consumeTapEvents: true,
geodesic: true,
endCap: Cap.buttCap,
startCap: Cap.buttCap,
visible: true,
polylineId: const PolylineId('route2'),
points: controller.polylineCoordinatesPointsAll[2],
color: AppColor.greenColor,
width: 5,
),
Polyline(
zIndex: 2,
consumeTapEvents: true,
geodesic: true,
endCap: Cap.buttCap,
startCap: Cap.buttCap,
visible: true,
polylineId: const PolylineId('route3'),
points: controller.polylineCoordinatesPointsAll[2],
color: AppColor.deepPurpleAccent,
width: 5,
),
// Polyline(
// zIndex: 2,
// consumeTapEvents: true,

View File

@@ -30,14 +30,53 @@ class PointsPageForRider extends StatelessWidget {
child: ListView(
children: [
// const AppBarPointsPageForRider(),
IconButton(
onPressed: () {
mapPassengerController.changeWayPointSheet();
},
icon: const Icon(Icons.arrow_drop_down_circle_outlined),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {
mapPassengerController.changeWayPointSheet();
},
icon: const Icon(Icons.arrow_drop_down_circle_outlined),
),
GetBuilder<WayPointController>(builder: (wayPointController) {
return Row(
children: [
ElevatedButton(
onPressed: () {
wayPointController.addWayPoints();
},
child: const Text('Add Text Field'),
),
wayPointController.wayPoints.length > 1
? ElevatedButton(
onPressed: () {
print(mapPassengerController.placesCoordinate
.toString());
for (var i = 0;
i < wayPointController.wayPoints.length;
i++) {
mapPassengerController.getMapPoints(
mapPassengerController.placesCoordinate[i]
.toString(),
mapPassengerController
.placesCoordinate[i + 1]
.toString(),
i,
);
}
},
child: const Text('Get Map'),
)
: const SizedBox()
],
);
}),
],
),
SizedBox(
height: Get.height * .57,
height: Get.height * .36,
child: GetBuilder<WayPointController>(
builder: (wayPointController) {
return ReorderableListView(
@@ -50,7 +89,7 @@ class PointsPageForRider extends StatelessWidget {
final wayPoint = entry.value;
return Padding(
key: ValueKey(index),
padding: const EdgeInsets.all(6),
padding: const EdgeInsets.all(1),
child: ListTile(
leading: Container(
decoration: BoxDecoration(
@@ -86,35 +125,39 @@ class PointsPageForRider extends StatelessWidget {
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,
),
Text(mapPassengerController
.currentLocationStringAll[index]
.toString())
// 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,
@@ -148,14 +191,6 @@ class PointsPageForRider extends StatelessWidget {
);
}),
),
GetBuilder<WayPointController>(builder: (wayPointController) {
return ElevatedButton(
onPressed: () {
wayPointController.addWayPoints();
},
child: const Text('Add Text Field'),
);
}),
],
),
),