218 lines
12 KiB
Dart
218 lines
12 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:SEFER/constant/table_names.dart';
|
|
|
|
import '../../../constant/colors.dart';
|
|
import '../../../constant/style.dart';
|
|
import '../../../controller/home/map_passenger_controller.dart';
|
|
import '../../../main.dart';
|
|
import '../../widgets/elevated_btn.dart';
|
|
import 'form_search_places_destenation.dart';
|
|
|
|
class PickerAnimtionContainerFormPlaces extends StatelessWidget {
|
|
PickerAnimtionContainerFormPlaces({
|
|
super.key,
|
|
});
|
|
final controller = MapPassengerController();
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// DbSql sql = DbSql.instance;
|
|
return GetBuilder<MapPassengerController>(
|
|
builder: (controller) => Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 5,
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 300),
|
|
height: controller.heightPickerContainer,
|
|
decoration: const 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: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
controller.isPickerShown
|
|
? const SizedBox()
|
|
: Text(
|
|
'Hi, Where to '.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
controller.isPickerShown
|
|
? InkWell(
|
|
onTapDown: (details) {
|
|
controller.changePickerShown();
|
|
controller.changeHeightPlaces();
|
|
},
|
|
child: Container(
|
|
height: 7,
|
|
width: Get.width * .3,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.accentColor,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(
|
|
color: AppColor.accentColor,
|
|
)),
|
|
),
|
|
)
|
|
: const SizedBox(),
|
|
controller.isPickerShown
|
|
? InkWell(
|
|
onTap: () {},
|
|
child: formSearchPlacesDestenation(),
|
|
)
|
|
: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () {
|
|
controller.changePickerShown();
|
|
},
|
|
child: Text(
|
|
"Pick your destination from Map".tr,
|
|
style: AppStyle.subtitle,
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () async {
|
|
List favoritePlaces = await sql
|
|
.getAllData(TableName.placesFavorite);
|
|
print(favoritePlaces);
|
|
Get.defaultDialog(
|
|
title: 'Favorite Places'.tr,
|
|
content: SizedBox(
|
|
width: Get.width * .8,
|
|
height: 300,
|
|
child: favoritePlaces.isEmpty
|
|
? Center(
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.center,
|
|
children: [
|
|
const Icon(
|
|
Icons
|
|
.hourglass_empty_rounded,
|
|
size: 99,
|
|
color: AppColor
|
|
.primaryColor,
|
|
),
|
|
Text(
|
|
'You Dont Have Any places yet !'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
)
|
|
: ListView.builder(
|
|
itemCount:
|
|
favoritePlaces.length,
|
|
itemBuilder:
|
|
(BuildContext context,
|
|
int index) {
|
|
return Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.spaceBetween,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () async {
|
|
await controller
|
|
.getMap(
|
|
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
|
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
|
|
);
|
|
controller
|
|
.changePickerShown();
|
|
controller
|
|
.changeBottomSheetShown();
|
|
controller
|
|
.bottomSheet();
|
|
Get.back();
|
|
},
|
|
child: Text(
|
|
favoritePlaces[
|
|
index]['name'],
|
|
style:
|
|
AppStyle.title,
|
|
),
|
|
),
|
|
IconButton(
|
|
onPressed: () async {
|
|
await sql.deleteData(
|
|
TableName
|
|
.placesFavorite,
|
|
favoritePlaces[
|
|
index]
|
|
['id']);
|
|
Get.back();
|
|
Get.snackbar(
|
|
'Deleted ',
|
|
'${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
|
|
backgroundColor:
|
|
AppColor
|
|
.accentColor);
|
|
},
|
|
icon: const Icon(Icons
|
|
.favorite_outlined),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
onCancel: () {},
|
|
);
|
|
},
|
|
child: Text(
|
|
"Go To Favorite Places".tr,
|
|
style: AppStyle.subtitle,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (controller.isPickerShown &&
|
|
controller.placesDestination.isEmpty)
|
|
MyElevatedButton(
|
|
title: 'Go to this Target'.tr,
|
|
onPressed: () async {
|
|
await controller.getMap(
|
|
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
|
'${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
|
|
);
|
|
controller.changePickerShown();
|
|
controller.changeBottomSheetShown();
|
|
controller.bottomSheet();
|
|
// await sql
|
|
// .getAllData(TableName.placesFavorite)
|
|
// .then((value) => print(value));
|
|
},
|
|
),
|
|
if (controller.isPickerShown &&
|
|
controller.placesDestination.isEmpty)
|
|
const SizedBox(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
}
|
|
}
|