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

@@ -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'),
);
}),
],
),
),