Files
tripz/lib/views/home/map_widget.dart/main_bottom_Menu_map.dart
Hamza-Ayed 069ab52a83 8-28/1
2023-08-28 19:13:50 +03:00

226 lines
10 KiB
Dart

import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/controller/home/map_page_controller.dart';
import 'package:ride/main.dart';
import 'package:ride/views/home/map_widget.dart/form_search_places.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart';
import '../../../constant/table_names.dart';
import '../../../controller/functions/toast.dart';
class MainBottomMenuMap extends StatelessWidget {
const MainBottomMenuMap({super.key});
@override
Widget build(BuildContext context) {
Get.put(MapController());
return GetBuilder<MapController>(
builder: (controller) => Positioned(
bottom: 3,
left: 5,
right: 5,
child: AnimatedContainer(
duration: const Duration(milliseconds: 400),
height: controller.mainBottomMenuMap,
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.start,
children: [
Padding(
padding: const EdgeInsets.all(15),
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: GestureDetector(
onTap: () => controller.changeMainBottomMenuMap(),
child: DefaultTextStyle(
style: AppStyle.title,
child: Center(
child: Column(
children: [
SizedBox(
height: 30,
child: AnimatedTextKit(
animatedTexts: [
ScaleAnimatedText(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
WavyAnimatedText(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
FlickerAnimatedText(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
WavyAnimatedText(
'${'Where to'.tr} ${box.read(BoxName.name)}'),
],
isRepeatingAnimation: true,
onTap: () {
print("Tap Event");
},
),
),
Text('Nearest Car for you about '.tr +
(controller.nearestCar != null
? controller.nearestCar!.duration
.toString()
: 'N/A'))
],
),
),
),
)),
),
controller.isMainBottomMenuMap
? const FavioratePlacesDialogu()
: const SizedBox(),
controller.isMainBottomMenuMap
? const SizedBox()
: Text(
'From : Current Location'.tr,
style: AppStyle.subtitle,
),
controller.isMainBottomMenuMap
? const SizedBox()
: formSearchPlaces()
],
),
),
));
}
}
class FavioratePlacesDialogu extends StatelessWidget {
const FavioratePlacesDialogu({
super.key,
});
@override
Widget build(BuildContext context) {
Get.put(MapController());
return GetBuilder<MapController>(
builder: (controller) => DefaultTextStyle(
style: AppStyle.title,
child: Center(
child: AnimatedTextKit(
animatedTexts: [
TypewriterAnimatedText('Favorite Places'.tr),
ScaleAnimatedText(
'Favorite Places'.tr,
),
// TyperAnimatedText(
// 'Favorite Places'.tr,
// ),
],
isRepeatingAnimation: true,
onTap: () 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.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
},
child: Text(
favoritePlaces[index]['name'],
style: AppStyle.title,
),
),
IconButton(
onPressed: () async {
await sql.deleteData(
TableName.placesFavorite,
favoritePlaces[index]['id']);
Get.back();
// ignore: use_build_context_synchronously
Toast.show(
context,
'${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
AppColor.redColor);
// Get.snackbar('Deleted'.tr,
// '${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
// backgroundColor:
// AppColor.accentColor);
},
icon:
const Icon(Icons.favorite_outlined),
),
],
);
},
),
),
cancel: MyElevatedButton(
title: 'Back'.tr, onPressed: () => Get.back()),
);
},
),
),
));
}
}