Update: 2026-06-21 18:58:05
This commit is contained in:
@@ -338,6 +338,17 @@ class AppLink {
|
||||
static String get getPromptDriverDocumentsEgypt =>
|
||||
"$server/auth/captin/getPromptDriverDocumentsEgypt.php";
|
||||
|
||||
static String get saveDriverDestination => "$ride/location/save_driver_destination.php";
|
||||
|
||||
static String get reverseGeocoding {
|
||||
switch (currentCountry) {
|
||||
case 'Syria': return 'https://map-syria.siromove.com/api/geocoding/reverse';
|
||||
case 'Egypt': return 'https://map-egypt.siromove.com/api/geocoding/reverse';
|
||||
case 'Jordan': return 'https://map-jordan.siromove.com/api/geocoding/reverse';
|
||||
default: return 'https://map-saas.intaleqapp.com/api/geocoding/reverse';
|
||||
}
|
||||
}
|
||||
|
||||
static String get updateApiKey => "$ride/apiKey/update.php";
|
||||
static String get deleteApiKey => "$ride/apiKey/delete.php";
|
||||
static String get checkPhoneNumberISVerfiedDriver =>
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/controller/functions/tts.dart';
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
|
||||
class DestinationController extends GetxController {
|
||||
bool isLoading = false;
|
||||
bool isSelectingDestinationOnMap = false;
|
||||
|
||||
// Active destination details
|
||||
LatLng? activeLatLng;
|
||||
String activeName = "";
|
||||
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
List<dynamic> placesSuggestions = [];
|
||||
Timer? _debounce;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
fetchActiveDestination();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
searchController.dispose();
|
||||
_debounce?.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
// --- 1. Get current active destination from backend ---
|
||||
Future<void> fetchActiveDestination() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: AppLink.saveDriverDestination,
|
||||
payload: {'action': 'get'},
|
||||
);
|
||||
|
||||
if (response != null && response is Map && response['status'] == 'success') {
|
||||
final data = response['message'];
|
||||
if (data != null) {
|
||||
final lat = double.tryParse(data['target_latitude']?.toString() ?? '0') ?? 0.0;
|
||||
final lng = double.tryParse(data['target_longitude']?.toString() ?? '0') ?? 0.0;
|
||||
activeLatLng = LatLng(lat, lng);
|
||||
activeName = data['destination_name']?.toString() ?? "";
|
||||
} else {
|
||||
activeLatLng = null;
|
||||
activeName = "";
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print("[DestinationController] fetchActiveDestination error: $e");
|
||||
} finally {
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// --- 2. Autocomplete search suggestions ---
|
||||
void onSearchChanged(String query) {
|
||||
if (_debounce?.isActive ?? false) _debounce!.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 500), () => getPlacesSuggestions(query));
|
||||
}
|
||||
|
||||
Future<void> getPlacesSuggestions(String query) async {
|
||||
if (query.trim().length < 3) {
|
||||
placesSuggestions = [];
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final url = '${AppLink.mapSaasPlaces}?q=${Uri.encodeComponent(query)}';
|
||||
final response = await CRUD().getMapSaas(link: url);
|
||||
|
||||
if (response != null && response is List) {
|
||||
placesSuggestions = response;
|
||||
} else {
|
||||
placesSuggestions = [];
|
||||
}
|
||||
update();
|
||||
} catch (e) {
|
||||
print("[DestinationController] getPlacesSuggestions error: $e");
|
||||
}
|
||||
}
|
||||
|
||||
// --- 3. Save destination to database ---
|
||||
Future<void> saveDestination(LatLng position, String name) async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: AppLink.saveDriverDestination,
|
||||
payload: {
|
||||
'action': 'set',
|
||||
'destination_lat': position.latitude.toString(),
|
||||
'destination_lng': position.longitude.toString(),
|
||||
'destination_name': name,
|
||||
},
|
||||
);
|
||||
|
||||
if (response != null && response is Map) {
|
||||
if (response['status'] == 'success') {
|
||||
activeLatLng = position;
|
||||
activeName = name;
|
||||
mySnackbarSuccess('Destination set successfully!'.tr);
|
||||
} else {
|
||||
final msg = response['message']?.toString() ?? "";
|
||||
if (msg.contains("الحد الأقصى") || msg.contains("limit")) {
|
||||
mySnackbarWarning('You have reached the daily limit of 2 destination settings.'.tr);
|
||||
} else {
|
||||
mySnackbarWarning('Failed to set destination. Please try again.'.tr);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mySnackbarWarning('Failed to set destination. Please try again.'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
print("[DestinationController] saveDestination error: $e");
|
||||
mySnackbarWarning('Failed to set destination. Please try again.'.tr);
|
||||
} finally {
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// --- 4. Clear/Deactivate destination ---
|
||||
Future<void> clearDestination() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: AppLink.saveDriverDestination,
|
||||
payload: {'action': 'clear'},
|
||||
);
|
||||
|
||||
if (response != null && response is Map && response['status'] == 'success') {
|
||||
activeLatLng = null;
|
||||
activeName = "";
|
||||
mySnackbarSuccess('Destination cleared!'.tr);
|
||||
} else {
|
||||
mySnackbarWarning('Failed to set destination. Please try again.'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
print("[DestinationController] clearDestination error: $e");
|
||||
mySnackbarWarning('Failed to set destination. Please try again.'.tr);
|
||||
} finally {
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// --- 5. Reverse geocoding (for map picker) ---
|
||||
Future<String> reverseGeocode(LatLng location) async {
|
||||
final url = '${AppLink.reverseGeocoding}?lat=${location.latitude}&lng=${location.longitude}';
|
||||
try {
|
||||
final response = await CRUD().getMapSaas(link: url);
|
||||
if (response != null && response is List && response.isNotEmpty) {
|
||||
final data = response[0];
|
||||
return data['name_ar'] ?? data['name'] ?? 'Selected Location'.tr;
|
||||
}
|
||||
return 'Selected Location'.tr;
|
||||
} catch (e) {
|
||||
print("[DestinationController] reverseGeocode error: $e");
|
||||
return 'Selected Location'.tr;
|
||||
}
|
||||
}
|
||||
|
||||
// --- 6. TTS Voice Explanation Helper ---
|
||||
void toggleSpeaker() {
|
||||
final tts = Get.find<TextToSpeechController>();
|
||||
if (tts.isSpeaking) {
|
||||
tts.stop();
|
||||
} else {
|
||||
tts.speakText('Destination Tool Description'.tr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2659,4 +2659,20 @@ final Map<String, String> ar_eg = {
|
||||
"🏆 \\\${'Maximum Level Reached!": "🏆 \\\${'تم الوصول إلى المستوى الأقصى!",
|
||||
"💰 Pay with Wallet": "💰 ادفع عبر المحفظة",
|
||||
"💳 Pay with Credit Card": "💳 ادفع ببطاقة ائتمان",
|
||||
"Set Destination": "تحديد الوجهة",
|
||||
"Personal Destination": "الوجهة الشخصية",
|
||||
"Set your destination to only receive orders heading in that direction.": "حدد وجهتك لتلقي الطلبات المتجهة في نفس المسار فقط.",
|
||||
"Explain Destination Tool": "شرح أداة تحديد الوجهة",
|
||||
"Destination Tool Description": "تتيح لك هذه الأداة تحديد وجهتك الشخصية التي تنوي الذهاب إليها (مثل طريق عودتك للمنزل). بمجرد تفعيلها، سيقوم النظام تلقائياً بفلترة طلبات الركاب وعرض الرحلات المتوافقة مع مسارك فقط.\n\nتنبيه هام:\n1. يمكنك تحديد الوجهة مرتين كحد أقصى يومياً.\n2. يتم مطابقة الرحلات التي تقع وجهتها في طريق مسارك وبفارق بسيط لضمان عدم الخروج عن مسارك.",
|
||||
"Search for area or city...": "ابحث عن منطقة أو مدينة...",
|
||||
"Select on Map": "تحديد من الخريطة",
|
||||
"Confirm Location": "تأكيد الموقع",
|
||||
"Choose Destination": "اختر الوجهة",
|
||||
"Daily Limit Reached": "تم الوصول للحد اليومي",
|
||||
"You have reached the daily limit of 2 destination settings.": "لقد وصلت للحد اليومي الأقصى المسموح به لتحديد الوجهة (مرتان يومياً).",
|
||||
"Destination set successfully!": "تم تحديد الوجهة بنجاح!",
|
||||
"Failed to set destination. Please try again.": "فشل تحديد الوجهة. يرجى المحاولة لاحقاً.",
|
||||
"Clear Destination": "مسح الوجهة",
|
||||
"Destination cleared!": "تم مسح الوجهة الشخصية!",
|
||||
"Move map to select destination": "حرك الخريطة لتحديد الوجهة الشخصية",
|
||||
};
|
||||
|
||||
@@ -2659,4 +2659,20 @@ final Map<String, String> ar_jo = {
|
||||
"🏆 \\\${'Maximum Level Reached!": "🏆 \\\${'تم الوصول إلى المستوى الأقصى!",
|
||||
"💰 Pay with Wallet": "💰 ادفع عبر المحفظة",
|
||||
"💳 Pay with Credit Card": "💳 ادفع ببطاقة ائتمان",
|
||||
"Set Destination": "تحديد الوجهة",
|
||||
"Personal Destination": "الوجهة الشخصية",
|
||||
"Set your destination to only receive orders heading in that direction.": "حدد وجهتك لتلقي الطلبات المتجهة في نفس المسار فقط.",
|
||||
"Explain Destination Tool": "شرح أداة تحديد الوجهة",
|
||||
"Destination Tool Description": "تتيح لك هذه الأداة تحديد وجهتك الشخصية التي تنوي الذهاب إليها (مثل طريق عودتك للمنزل). بمجرد تفعيلها، سيقوم النظام تلقائياً بفلترة طلبات الركاب وعرض الرحلات المتوافقة مع مسارك فقط.\n\nتنبيه هام:\n1. يمكنك تحديد الوجهة مرتين كحد أقصى يومياً.\n2. يتم مطابقة الرحلات التي تقع وجهتها في طريق مسارك وبفارق بسيط لضمان عدم الخروج عن مسارك.",
|
||||
"Search for area or city...": "ابحث عن منطقة أو مدينة...",
|
||||
"Select on Map": "تحديد من الخريطة",
|
||||
"Confirm Location": "تأكيد الموقع",
|
||||
"Choose Destination": "اختر الوجهة",
|
||||
"Daily Limit Reached": "تم الوصول للحد اليومي",
|
||||
"You have reached the daily limit of 2 destination settings.": "لقد وصلت للحد اليومي الأقصى المسموح به لتحديد الوجهة (مرتان يومياً).",
|
||||
"Destination set successfully!": "تم تحديد الوجهة بنجاح!",
|
||||
"Failed to set destination. Please try again.": "فشل تحديد الوجهة. يرجى المحاولة لاحقاً.",
|
||||
"Clear Destination": "مسح الوجهة",
|
||||
"Destination cleared!": "تم مسح الوجهة الشخصية!",
|
||||
"Move map to select destination": "حرك الخريطة لتحديد الوجهة الشخصية",
|
||||
};
|
||||
|
||||
@@ -2062,6 +2062,24 @@ final Map<String, String> ar_sy = {
|
||||
"You have gift 30000 EGP": "عندك هدية 30000 ج.م",
|
||||
"You have gift 30000 JOD": "عندك هدية 30000 د.أ",
|
||||
"You have gift 30000 SYP": "عندك هدية 30000 ل.س",
|
||||
"💰 Pay with Wallet": "💰 ادفع عبر المحفظة",
|
||||
"💳 Pay with Credit Card": "💳 ادفع ببطاقة ائتمان",
|
||||
"Set Destination": "تحديد الوجهة",
|
||||
"Personal Destination": "الوجهة الشخصية",
|
||||
"Set your destination to only receive orders heading in that direction.": "حدد وجهتك لتلقي الطلبات المتجهة في نفس المسار فقط.",
|
||||
"Explain Destination Tool": "شرح أداة تحديد الوجهة",
|
||||
"Destination Tool Description": "تتيح لك هذه الأداة تحديد وجهتك الشخصية التي تنوي الذهاب إليها (مثل طريق عودتك للمنزل). بمجرد تفعيلها، سيقوم النظام تلقائياً بفلترة طلبات الركاب وعرض الرحلات المتوافقة مع مسارك فقط.\n\nتنبيه هام:\n1. يمكنك تحديد الوجهة مرتين كحد أقصى يومياً.\n2. يتم مطابقة الرحلات التي تقع وجهتها في طريق مسارك وبفارق بسيط لضمان عدم الخروج عن مسارك.",
|
||||
"Search for area or city...": "ابحث عن منطقة أو مدينة...",
|
||||
"Select on Map": "تحديد من الخريطة",
|
||||
"Confirm Location": "تأكيد الموقع",
|
||||
"Choose Destination": "اختر الوجهة",
|
||||
"Daily Limit Reached": "تم الوصول للحد اليومي",
|
||||
"You have reached the daily limit of 2 destination settings.": "لقد وصلت للحد اليومي الأقصى المسموح به لتحديد الوجهة (مرتان يومياً).",
|
||||
"Destination set successfully!": "تم تحديد الوجهة بنجاح!",
|
||||
"Failed to set destination. Please try again.": "فشل تحديد الوجهة. يرجى المحاولة لاحقاً.",
|
||||
"Clear Destination": "مسح الوجهة",
|
||||
"Destination cleared!": "تم مسح الوجهة الشخصية!",
|
||||
"Move map to select destination": "حرك الخريطة لتحديد الوجهة الشخصية",
|
||||
"You have got a gift": "وصلتك هدية",
|
||||
"You have got a gift for invitation": "وصلتك هدية للدعوة",
|
||||
"You have in account": "لديك في الحساب",
|
||||
|
||||
@@ -2659,4 +2659,20 @@ final Map<String, String> en = {
|
||||
"🏆 \\\${'Maximum Level Reached!": "🏆 \\\${'Maximum Level Reached!",
|
||||
"💰 Pay with Wallet": "💰 Pay with Wallet",
|
||||
"💳 Pay with Credit Card": "💳 Pay with Credit Card",
|
||||
"Set Destination": "Set Destination",
|
||||
"Personal Destination": "Personal Destination",
|
||||
"Set your destination to only receive orders heading in that direction.": "Set your destination to only receive orders heading in that direction.",
|
||||
"Explain Destination Tool": "Explain Destination Tool",
|
||||
"Destination Tool Description": "This tool allows you to specify a personal destination (e.g. your way home). Once activated, the system filters passenger requests and only displays rides compatible with your route.\n\nImportant Notes:\n1. You can set the destination a maximum of 2 times daily.\n2. Matches are computed based on paths that align with your route to ensure minimal detours.",
|
||||
"Search for area or city...": "Search for area or city...",
|
||||
"Select on Map": "Select on Map",
|
||||
"Confirm Location": "Confirm Location",
|
||||
"Choose Destination": "Choose Destination",
|
||||
"Daily Limit Reached": "Daily Limit Reached",
|
||||
"You have reached the daily limit of 2 destination settings.": "You have reached the daily limit of 2 destination settings.",
|
||||
"Destination set successfully!": "Destination set successfully!",
|
||||
"Failed to set destination. Please try again.": "Failed to set destination. Please try again.",
|
||||
"Clear Destination": "Clear Destination",
|
||||
"Destination cleared!": "Destination cleared!",
|
||||
"Move map to select destination": "Move map to select destination",
|
||||
};
|
||||
|
||||
@@ -26,6 +26,8 @@ import '../../../notification/available_rides_page.dart';
|
||||
import '../driver_map_page.dart';
|
||||
import 'widget/connect.dart';
|
||||
import 'widget/left_menu_map_captain.dart';
|
||||
import 'widget/destination_bottom_sheet.dart';
|
||||
import '../../../../controller/home/captin/destination_controller.dart';
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// Design Tokens (Responsive to Theme)
|
||||
@@ -99,13 +101,82 @@ class HomeCaptain extends StatelessWidget {
|
||||
drawer: AppDrawer(),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: Stack(
|
||||
children: [
|
||||
const _MapView(),
|
||||
leftMainMenuCaptainIcons(),
|
||||
const _BottomStatusBar(),
|
||||
const _FloatingControls(),
|
||||
],
|
||||
child: GetBuilder<DestinationController>(
|
||||
init: Get.put(DestinationController()),
|
||||
builder: (destCtrl) {
|
||||
return Stack(
|
||||
children: [
|
||||
const _MapView(),
|
||||
leftMainMenuCaptainIcons(),
|
||||
if (!destCtrl.isSelectingDestinationOnMap) ...[
|
||||
const _BottomStatusBar(),
|
||||
const _FloatingControls(),
|
||||
] else ...[
|
||||
const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 24),
|
||||
child: Icon(Icons.pin_drop_rounded, size: 48, color: Colors.red),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 20,
|
||||
left: 20,
|
||||
right: 20,
|
||||
child: Card(
|
||||
color: _Token.surfaceCard(context),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
elevation: 10,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Move map to select destination'.tr,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
destCtrl.isSelectingDestinationOnMap = false;
|
||||
destCtrl.update();
|
||||
},
|
||||
child: Text('Cancel'.tr, style: const TextStyle(color: Colors.grey)),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.primaryColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
onPressed: () async {
|
||||
final pickerPos = homeCaptainController.mapHomeCaptainController?.cameraPosition?.target;
|
||||
if (pickerPos != null) {
|
||||
destCtrl.isSelectingDestinationOnMap = false;
|
||||
destCtrl.update();
|
||||
final name = await destCtrl.reverseGeocode(pickerPos);
|
||||
destCtrl.saveDestination(pickerPos, name);
|
||||
}
|
||||
},
|
||||
child: Text('Confirm Location'.tr, style: const TextStyle(color: Colors.white)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -602,6 +673,21 @@ class _FloatingControls extends StatelessWidget {
|
||||
color: AppColor.primaryColor,
|
||||
tooltip: 'Available Rides'.tr,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// Set Destination
|
||||
_Fab(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.transparent,
|
||||
isScrollControlled: true,
|
||||
builder: (_) => const DestinationBottomSheet(),
|
||||
);
|
||||
},
|
||||
icon: Icons.flag_rounded,
|
||||
color: Colors.amber[800],
|
||||
tooltip: 'Set Destination'.tr,
|
||||
),
|
||||
// Continue active ride
|
||||
if (box.read(BoxName.rideStatus) == 'Applied' ||
|
||||
box.read(BoxName.rideStatus) == 'Apply' ||
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.3.5+2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
|
||||
Reference in New Issue
Block a user