This commit is contained in:
Hamza-Ayed
2023-12-31 00:11:49 +03:00
parent 1b9b0dc9e8
commit c2dc5ec44c
21 changed files with 792 additions and 496 deletions

View File

@@ -29,13 +29,13 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
width: 2,
)),
suffixIcon: const Icon(Icons.search),
hintText: 'Search for your destination'.tr,
hintText: controller.hintTextDestinationPoint,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.placeController.clear();
controller.clearPlaces();
controller.placeDestinationController.clear();
controller.clearPlacesDestination();
},
icon: Icon(
Icons.clear,
@@ -43,18 +43,19 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
),
),
),
controller: controller.placeController,
controller: controller.placeDestinationController,
onChanged: (value) {
if (controller.placeController.text.length > 5) {
if (controller.placeDestinationController.text.length >
5) {
controller.getPlaces();
controller.changeHeight();
controller.changeHeightPlaces();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.places.isEmpty
controller.placesDestination.isEmpty
? InkWell(
onTap: () {
controller.changeMainBottomMenuMap();
@@ -68,37 +69,25 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
)
: const SizedBox(),
Container(
height: controller.places.isNotEmpty ? controller.height : 0,
height: controller.placesDestination.isNotEmpty
? controller.height
: 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.places.length,
itemCount: controller.placesDestination.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.places[index];
var res = controller.placesDestination[index];
return InkWell(
onTap: () {
controller.changeHeight();
Get.defaultDialog(
title:
'${'Are You sure to ride to'.tr} ${res['name']}',
middleText: '',
titleStyle: AppStyle.title,
confirm: MyElevatedButton(
title: 'Confirm'.tr,
onPressed: () async {
controller.clearPolyline();
controller.data = [];
await controller.getMap(
'${controller.myLocation.latitude.toString()},${controller.myLocation.longitude.toString()}',
"${res['geometry']['location']['lat']},${res['geometry']['location']['lng']}");
controller.places = [];
controller.placeController.clear();
onTap: () async {
controller.changeHeightPlaces();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
controller.changeMainBottomMenuMap();
}),
);
controller.changeHeightPlaces();
controller.myLocation = controller.newMyLocation;
controller.convertHintTextDestinationNewPlaces(index);
controller.placesDestination = [];
controller.placeDestinationController.clear();
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),

View File

@@ -0,0 +1,165 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/table_names.dart';
import 'package:ride/views/widgets/my_textField.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
import '../../../controller/functions/toast.dart';
import '../../../controller/home/map_passenger_controller.dart';
import '../../../main.dart';
GetBuilder<MapPassengerController> formSearchPlacesStart() {
// 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.hintTextStartPoint,
hintStyle: AppStyle.title,
hintMaxLines: 1,
prefixIcon: IconButton(
onPressed: () {
controller.placeStartController.clear();
controller.clearPlacesStart();
},
icon: Icon(
Icons.clear,
color: Colors.red[300],
),
),
),
controller: controller.placeStartController,
onChanged: (value) {
if (controller.placeStartController.text.length > 5) {
controller.getPlacesStart();
controller.changeHeightStartPlaces();
}
},
// onEditingComplete: () => controller.changeHeight(),
),
),
),
controller.placesDestination.isEmpty
? InkWell(
onTap: () {
controller.startLocationFromMap = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
child: Text(
'Choose from Map'.tr,
style:
AppStyle.title.copyWith(color: AppColor.blueColor),
),
)
: const SizedBox(),
Container(
height:
controller.placesStart.isNotEmpty ? controller.height : 0,
color: AppColor.secondaryColor,
child: ListView.builder(
itemCount: controller.placesStart.length,
itemBuilder: (BuildContext context, int index) {
var res = controller.placesStart[index];
return InkWell(
onTap: () async {
controller.changeHeightPlaces();
// if (controller.currentLocationToFormPlaces == true) {
// controller.newStartPointLocation =
// controller.myLocation;
// } else {
// controller.myLocation =
// controller.newStartPointLocation;
// }
controller.convertHintTextStartNewPlaces(index);
controller.currentLocationString = res['name'];
controller.placesStart = [];
controller.placeStartController.clear();
},
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,
)
],
),
),
);
},
),
)
],
));
}

View File

@@ -149,9 +149,24 @@ class GoogleMapPassengerWidget extends StatelessWidget {
markerId: MarkerId(carLocation.toString())),
Marker(
markerId: MarkerId('MyLocation'.tr),
position: controller.myLocation,
position: controller.newStartPointLocation,
draggable: true,
icon: controller.markerIcon,
icon: controller.tripIcon,
infoWindow: const InfoWindow(
title: 'Time',
// snippet: controller.durationFromDriverToPassenger
// .toString(),
),
onDragEnd: (value) {
print(value);
},
// infoWindow: InfoWindow(title: 'my location'.tr),
),
Marker(
markerId: MarkerId('Destination'.tr),
position: controller.newMyLocation,
draggable: true,
icon: controller.tripIcon,
infoWindow: const InfoWindow(
title: 'Time',
// snippet: controller.durationFromDriverToPassenger
@@ -230,7 +245,11 @@ class GoogleMapPassengerWidget extends StatelessWidget {
buildingsEnabled: true,
mapToolbarEnabled: true,
onCameraMove: (position) {
if (controller.startLocationFromMap == true) {
controller.newStartPointLocation = position.target;
}
controller.newMyLocation = position.target;
// print('my' + controller.mylocation.toString());
// print('new' + controller.newMylocation.toString());
},

View File

@@ -10,6 +10,7 @@ import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart';
import '../../../constant/table_names.dart';
import '../../../controller/functions/toast.dart';
import 'form_search_start.dart';
class MainBottomMenuMap extends StatelessWidget {
const MainBottomMenuMap({super.key});
@@ -37,185 +38,245 @@ class MainBottomMenuMap extends StatelessWidget {
topLeft: Radius.circular(15),
topRight: Radius.circular(15),
)),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(15),
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: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(15),
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: DefaultTextStyle(
style: AppStyle.title,
child: Center(
child: controller.isPickerShown
? TextButton(
onPressed: () async {
controller.clearPolyline();
controller.data = [];
await controller.getMap(
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
'${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
);
controller.places = [];
controller.placeController.clear();
child: DefaultTextStyle(
style: AppStyle.title,
child: Center(
child: controller.isPickerShown
? TextButton(
onPressed: () async {
controller.clearPolyline();
controller.data = [];
if (controller
.startLocationFromMap ==
true) {
controller.newMyLocation =
controller
.newStartPointLocation;
controller.startLocationFromMap =
false;
controller.isPickerShown = false;
print(controller.myLocation);
print(controller
.newStartPointLocation);
} else {
controller.newMyLocation =
controller.newMyLocation;
controller.isPickerShown = false;
print(controller.myLocation);
print(controller.newMyLocation);
}
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
// controller.changeMainBottomMenuMap();
},
child: Row(
// await controller.getMap(
// '${controller.myLocation.latitude},${controller.myLocation.longitude}',
// '${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
// );
controller.placesDestination = [];
controller
.placeDestinationController
.clear();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
controller
.changeMainBottomMenuMap();
},
child: Row(
children: [
IconButton(
onPressed: () {
controller
.changeMainBottomMenuMap();
},
icon: controller
.isMainBottomMenuMap
? const Icon(
Icons
.arrow_circle_up_rounded,
size: 35,
)
: const Icon(
Icons
.arrow_circle_down_rounded,
size: 35,
),
),
Text(
"Click here point".tr,
style: AppStyle.title,
),
],
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
IconButton(
onPressed: () {
controller
.changeMainBottomMenuMap();
},
icon:
controller.isMainBottomMenuMap
? const Icon(
Icons
.arrow_circle_up_rounded,
size: 35,
)
: const Icon(
Icons
.arrow_circle_down_rounded,
size: 35,
SizedBox(
height: 30,
child: Row(
children: [
IconButton(
onPressed: () {
controller
.changeMainBottomMenuMap();
},
icon: controller
.isMainBottomMenuMap
? const Icon(
Icons
.arrow_circle_up_rounded,
size: 35,
)
: const Icon(
Icons
.arrow_circle_down_rounded,
size: 35,
),
),
Text(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
],
)),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
const SizedBox(
width: 10,
),
controller.noCarString == false
? Text(
'Nearest Car for you about '
.tr)
: Container(
decoration:
BoxDecoration(
borderRadius:
BorderRadius
.circular(12),
color:
AppColor.redColor,
),
),
Text(
"Click here to go to this location"
.tr,
style: AppStyle.title,
),
child: Padding(
padding:
const EdgeInsets
.all(6),
child: Text(
'No Car in your site. Sorry!'
.tr,
style: AppStyle
.title
.copyWith(
color: AppColor
.secondaryColor),
),
),
),
controller.noCarString == false
? Container(
decoration: BoxDecoration(
border: Border.all(
color: AppColor
.redColor,
width: 3)),
child: Padding(
padding:
const EdgeInsets
.all(4),
child: Text((controller
.nearestCar !=
null
? controller
.durationByPassenger
.toString()
: 'N/A')),
),
)
: const SizedBox(),
],
)
],
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
SizedBox(
height: 30,
child: Row(
children: [
IconButton(
onPressed: () {
controller
.changeMainBottomMenuMap();
},
icon: controller
.isMainBottomMenuMap
? const Icon(
Icons
.arrow_circle_up_rounded,
size: 35,
)
: const Icon(
Icons
.arrow_circle_down_rounded,
size: 35,
),
),
Text(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
],
)),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
const SizedBox(
width: 10,
),
controller.noCarString == false
? Text(
'Nearest Car for you about '
.tr)
: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(12),
color:
AppColor.redColor,
),
child: Padding(
padding:
const EdgeInsets
.all(6),
child: Text(
'No Car in your site. Sorry!'
.tr,
style: AppStyle.title
.copyWith(
color: AppColor
.secondaryColor),
),
),
),
controller.noCarString == false
? Container(
decoration: BoxDecoration(
border: Border.all(
color: AppColor
.redColor,
width: 3)),
child: Padding(
padding:
const EdgeInsets
.all(4),
child: Text((controller
.nearestCar !=
null
? controller
.durationByPassenger
.toString()
: 'N/A')),
),
)
: const SizedBox(),
],
)
],
),
),
)),
),
)),
),
),
),
controller.isMainBottomMenuMap
? const FavioratePlacesDialogu()
: const SizedBox(),
controller.isMainBottomMenuMap
? const SizedBox()
: Text(
'From : Current Location'.tr,
style: AppStyle.subtitle,
),
controller.isMainBottomMenuMap
? const SizedBox()
: formSearchPlaces()
],
controller.isMainBottomMenuMap
? const FavioratePlacesDialogu()
: const SizedBox(),
controller.isMainBottomMenuMap
? const SizedBox()
: InkWell(
onTap: () async {
controller.getCurrentLocationFormString();
},
child: Text(
'From : ${controller.currentLocationString}'.tr,
style: AppStyle.subtitle,
),
),
controller.isMainBottomMenuMap
? const SizedBox()
: Column(
children: [
controller.currentLocationToFormPlaces
? const SizedBox()
: formSearchPlacesStart(),
formSearchPlaces(),
const SizedBox(
height: 30,
),
MyElevatedButton(
title: 'Go to Ride',
onPressed: () async {
controller.changeMainBottomMenuMap();
await controller.getMap(
'${controller.newStartPointLocation.latitude},${controller.newStartPointLocation.longitude}',
'${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
);
controller.currentLocationToFormPlaces =
false;
controller.placesDestination = [];
controller.clearPlacesStart();
controller.clearPlacesDestination();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
})
],
)
],
),
),
),
));
@@ -270,13 +331,15 @@ class FavioratePlacesDialogu extends StatelessWidget {
children: [
TextButton(
onPressed: () async {
Get.back();
await controller.getLocation();
await controller.getMap(
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
);
// controller.changePickerShown();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
},
child: Text(

View File

@@ -56,7 +56,7 @@ class PickerAnimtionContainerFormPlaces extends StatelessWidget {
? InkWell(
onTapDown: (details) {
controller.changePickerShown();
controller.changeHeight();
controller.changeHeightPlaces();
},
child: Container(
height: 7,
@@ -188,7 +188,7 @@ class PickerAnimtionContainerFormPlaces extends StatelessWidget {
],
),
if (controller.isPickerShown &&
controller.places.isEmpty)
controller.placesDestination.isEmpty)
MyElevatedButton(
title: 'Go to this Target'.tr,
onPressed: () async {
@@ -205,7 +205,7 @@ class PickerAnimtionContainerFormPlaces extends StatelessWidget {
},
),
if (controller.isPickerShown &&
controller.places.isEmpty)
controller.placesDestination.isEmpty)
const SizedBox(),
],
),