import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:ride/constant/table_names.dart'; import 'package:ride/models/db_sql.dart'; import '../../../constant/colors.dart'; import '../../../constant/style.dart'; import '../../../controller/home/map_page_controller.dart'; import '../../../main.dart'; import '../../widgets/elevated_btn.dart'; import 'form_search_places.dart'; class PickerAnimtionContainerFormPlaces extends StatelessWidget { PickerAnimtionContainerFormPlaces({ super.key, }); final controller = MapController(); @override Widget build(BuildContext context) { // DbSql sql = DbSql.instance; return GetBuilder( 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 ', style: AppStyle.title, ), Column( mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox( height: 5, ), controller.isPickerShown ? InkWell( onTapDown: (details) { controller.changePickerShown(); controller.changeHeight(); }, 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: formSearchPlaces(), ) : 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.mylocation.latitude},${controller.mylocation.longitude}', '${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}', ); controller .changePickerShown(); controller .changeButtomSheetShown(); 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 ${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.places.isEmpty) MyElevatedButton( title: 'Go to this Target', onPressed: () async { await controller.getMap( '${controller.mylocation.latitude},${controller.mylocation.longitude}', '${controller.newMylocation.latitude},${controller.newMylocation.longitude}', ); controller.changePickerShown(); controller.changeButtomSheetShown(); controller.bottomSheet(); // await sql // .getAllData(TableName.placesFavorite) // .then((value) => print(value)); }, ), if (controller.isPickerShown && controller.places.isEmpty) const SizedBox(), ], ), ], ), ), )); } }