24-12/26/1

This commit is contained in:
Hamza-Ayed
2024-12-26 00:58:41 +03:00
parent 970e444f4a
commit 186cd3aa54
14 changed files with 2912 additions and 3466 deletions

View File

@@ -9,181 +9,130 @@ import '../../../controller/home/map_passenger_controller.dart';
import '../../../main.dart';
GetBuilder<MapPassengerController> formSearchPlacesStart() {
// DbSql sql = DbSql.instance;
return GetBuilder<MapPassengerController>(
builder: (controller) => Column(
builder: (controller) => Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: Get.width * .75,
height: 40,
decoration:
const BoxDecoration(color: AppColor.secondaryColor),
child: TextFormField(
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(
Expanded(
child: TextFormField(
controller: controller.placeStartController,
onChanged: (value) {
if (controller.placeStartController.text.length > 2) {
// Reduced character limit
controller.getPlacesStart();
controller.changeHeightStartPlaces();
} else if (controller.placeStartController.text.isEmpty) {
controller.clearPlacesStart();
controller.changeHeightPlaces(); // Collapse if empty
}
},
decoration: InputDecoration(
hintText: controller.hintTextStartPoint,
hintStyle:
AppStyle.subtitle.copyWith(color: Colors.grey[600]),
prefixIcon:
const Icon(Icons.search, color: AppColor.primaryColor),
suffixIcon: controller.placeStartController.text.isNotEmpty
? IconButton(
icon: Icon(Icons.clear, color: Colors.grey[400]),
onPressed: () {
controller.placeStartController.clear();
controller.clearPlacesStart();
controller
.changeHeightPlaces(); // Collapse on clear
},
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(),
),
)
: null,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide.none,
),
IconButton(
onPressed: () {
controller.startLocationFromMap = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
icon: const Icon(
Icons.map_outlined,
color: AppColor.yellowColor,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(color: AppColor.primaryColor),
),
],
filled: true,
fillColor: Colors.grey[50],
),
),
),
// controller.placesDestination.isEmpty
// ? InkWell(
// onTap: () {
// controller.startLocationFromMap = true;
// controller.changeMainBottomMenuMap();
// controller.changePickerShown();
// },
// child: Text(
// 'Choose from Map Start Point'.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;
// }
await sql.insertMapLocation({
'latitude': res['geometry']['location']['lat'],
'longitude': res['geometry']['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
'createdAt': DateTime.now().toIso8601String(),
}, TableName.recentLocations);
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.insertMapLocation({
'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,
)
],
),
),
);
const SizedBox(width: 8.0),
IconButton(
onPressed: () {
controller.startLocationFromMap = true;
controller.changeMainBottomMenuMap();
controller.changePickerShown();
},
icon: Icon(Icons.location_on_outlined,
color: AppColor.accentColor, size: 30),
tooltip: 'Choose on Map',
),
],
),
),
AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: controller.placesStart.isNotEmpty ? controller.height : 0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
),
margin: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: controller.placesStart.length,
separatorBuilder: (context, index) =>
const Divider(height: 1, color: Colors.grey),
itemBuilder: (BuildContext context, int index) {
var res = controller.placesStart[index];
return ListTile(
leading: Image.network(res['icon'], width: 30, height: 30),
title: Text(res['name'].toString(),
style: AppStyle.subtitle
.copyWith(fontWeight: FontWeight.w500)),
subtitle: Text(res['vicinity'].toString(),
style: TextStyle(color: Colors.grey[600], fontSize: 12)),
trailing: IconButton(
icon: const Icon(Icons.favorite_border, color: Colors.grey),
onPressed: () async {
await sql.insertMapLocation({
'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 Successfully'.tr}',
AppColor.primaryColor);
},
),
)
],
));
onTap: () async {
controller.changeHeightPlaces();
await sql.insertMapLocation({
'latitude': res['geometry']['location']['lat'],
'longitude': res['geometry']['location']['lng'],
'name': res['name'].toString(),
'rate': res['rating'].toString(),
'createdAt': DateTime.now().toIso8601String(),
}, TableName.recentLocations);
controller.convertHintTextStartNewPlaces(index);
controller.currentLocationString = res['name'];
controller.placesStart = [];
controller.placeStartController.clear();
},
);
},
),
),
],
),
);
}