Update: 2026-06-21 18:58:05

This commit is contained in:
Hamza-Ayed
2026-06-21 18:58:13 +03:00
parent b492b5076b
commit e73be65a72
8755 changed files with 92977 additions and 99 deletions

View File

@@ -0,0 +1,241 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import 'package:siro_driver/constant/colors.dart';
import 'package:siro_driver/controller/home/captin/destination_controller.dart';
import 'package:siro_driver/controller/functions/tts.dart';
class DestinationBottomSheet extends StatelessWidget {
const DestinationBottomSheet({super.key});
@override
Widget build(BuildContext context) {
Get.put(DestinationController());
return Container(
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF16213E)
: const Color(0xFFF8F9FA),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
),
padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
child: GetBuilder<DestinationController>(
builder: (c) {
if (c.isLoading) {
return const SizedBox(
height: 200,
child: Center(
child: CircularProgressIndicator(color: AppColor.primaryColor),
),
);
}
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Drag handle
Center(
child: Container(
width: 36,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.3),
borderRadius: BorderRadius.circular(2),
),
),
),
const SizedBox(height: 16),
// Header & Speaker
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Personal Destination'.tr,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
GetBuilder<TextToSpeechController>(
init: Get.find<TextToSpeechController>(),
builder: (tts) => IconButton(
icon: Icon(
tts.isSpeaking ? Icons.volume_up_rounded : Icons.volume_mute_rounded,
color: AppColor.primaryColor,
size: 26,
),
onPressed: c.toggleSpeaker,
tooltip: 'Listen to description'.tr,
),
),
],
),
const SizedBox(height: 12),
// Description Box (Smart container with soft color)
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColor.primaryColor.withOpacity(0.08),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: AppColor.primaryColor.withOpacity(0.2),
),
),
child: Text(
'Destination Tool Description'.tr,
style: const TextStyle(
fontSize: 12,
height: 1.4,
),
),
),
const SizedBox(height: 16),
// Active Destination Card (If set)
if (c.activeLatLng != null) ...[
Card(
elevation: 0,
color: Colors.green.withOpacity(0.1),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: Colors.green.withOpacity(0.3)),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
child: Row(
children: [
const Icon(Icons.check_circle_rounded, color: Colors.green, size: 22),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
c.activeName,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
'${c.activeLatLng!.latitude.toStringAsFixed(5)}, ${c.activeLatLng!.longitude.toStringAsFixed(5)}',
style: const TextStyle(
fontSize: 11,
color: Colors.grey,
),
),
],
),
),
TextButton(
onPressed: c.clearDestination,
child: Text(
'Clear Destination'.tr,
style: const TextStyle(color: Colors.red),
),
),
],
),
),
),
const SizedBox(height: 16),
],
// Autocomplete Place Search Field
TextField(
controller: c.searchController,
onChanged: c.onSearchChanged,
decoration: InputDecoration(
hintText: 'Search for area or city...'.tr,
prefixIcon: const Icon(Icons.search_rounded),
filled: true,
fillColor: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF202B4B)
: Colors.grey.withOpacity(0.1),
contentPadding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide.none,
),
),
),
// Suggestions List
if (c.placesSuggestions.isNotEmpty) ...[
const SizedBox(height: 8),
Container(
constraints: const BoxConstraints(maxHeight: 180),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF1E2746)
: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(color: Colors.grey.withOpacity(0.2)),
),
child: ListView.separated(
shrinkWrap: true,
itemCount: c.placesSuggestions.length,
separatorBuilder: (_, __) => const Divider(height: 1),
itemBuilder: (context, index) {
final place = c.placesSuggestions[index];
return ListTile(
leading: const Icon(Icons.place_rounded, color: Colors.grey),
title: Text(
place['name'] ?? "",
style: const TextStyle(fontSize: 13),
),
subtitle: Text(
place['description'] ?? "",
style: const TextStyle(fontSize: 11, color: Colors.grey),
),
onTap: () {
FocusScope.of(context).unfocus();
Get.back(); // Close sheet
final lat = double.tryParse(place['latitude']?.toString() ?? '0') ?? 0.0;
final lng = double.tryParse(place['longitude']?.toString() ?? '0') ?? 0.0;
c.saveDestination(LatLng(lat, lng), place['name'] ?? 'Destination');
},
);
},
),
),
],
const SizedBox(height: 16),
// Select on Map Button
ElevatedButton.icon(
onPressed: () {
Get.back(); // Close sheet
c.isSelectingDestinationOnMap = true;
c.update();
},
icon: const Icon(Icons.map_rounded),
label: Text('Select on Map'.tr),
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primaryColor,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
padding: const EdgeInsets.symmetric(vertical: 14),
),
),
],
),
);
},
),
);
}
}