2026-03-10-1
This commit is contained in:
@@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:sefer_admin1/constant/links.dart';
|
||||
// Keep your specific imports
|
||||
import 'package:sefer_admin1/controller/functions/crud.dart';
|
||||
import 'package:sefer_admin1/print.dart';
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// 1. DATA MODELS
|
||||
@@ -43,8 +43,7 @@ class DriverLocation {
|
||||
|
||||
class RideMonitorController extends GetxController {
|
||||
// CONFIGURATION
|
||||
final String apiUrl =
|
||||
"https://api.intaleq.xyz/intaleq/Admin/rides/monitorRide.php";
|
||||
final String apiUrl = "${AppLink.server}/Admin/rides/monitorRide.php";
|
||||
|
||||
// INPUT CONTROLLERS
|
||||
final TextEditingController phoneInputController = TextEditingController();
|
||||
@@ -81,7 +80,15 @@ class RideMonitorController extends GetxController {
|
||||
|
||||
void startSearch() {
|
||||
if (phoneInputController.text.trim().isEmpty) {
|
||||
Get.snackbar("Error", "Please enter a phone number");
|
||||
Get.snackbar(
|
||||
"تنبيه",
|
||||
"يرجى إدخال رقم الهاتف أولاً",
|
||||
backgroundColor: Colors.redAccent.withOpacity(0.9),
|
||||
colorText: Colors.white,
|
||||
snackPosition: SnackPosition.TOP,
|
||||
margin: const EdgeInsets.all(15),
|
||||
borderRadius: 15,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,8 +99,8 @@ class RideMonitorController extends GetxController {
|
||||
startPoint.value = null;
|
||||
endPoint.value = null;
|
||||
routePolyline.clear();
|
||||
driverName.value = "Loading...";
|
||||
rideStatus.value = "Loading...";
|
||||
driverName.value = "جاري التحميل...";
|
||||
rideStatus.value = "جاري التحميل...";
|
||||
_isFirstLoad = true;
|
||||
|
||||
// Switch UI
|
||||
@@ -114,7 +121,7 @@ class RideMonitorController extends GetxController {
|
||||
_timer?.cancel();
|
||||
isTracking.value = false;
|
||||
isLoading.value = false;
|
||||
phoneInputController.clear();
|
||||
// phoneInputController.clear(); // اختياري: يمكنك إبقائه لتسهيل البحث مرة أخرى
|
||||
}
|
||||
|
||||
Future<void> fetchRideData() async {
|
||||
@@ -124,11 +131,9 @@ class RideMonitorController extends GetxController {
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link: apiUrl,
|
||||
payload: {"phone": phone},
|
||||
payload: {"phone": "963$phone"},
|
||||
);
|
||||
|
||||
// Log.print('response: ${response}');
|
||||
|
||||
if (response != 'failure') {
|
||||
final jsonResponse = response;
|
||||
|
||||
@@ -140,12 +145,13 @@ class RideMonitorController extends GetxController {
|
||||
|
||||
// 1. Parse Driver Info
|
||||
if (data['driver_details'] != null) {
|
||||
driverName.value = data['driver_details']['fullname'] ?? "Unknown";
|
||||
driverName.value =
|
||||
data['driver_details']['fullname'] ?? "سائق غير معروف";
|
||||
}
|
||||
|
||||
// 2. Parse Ride Info & Route
|
||||
if (data['ride_details'] != null) {
|
||||
rideStatus.value = data['ride_details']['status'] ?? "Unknown";
|
||||
rideStatus.value = data['ride_details']['status'] ?? "غير معروف";
|
||||
|
||||
// Parse Start/End Locations (Format: "lat,lng")
|
||||
String? startStr = data['ride_details']['start_location'];
|
||||
@@ -174,21 +180,19 @@ class RideMonitorController extends GetxController {
|
||||
if (startPoint.value != null && endPoint.value != null) {
|
||||
_updateMapBounds();
|
||||
}
|
||||
print("No live location coordinates.");
|
||||
}
|
||||
|
||||
hasError.value = false;
|
||||
} else {
|
||||
hasError.value = true;
|
||||
errorMessage.value = jsonResponse['message'] ??
|
||||
"Phone number not found or no active ride.";
|
||||
"لم يتم العثور على رقم الهاتف أو لا توجد رحلة نشطة.";
|
||||
}
|
||||
} else {
|
||||
hasError.value = true;
|
||||
errorMessage.value = "Connection Failed";
|
||||
errorMessage.value = "فشل الاتصال بالخادم";
|
||||
}
|
||||
} catch (e) {
|
||||
print("Polling Error: $e");
|
||||
if (isLoading.value) {
|
||||
hasError.value = true;
|
||||
errorMessage.value = e.toString();
|
||||
@@ -207,14 +211,12 @@ class RideMonitorController extends GetxController {
|
||||
final lng = double.parse(parts[1].trim());
|
||||
return LatLng(lat, lng);
|
||||
} catch (e) {
|
||||
print("Error parsing location string '$str': $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Logic to fit start, end, and driver on screen
|
||||
void _updateMapBounds() {
|
||||
// Only auto-fit on the first successful load to avoid fighting user pan/zoom
|
||||
if (!_isFirstLoad) return;
|
||||
|
||||
List<LatLng> pointsToFit = [];
|
||||
@@ -232,106 +234,184 @@ class RideMonitorController extends GetxController {
|
||||
mapController.fitCamera(
|
||||
CameraFit.bounds(
|
||||
bounds: bounds,
|
||||
padding:
|
||||
const EdgeInsets.all(80.0), // Padding so markers aren't on edge
|
||||
padding: const EdgeInsets.all(80.0),
|
||||
),
|
||||
);
|
||||
_isFirstLoad = false; // Disable auto-fit after initial success
|
||||
_isFirstLoad = false;
|
||||
} catch (e) {
|
||||
print("Map Controller not ready yet: $e");
|
||||
// Map Controller not ready yet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// 3. UI SCREEN
|
||||
/// 3. UI SCREEN (Modern Light Theme)
|
||||
/// --------------------------------------------------------------------------
|
||||
|
||||
class RideMonitorScreen extends StatelessWidget {
|
||||
const RideMonitorScreen({super.key});
|
||||
|
||||
// 🎨 الألوان العصرية (Modern Palette)
|
||||
final Color backgroundColor = const Color(0xFFF4F7FE);
|
||||
final Color primaryColor = const Color(0xFF4318FF);
|
||||
final Color textPrimary = const Color(0xFF2B3674);
|
||||
final Color textSecondary = const Color(0xFFA3AED0);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final RideMonitorController controller = Get.put(RideMonitorController());
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Admin Ride Monitor"),
|
||||
backgroundColor: Colors.blueAccent,
|
||||
foregroundColor: Colors.white,
|
||||
actions: [
|
||||
Obx(() => controller.isTracking.value
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: controller.stopTracking,
|
||||
tooltip: "Stop Tracking",
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
],
|
||||
backgroundColor: backgroundColor,
|
||||
// الإبقاء على AppBar فقط في شاشة البحث
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||
child: Obx(() {
|
||||
if (controller.isTracking.value)
|
||||
return const SizedBox
|
||||
.shrink(); // إخفاء الـ AppBar في وضع التتبع للخريطة الكاملة
|
||||
return AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
iconTheme: IconThemeData(color: textPrimary),
|
||||
title: Text(
|
||||
"مراقبة الرحلات",
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
body: Obx(() {
|
||||
if (!controller.isTracking.value) {
|
||||
return _buildSearchForm(context, controller);
|
||||
}
|
||||
return _buildMapTrackingView(controller);
|
||||
return _buildMapTrackingView(context, controller);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// واجهة البحث (Search View)
|
||||
// ---------------------------------------------------------------------------
|
||||
Widget _buildSearchForm(
|
||||
BuildContext context, RideMonitorController controller) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.map_outlined, size: 80, color: Colors.blueAccent),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"Track Active Ride",
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: primaryColor.withOpacity(0.08),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 10),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
"Enter Driver or Passenger Phone Number",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextField(
|
||||
controller: controller.phoneInputController,
|
||||
keyboardType: TextInputType.phone,
|
||||
decoration: InputDecoration(
|
||||
labelText: "Phone Number",
|
||||
hintText: "e.g. 9639...",
|
||||
border:
|
||||
OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.startSearch,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blueAccent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child:
|
||||
Icon(Icons.radar_rounded, size: 60, color: primaryColor),
|
||||
),
|
||||
child: const Text("Start Monitoring",
|
||||
style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
"تتبع رحلة نشطة",
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"أدخل رقم هاتف السائق أو الراكب للبدء",
|
||||
style: TextStyle(
|
||||
color: textSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller.phoneInputController,
|
||||
keyboardType: TextInputType.phone,
|
||||
textDirection: TextDirection.ltr,
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: "مثال: 0992952235...",
|
||||
hintStyle: TextStyle(color: textSecondary),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 18, horizontal: 20),
|
||||
prefixIcon:
|
||||
Icon(Icons.phone_rounded, color: primaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.startSearch,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: primaryColor,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"بدء المراقبة",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMapTrackingView(RideMonitorController controller) {
|
||||
// ---------------------------------------------------------------------------
|
||||
// واجهة الخريطة (Map View)
|
||||
// ---------------------------------------------------------------------------
|
||||
Widget _buildMapTrackingView(
|
||||
BuildContext context, RideMonitorController controller) {
|
||||
return Stack(
|
||||
children: [
|
||||
FlutterMap(
|
||||
@@ -352,10 +432,12 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: controller.routePolyline.value,
|
||||
strokeWidth: 5.0,
|
||||
color: Colors.blueAccent.withOpacity(0.8),
|
||||
strokeWidth: 6.0,
|
||||
color: primaryColor.withOpacity(0.9),
|
||||
borderStrokeWidth: 2.0,
|
||||
borderColor: Colors.blue[900]!,
|
||||
borderColor: primaryColor.withOpacity(0.3),
|
||||
strokeCap: StrokeCap.round,
|
||||
strokeJoin: StrokeJoin.round,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -363,25 +445,22 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
// 2. START & END MARKERS
|
||||
MarkerLayer(
|
||||
markers: [
|
||||
// Start Point (Green Flag)
|
||||
// Start Point (Green Dot)
|
||||
if (controller.startPoint.value != null)
|
||||
Marker(
|
||||
point: controller.startPoint.value!,
|
||||
width: 40,
|
||||
height: 40,
|
||||
child:
|
||||
const Icon(Icons.flag, color: Colors.green, size: 40),
|
||||
alignment: Alignment.topCenter,
|
||||
width: 30,
|
||||
height: 30,
|
||||
child: _buildPointMarker(const Color(0xFF10B981)),
|
||||
),
|
||||
|
||||
// End Point (Red Flag)
|
||||
// End Point (Red Dot)
|
||||
if (controller.endPoint.value != null)
|
||||
Marker(
|
||||
point: controller.endPoint.value!,
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: const Icon(Icons.flag, color: Colors.red, size: 40),
|
||||
alignment: Alignment.topCenter,
|
||||
width: 30,
|
||||
height: 30,
|
||||
child: _buildPointMarker(const Color(0xFFEF4444)),
|
||||
),
|
||||
|
||||
// Driver Car Marker
|
||||
@@ -391,30 +470,49 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
controller.driverLocation.value!.latitude,
|
||||
controller.driverLocation.value!.longitude,
|
||||
),
|
||||
width: 60,
|
||||
height: 60,
|
||||
width: 80,
|
||||
height: 80,
|
||||
child: Transform.rotate(
|
||||
angle: (controller.driverLocation.value!.heading *
|
||||
(3.14159 / 180)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.directions_car_filled,
|
||||
color: Colors
|
||||
.black, // Dark car for visibility on blue line
|
||||
size: 35,
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 10,
|
||||
spreadRadius: 2,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
Icons.directions_car_rounded,
|
||||
color: primaryColor,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4, vertical: 1),
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: textPrimary,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
"${controller.driverLocation.value!.speed.toInt()} km",
|
||||
"${controller.driverLocation.value!.speed.toInt()} كم",
|
||||
style: const TextStyle(
|
||||
fontSize: 10, fontWeight: FontWeight.bold),
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textDirection: TextDirection.rtl,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -426,88 +524,196 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
|
||||
// LOADING OVERLAY
|
||||
// زر التراجع (إيقاف التتبع) أعلى الشاشة
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).padding.top + 10,
|
||||
right: 20, // أو left حسب لغة التطبيق
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.close_rounded, color: textPrimary, size: 24),
|
||||
onPressed: controller.stopTracking,
|
||||
tooltip: "إيقاف المراقبة",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// LOADING OVERLAY (Smooth Frosted Glass like)
|
||||
if (controller.isLoading.value &&
|
||||
controller.driverLocation.value == null &&
|
||||
controller.startPoint.value == null)
|
||||
Container(
|
||||
color: Colors.black45,
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(color: Colors.white)),
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
color: primaryColor, strokeWidth: 3),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"جاري تحديد الموقع...",
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ERROR OVERLAY
|
||||
if (controller.hasError.value)
|
||||
Center(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.all(20),
|
||||
margin: const EdgeInsets.all(24),
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: const [
|
||||
BoxShadow(blurRadius: 10, color: Colors.black26)
|
||||
]),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.red, size: 40),
|
||||
const SizedBox(height: 10),
|
||||
Text(controller.errorMessage.value,
|
||||
textAlign: TextAlign.center),
|
||||
const SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.error_outline_rounded,
|
||||
color: Colors.red, size: 40),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"حدث خطأ",
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
controller.errorMessage.value,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: textSecondary, height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: controller.stopTracking,
|
||||
child: const Text("Back"))
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: textPrimary,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
),
|
||||
child: const Text("رجوع للبحث",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// INFO CARD
|
||||
// INFO CARD (Bottom Floating Card)
|
||||
if (!controller.hasError.value && !controller.isLoading.value)
|
||||
Positioned(
|
||||
bottom: 20,
|
||||
bottom: 30,
|
||||
left: 20,
|
||||
right: 20,
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 10),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const CircleAvatar(
|
||||
backgroundColor: Colors.blueAccent,
|
||||
child: Icon(Icons.person, color: Colors.white),
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Icon(Icons.person_rounded,
|
||||
color: primaryColor, size: 28),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
controller.driverName.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.circle,
|
||||
size: 10,
|
||||
color:
|
||||
controller.rideStatus.value == 'Begin'
|
||||
? Colors.green
|
||||
: Colors.grey),
|
||||
const SizedBox(width: 5),
|
||||
Text(controller.rideStatus.value,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600)),
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: controller.rideStatus.value
|
||||
.toLowerCase() ==
|
||||
'begin'
|
||||
? const Color(0xFF10B981)
|
||||
: const Color(0xFFF59E0B),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
controller.rideStatus.value,
|
||||
style: TextStyle(
|
||||
color: textSecondary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -515,25 +721,53 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Divider(height: 1, thickness: 1),
|
||||
),
|
||||
if (controller.driverLocation.value != null)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildInfoBadge(Icons.speed,
|
||||
"${controller.driverLocation.value!.speed.toStringAsFixed(1)} km/h"),
|
||||
_buildInfoBadge(
|
||||
Icons.access_time,
|
||||
controller.driverLocation.value!.updatedAt
|
||||
.split(' ')
|
||||
.last),
|
||||
_buildModernInfoBadge(
|
||||
Icons.speed_rounded,
|
||||
"${controller.driverLocation.value!.speed.toStringAsFixed(1)} كم/س",
|
||||
const Color(0xFF3B82F6),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 30,
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
_buildModernInfoBadge(
|
||||
Icons.access_time_rounded,
|
||||
controller.driverLocation.value!.updatedAt
|
||||
.split(' ')
|
||||
.last,
|
||||
const Color(0xFF8B5CF6),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
const Text("Connecting to driver...",
|
||||
style: TextStyle(
|
||||
color: Colors.orange,
|
||||
fontStyle: FontStyle.italic)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
color: primaryColor, strokeWidth: 2),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
"جاري الاتصال بالسائق...",
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -543,14 +777,56 @@ class RideMonitorScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoBadge(IconData icon, String text) {
|
||||
// --- Helper Widgets ---
|
||||
|
||||
Widget _buildPointMarker(Color color) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: color.withOpacity(0.5),
|
||||
blurRadius: 6,
|
||||
spreadRadius: 1,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildModernInfoBadge(IconData icon, String text, Color iconColor) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 16, color: Colors.grey[600]),
|
||||
const SizedBox(width: 4),
|
||||
Text(text,
|
||||
style: TextStyle(
|
||||
color: Colors.grey[800], fontWeight: FontWeight.bold)),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: iconColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, size: 16, color: iconColor),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: textPrimary,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textDirection: TextDirection.ltr, // للحفاظ على اتجاه الأرقام
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user