This commit is contained in:
Hamza-Ayed
2024-03-21 02:09:52 +03:00
parent ad062d9ad7
commit 045f7e20f0
46 changed files with 2767 additions and 877 deletions

View File

@@ -10,6 +10,7 @@ import 'package:SEFER/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart';
import '../../../constant/table_names.dart';
import '../../../controller/functions/toast.dart';
import '../../../controller/functions/tts.dart';
import 'form_search_start.dart';
class MainBottomMenuMap extends StatelessWidget {
@@ -23,298 +24,313 @@ class MainBottomMenuMap extends StatelessWidget {
bottom: 3,
left: 5,
right: 5,
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
height: controller.mainBottomMenuMapHeight,
decoration: AppStyle.boxDecoration,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
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 = [];
if (controller
.startLocationFromMap ==
true) {
controller.newMyLocation =
controller
.newStartPointLocation;
controller.hintTextStartPoint =
'${controller.newStartPointLocation.latitude.toStringAsFixed(4)} , ${controller.newStartPointLocation.longitude.toStringAsFixed(4)}';
controller.startLocationFromMap =
false;
controller.isPickerShown = false;
} else if (controller
.workLocationFromMap ==
true) {
controller
.hintTextDestinationPoint =
'To Work'.tr;
box.write(BoxName.addWork,
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}');
controller.newMyLocation =
controller.newMyLocation;
controller.isPickerShown = false;
controller.workLocationFromMap =
false;
Toast.show(
context,
'Work Saved'.tr,
AppColor.greenColor);
} else if (controller
.homeLocationFromMap ==
true) {
controller
.hintTextDestinationPoint =
'To Home'.tr;
box.write(BoxName.addHome,
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}');
controller.newMyLocation =
controller.newMyLocation;
controller.isPickerShown = false;
controller.homeLocationFromMap =
false;
controller.update();
Toast.show(
context,
'Home Saved'.tr,
AppColor.greenColor);
} else {
controller
.hintTextDestinationPoint =
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}';
controller.newMyLocation =
controller.newMyLocation;
controller.isPickerShown = false;
}
child: GestureDetector(
onVerticalDragUpdate: (DragUpdateDetails details) {
// Update the size of the GestureDetector based on the user's finger position.
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,
),
],
),
)
: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {
controller
.changeMainBottomMenuMap();
},
icon:
controller.isMainBottomMenuMap
? const Icon(
Icons.ads_click,
size: 35,
)
: const Icon(
Icons
.arrow_circle_down_rounded,
size: 35,
),
),
Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
SizedBox(
height: 30,
child: Text(
'${'Where to'.tr} ${box.read(BoxName.name)}')),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
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(),
],
)
],
),
],
// _height = details.globalPosition.dy;
controller.changeMainBottomMenuMap();
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
height: controller.mainBottomMenuMapHeight,
decoration: AppStyle.boxDecoration,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
controller.isMainBottomMenuMap
? Padding(
padding: const EdgeInsets.all(15),
child: InkWell(
onTap: () =>
controller.changeMainBottomMenuMap(),
child: Container(
width: Get.width * .8,
height: Get.height * .1,
decoration: AppStyle.boxDecoration1,
child: DefaultTextStyle(
style: AppStyle.title,
child: Center(
child: controller.isPickerShown
? clickPointPosition(
controller, context)
: whereWidgetsmall(controller),
),
)),
),
)),
),
),
controller.isMainBottomMenuMap
? const FavioratePlacesDialogu()
: const SizedBox(),
controller.isMainBottomMenuMap
? const SizedBox()
: InkWell(
onTap: () async {
controller.getCurrentLocationFormString();
},
child: Text(
'From :'.tr +
' ${controller.currentLocationString}'.tr,
style: AppStyle.subtitle,
)
: IconButton(
onPressed: () {
controller.changeMainBottomMenuMap();
},
icon: controller.isMainBottomMenuMap
? const Icon(
Icons.ads_click,
size: 35,
)
: const Icon(
Icons.arrow_circle_down_rounded,
size: 35,
),
),
),
controller.isMainBottomMenuMap
? const SizedBox()
: Column(
children: [
controller.currentLocationToFormPlaces
? const SizedBox()
: formSearchPlacesStart(),
formSearchPlacesDestenation(),
const SizedBox(
height: 10,
controller.isMainBottomMenuMap
? recentPlacesWidget(controller)
: const SizedBox(),
controller.isMainBottomMenuMap
? const SizedBox()
: InkWell(
onTap: () async {
controller.getCurrentLocationFormString();
},
child: Text(
'From :'.tr +
' ${controller.currentLocationString}'.tr,
style: AppStyle.subtitle,
),
MyElevatedButton(
title: 'Get Details of Trip'.tr,
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.isCancelRidePageShown = true;
controller.clearPlacesStart();
controller.clearPlacesDestination();
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,
),
controller.isMainBottomMenuMap
? const SizedBox()
: Column(
children: [
controller.currentLocationToFormPlaces
? const SizedBox()
: formSearchPlacesStart(),
formSearchPlacesDestenation(),
const SizedBox(
height: 10,
),
),
],
)
],
MyElevatedButton(
title: 'Get Details of Trip'.tr,
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.isCancelRidePageShown = true;
controller.clearPlacesStart();
controller.clearPlacesDestination();
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,
),
),
],
)
],
),
),
),
),
));
}
SizedBox recentPlacesWidget(MapPassengerController controller) {
final textToSpeechController = Get.put(TextToSpeechController());
return SizedBox(
height: 50,
child: ListView.builder(
itemCount: controller.recentPlaces.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return TextButton(
onPressed: () {
Get.defaultDialog(
title: 'Are you want to go this site'.tr,
titleStyle: AppStyle.title,
middleText: '',
content: IconButton(
onPressed: () {
textToSpeechController
.speakText('Are you want to go this site'.tr);
},
icon: const Icon(
Icons.headphones,
size: 45,
),
),
confirm: MyElevatedButton(
title: 'Yes'.tr,
onPressed: () async {
await controller.getLocation();
await controller.getMap(
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
'${controller.recentPlaces[index]['latitude']},${controller.recentPlaces[index]['longitude']}',
);
// controller.changePickerShown();
controller.showBottomSheet1();
// controller.showBottomSheet1();
Get.back();
},
));
},
child: Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(2),
child: Text(
controller.recentPlaces[index]['name'],
style: AppStyle.title,
),
),
),
);
},
),
);
}
TextButton clickPointPosition(
MapPassengerController controller, BuildContext context) {
return TextButton(
onPressed: () async {
controller.clearPolyline();
controller.data = [];
if (controller.startLocationFromMap == true) {
controller.newMyLocation = controller.newStartPointLocation;
controller.hintTextStartPoint =
'${controller.newStartPointLocation.latitude.toStringAsFixed(4)} , ${controller.newStartPointLocation.longitude.toStringAsFixed(4)}';
controller.startLocationFromMap = false;
controller.isPickerShown = false;
} else if (controller.workLocationFromMap == true) {
controller.hintTextDestinationPoint = 'To Work'.tr;
box.write(BoxName.addWork,
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}');
controller.newMyLocation = controller.newMyLocation;
controller.isPickerShown = false;
controller.workLocationFromMap = false;
Get.snackbar('Work Saved'.tr, '',
backgroundColor: AppColor.greenColor);
} else if (controller.homeLocationFromMap == true) {
controller.hintTextDestinationPoint = 'To Home'.tr;
box.write(BoxName.addHome,
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}');
controller.newMyLocation = controller.newMyLocation;
controller.isPickerShown = false;
controller.homeLocationFromMap = false;
controller.update();
Get.snackbar('Home Saved'.tr, '',
backgroundColor: AppColor.greenColor);
} else {
controller.hintTextDestinationPoint =
'${controller.newMyLocation.latitude.toStringAsFixed(4)} , ${controller.newMyLocation.longitude.toStringAsFixed(4)}';
controller.newMyLocation = controller.newMyLocation;
controller.isPickerShown = false;
}
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,
),
],
),
);
}
Row whereWidgetsmall(MapPassengerController controller) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {
controller.changeMainBottomMenuMap();
},
icon: controller.isMainBottomMenuMap
? const Icon(
Icons.ads_click,
size: 35,
)
: const Icon(
Icons.arrow_circle_down_rounded,
size: 35,
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 30,
child: Text('${'Where to'.tr} ${box.read(BoxName.name)}')),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
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.nearestDistance.toStringAsFixed(0)
: 'N/A')),
),
)
: const SizedBox(),
],
)
],
),
],
);
}
}
class FavioratePlacesDialogu extends StatelessWidget {