Fixes & Updates - 2026-06-01: Integrate Back-End v3 updates, fix call/connection issues across apps

This commit is contained in:
Hamza-Ayed
2026-06-01 23:35:29 +03:00
parent 8f555691b9
commit cbf693c804
56 changed files with 6091 additions and 1217 deletions

View File

@@ -307,7 +307,7 @@ class _PhoneNumberScreenState extends State<PhoneNumberScreen> {
Log.print('📱 _submit rawPhone: "$rawPhone" (from _completePhone: "$_completePhone")');
final success = await PhoneAuthHelper.sendOtp(rawPhone);
if (success && mounted) {
await PhoneAuthHelper.verifyOtp(rawPhone);
Get.to(() => OtpVerificationScreen(phoneNumber: rawPhone));
}
if (mounted) setState(() => _isLoading = false);
}
@@ -416,7 +416,7 @@ class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
void _submit() async {
if (_formKey.currentState!.validate()) {
setState(() => _isLoading = true);
await PhoneAuthHelper.verifyOtp(widget.phoneNumber);
await PhoneAuthHelper.verifyOtp(widget.phoneNumber, _otpController.text.trim());
if (mounted) setState(() => _isLoading = false);
}
}
@@ -431,7 +431,7 @@ class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'Enter the 5-digit code',
'Enter the 3-digit code',
style: TextStyle(color: Colors.black87, fontSize: 16),
textAlign: TextAlign.center,
),
@@ -442,7 +442,7 @@ class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
controller: _otpController,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 5,
maxLength: 3,
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
@@ -451,7 +451,7 @@ class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
),
decoration: InputDecoration(
counterText: "",
hintText: '-----',
hintText: '---',
hintStyle: TextStyle(
color: Colors.black.withOpacity(0.2),
letterSpacing: 18,
@@ -459,7 +459,7 @@ class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(vertical: 10),
),
validator: (v) => v == null || v.length < 5 ? '' : null,
validator: (v) => v == null || v.length < 3 ? '' : null,
),
),
const SizedBox(height: 30),

View File

@@ -23,9 +23,9 @@ class OtpVerificationPage extends StatefulWidget {
class _OtpVerificationPageState extends State<OtpVerificationPage> {
late final OtpVerificationController controller;
final List<FocusNode> _focusNodes = List.generate(6, (index) => FocusNode());
final List<FocusNode> _focusNodes = List.generate(3, (index) => FocusNode());
final List<TextEditingController> _textControllers =
List.generate(6, (index) => TextEditingController());
List.generate(3, (index) => TextEditingController());
@override
void initState() {
@@ -50,7 +50,7 @@ class _OtpVerificationPageState extends State<OtpVerificationPage> {
void _onOtpChanged(String value, int index) {
if (value.isNotEmpty) {
if (index < 5) {
if (index < 2) {
_focusNodes[index + 1].requestFocus();
} else {
_focusNodes[index].unfocus(); // إلغاء التركيز بعد آخر حقل
@@ -67,7 +67,7 @@ class _OtpVerificationPageState extends State<OtpVerificationPage> {
textDirection: TextDirection.ltr, // لضمان ترتيب الحقول من اليسار لليمين
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(5, (index) {
children: List.generate(3, (index) {
return SizedBox(
width: 45,
height: 55,

View File

@@ -48,10 +48,11 @@ class PassengerLocationMapPage extends StatelessWidget {
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (Get.arguments != null && Get.arguments is Map<String, dynamic>) {
// 🔥 [Fix] argumentLoading ضرورية هنا للعودة للرحلة من صفحة الهوم
// (عند العودة لا يُستدعى onInit() لأن الكنترولر موجود مسبقاً)
// الحماية من التكرار موجودة داخل argumentLoading بواسطة _isRouteRequested flag
mapDriverController.argumentLoading();
mapDriverController.startTimerToShowPassengerInfoWindowFromDriver();
// 2. فرض التحديث لكل المعرفات (IDs) لضمان ظهورها
// لأن argumentLoading قد تستدعي update() العادية التي لا تؤثر على هؤلاء
mapDriverController
.update(['PassengerInfo', 'DriverEndBar', 'SosConnect']);
}
@@ -152,7 +153,6 @@ class InstructionsOfRoads extends StatelessWidget {
if (controller.currentInstruction.isEmpty) return const SizedBox();
return TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 500),
builder: (context, value, child) {
@@ -165,7 +165,8 @@ class InstructionsOfRoads extends StatelessWidget {
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: theme.cardColor.withOpacity(0.95), // Adaptive background
color: theme.cardColor
.withOpacity(0.95), // Adaptive background
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
@@ -173,7 +174,8 @@ class InstructionsOfRoads extends StatelessWidget {
blurRadius: 15,
offset: const Offset(0, 5)),
],
border: Border.all(color: theme.dividerColor.withOpacity(0.1)),
border: Border.all(
color: theme.dividerColor.withOpacity(0.1)),
),
child: Row(
children: [
@@ -193,7 +195,7 @@ class InstructionsOfRoads extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Text(
"${"NEXT STEP".tr} (${controller.distanceToNextStep})",
style: theme.textTheme.labelSmall?.copyWith(
color: theme.hintColor,
@@ -204,8 +206,7 @@ class InstructionsOfRoads extends StatelessWidget {
Text(
controller.currentInstruction,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
height: 1.2),
fontWeight: FontWeight.w600, height: 1.2),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
@@ -213,7 +214,6 @@ class InstructionsOfRoads extends StatelessWidget {
),
),
// فاصل عمودي
Container(
width: 1,
@@ -279,10 +279,11 @@ class CancelWidget extends StatelessWidget {
color: Theme.of(context).cardColor.withOpacity(0.9),
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(color: Theme.of(context).shadowColor.withOpacity(0.1), blurRadius: 8)
BoxShadow(
color: Theme.of(context).shadowColor.withOpacity(0.1),
blurRadius: 8)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
@@ -388,7 +389,6 @@ class PricesWindow extends StatelessWidget {
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -416,7 +416,6 @@ class PricesWindow extends StatelessWidget {
fontWeight: FontWeight.w900,
),
),
const SizedBox(height: 30),
SizedBox(
width: double.infinity,

View File

@@ -75,7 +75,7 @@ class HomeCaptain extends StatelessWidget {
final LocationController locationController =
Get.put(LocationController(), permanent: true);
final HomeCaptainController homeCaptainController =
Get.put(HomeCaptainController());
Get.put(HomeCaptainController(), permanent: true);
@override
Widget build(BuildContext context) {

View File

@@ -23,49 +23,59 @@ class GoogleDriverMap extends StatelessWidget {
final double mapPaddingBottom = MediaQuery.of(context).size.height * 0.3;
return GetBuilder<MapDriverController>(
builder: (controller) => IntaleqMap(
apiKey: AK.mapAPIKEY,
onMapCreated: (mapController) {
controller.onMapCreated(mapController);
},
mapType: Get.isRegistered<SettingController>()
? (Get.find<SettingController>().isMapDarkMode
? IntaleqMapType.normal
: IntaleqMapType.light)
: IntaleqMapType.light,
zoomControlsEnabled: false,
initialCameraPosition: CameraPosition(
target: locationController.myLocation,
zoom: 17,
bearing: locationController.heading,
tilt: 60,
builder: (controller) => Listener(
onPointerDown: (_) => controller.onUserMapInteraction(),
child: IntaleqMap(
apiKey: AK.mapAPIKEY,
onMapCreated: (mapController) {
controller.onMapCreated(mapController);
},
mapType: Get.isRegistered<SettingController>()
? (Get.find<SettingController>().isMapDarkMode
? IntaleqMapType.normal
: IntaleqMapType.light)
: IntaleqMapType.light,
zoomControlsEnabled: false,
initialCameraPosition: CameraPosition(
target: controller.smoothedLocation ?? locationController.myLocation,
zoom: 17,
bearing: controller.smoothedHeading,
tilt: 60,
),
// padding: EdgeInsets.only(bottom: 50, top: Get.height * 0.7),
// minMaxZoomPreference: const MinMaxZoomPreference(8, 18),
myLocationEnabled: false,
myLocationButtonEnabled: false,
compassEnabled: false,
polylines: controller.polyLines.toSet(),
markers: {
// 🔥 Car icon — always visible, moves with GPS location on map.
// MarkerId matches exactly with updateMarker() in controller.
Marker(
markerId: const MarkerId('MyLocation'),
position: controller.smoothedLocation ?? controller.myLocation,
rotation: controller.smoothedHeading,
flat: true,
anchor: const Offset(0.5, 0.5),
icon: controller.carIcon,
zIndex: 100,
),
if (!controller.isRideStarted &&
controller.latLngPassengerLocation.latitude != 0)
Marker(
markerId: const MarkerId('start'),
position: controller.latLngPassengerLocation,
icon: controller.startIcon,
),
if (controller.latLngPassengerDestination.latitude != 0 ||
controller.latLngPassengerDestination.longitude != 0)
Marker(
markerId: const MarkerId('end'),
position: controller.latLngPassengerDestination,
icon: controller.endIcon,
),
},
),
// padding: EdgeInsets.only(bottom: 50, top: Get.height * 0.7),
// minMaxZoomPreference: const MinMaxZoomPreference(8, 18),
myLocationEnabled: false,
myLocationButtonEnabled: true,
compassEnabled: true,
polylines: controller.polyLines.toSet(),
markers: {
Marker(
markerId: MarkerId('MyLocation'.tr),
position: controller.smoothedLocation ?? locationController.myLocation,
rotation: controller.smoothedHeading,
flat: true,
anchor: const Offset(0.5, 0.5),
icon: controller.carIcon,
),
Marker(
markerId: MarkerId('start'.tr),
position: controller.latLngPassengerLocation,
icon: controller.startIcon,
),
Marker(
markerId: MarkerId('end'.tr),
position: controller.latLngPassengerDestination,
icon: controller.endIcon,
),
},
),
);
}

View File

@@ -2,11 +2,19 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_driver/constant/colors.dart';
import 'package:sefer_driver/controller/home/captin/map_driver_controller.dart';
import '../../../../constant/box_name.dart';
import '../../../../constant/style.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import '../../../../controller/voice_call_controller.dart';
import '../../../../controller/functions/launch.dart';
import '../../../../controller/functions/location_controller.dart';
import '../../../../main.dart';
import '../../../widgets/error_snakbar.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import '../../../../controller/firebase/notification_service.dart';
import '../../../../controller/functions/crud.dart';
import '../../../../constant/links.dart';
import '../../../widgets/my_textField.dart';
class PassengerInfoWindow extends StatelessWidget {
const PassengerInfoWindow({super.key});
@@ -132,12 +140,19 @@ class PassengerInfoWindow extends StatelessWidget {
Icon(Icons.location_on,
size: 14, color: Colors.grey[600]),
const SizedBox(width: 4),
Text(
'${controller.distance} km',
style: TextStyle(
color: Colors.grey[700],
fontSize: 13,
fontWeight: FontWeight.w600),
// 🔥 [Fix Overflow] Flexible لمنع الـ overflow + تحويل المسافة
// السيرفر يُرجع المسافة بالأمتار (5864.022)
Flexible(
child: Text(
_formatDistanceDisplay(
controller.distance),
style: TextStyle(
color: Colors.grey[700],
fontSize: 13,
fontWeight: FontWeight.w600),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
const SizedBox(width: 10),
Icon(Icons.access_time_filled,
@@ -172,8 +187,8 @@ class PassengerInfoWindow extends StatelessWidget {
await controller.driverCallPassenger();
if (canCall) {
makePhoneCall(
controller.passengerPhone.toString());
_showCallSelectionDialog(
context, controller);
} else {
// هنا ممكن تظهر رسالة: تم منع الاتصال بسبب كثرة الإلغاءات
mySnackeBarError(
@@ -194,6 +209,26 @@ class PassengerInfoWindow extends StatelessWidget {
color: Colors.green, size: 22),
),
),
const SizedBox(width: 8),
InkWell(
onTap: () =>
_showMessageOptions(context, controller),
borderRadius: BorderRadius.circular(50),
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey.shade100,
shape: BoxShape.circle,
border:
Border.all(color: Colors.grey.shade300),
),
child: Icon(
MaterialCommunityIcons
.message_text_outline,
color: AppColor.primaryColor,
size: 22),
),
),
],
),
],
@@ -372,13 +407,40 @@ class PassengerInfoWindow extends StatelessWidget {
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
onPressed: () {
MyDialog().getDialog(
"Start Trip?".tr,
"Ensure the passenger is in the car.".tr,
() async {
await controller.startRideFromDriver();
Get.back();
},
// 🔥 [Fix Start-Ride] استخدام Get.defaultDialog بدلاً من MyDialog
// لأن MyDialog يستخدم Navigator.of(context, rootNavigator: true).pop()
// الذي يتعارض مع Get.dialog() المستخدم في startRideFromDriver()
// وقد يُسبب Get.back() اللاحق إغلاق صفحة الماب بدلاً من الـ loading dialog
Get.defaultDialog(
title: "Start Trip?".tr,
titleStyle: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
middleText: "Ensure the passenger is in the car.".tr,
barrierDismissible: true,
radius: 14,
confirm: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF27AE60),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
),
onPressed: () async {
// نُغلق الديالوج بـ Get.back() لضمان أن GetX يعرف أنه أُغلق
Get.back();
// ثم نُنفذ startRideFromDriver الذي يستخدم Get.dialog و Get.back بأمان
await controller.startRideFromDriver();
},
child: Text('Start'.tr,
style: const TextStyle(fontWeight: FontWeight.bold)),
),
cancel: TextButton(
onPressed: () => Get.back(),
child: Text('Cancel'.tr,
style: const TextStyle(color: Colors.grey)),
),
);
},
icon: const Icon(Icons.play_circle_fill_rounded),
@@ -389,4 +451,167 @@ class PassengerInfoWindow extends StatelessWidget {
);
}
}
void _showCallSelectionDialog(
BuildContext context, MapDriverController controller) {
Get.dialog(
Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Call Options'.tr,
style: AppStyle.title
.copyWith(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
Text(
'Choose how you want to call the passenger'.tr,
style: const TextStyle(color: Colors.grey, fontSize: 14),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.green.withOpacity(0.1),
child: const Icon(Icons.phone_android_rounded,
color: Colors.green),
),
title: Text('Standard Call'.tr,
style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text('Uses cellular network'.tr,
style: const TextStyle(fontSize: 12)),
onTap: () {
Get.back();
makePhoneCall(controller.passengerPhone.toString());
},
),
const Divider(),
ListTile(
leading: CircleAvatar(
backgroundColor: AppColor.primaryColor.withOpacity(0.1),
child: Icon(Icons.wifi_calling_3_rounded,
color: AppColor.primaryColor),
),
title: Text('Free Call'.tr,
style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text('Voice call over internet'.tr,
style: const TextStyle(fontSize: 12)),
onTap: () {
Get.back();
final voiceCtrl = Get.find<VoiceCallController>();
final driverId = box.read(BoxName.driverID).toString();
voiceCtrl.startCall(
rideIdVal: controller.rideId,
driverId: driverId,
passengerId: controller.passengerId,
remoteNameVal: controller.passengerName ?? "Passenger",
);
},
),
],
),
),
),
);
}
void _showMessageOptions(
BuildContext context, MapDriverController controller) {
Get.bottomSheet(
Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(25)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Quick Messages'.tr,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 15),
_buildQuickMessageItem("Where are you, sir?".tr, controller),
_buildQuickMessageItem("I've arrived.".tr, controller),
const Divider(),
Row(
children: [
Expanded(
child: TextField(
controller: controller.messageToPassenger,
decoration:
InputDecoration(hintText: 'Type a message...'.tr),
),
),
IconButton(
icon: const Icon(Icons.send),
onPressed: () {
_sendMessage(controller, controller.messageToPassenger.text,
'cancel');
controller.messageToPassenger.clear();
Get.back();
},
),
],
),
],
),
),
);
}
Widget _buildQuickMessageItem(String text, MapDriverController controller) {
return ListTile(
title: Text(text),
onTap: () {
_sendMessage(controller, text, 'ding');
Get.back();
},
);
}
void _sendMessage(
MapDriverController controller, String body, String tone) async {
try {
await CRUD().post(
link: AppLink.sendChatMessage,
payload: {
'ride_id': controller.rideId.toString(),
'sender_id': box.read(BoxName.driverID).toString(),
'receiver_id': controller.passengerId.toString(),
'sender_type': 'driver',
'message_content': body,
},
);
} catch (e) {
// Ignore or log error
}
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'Driver Message'.tr,
body: body,
isTopic: false,
tone: tone,
driverList: [],
category: 'message From Driver',
);
}
}
/// تحويل المسافة من الأمتار إلى عرض مقروء
/// السيرفر يُرجع المسافة بالأمتار (مثال: 5864.022)
/// النتيجة: "5.9 km" أو "250 م"
String _formatDistanceDisplay(String rawDistance) {
final meters = double.tryParse(rawDistance) ?? 0.0;
if (meters >= 1000) {
return '${(meters / 1000).toStringAsFixed(1)} km';
} else if (meters > 0) {
return '${meters.toStringAsFixed(0)} م';
}
return rawDistance; // fallback للقيمة الأصلية
}

View File

@@ -21,14 +21,10 @@ class SosConnect extends StatelessWidget {
return GetBuilder<MapDriverController>(
id: 'SosConnect', // Keep ID for updates
builder: (controller) {
// Check visibility logic
bool showPassengerContact =
!controller.isRideBegin && controller.isPassengerInfoWindow;
bool showSos = controller.isRideStarted;
if (!showPassengerContact && !showSos) return const SizedBox();
if (!showSos) return const SizedBox();
// REMOVED: Positioned widget
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
@@ -45,46 +41,15 @@ class SosConnect extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// === Call Button ===
if (showPassengerContact)
_buildModernActionButton(
icon: Icons.phone_in_talk,
color: Colors.white,
bgColor: AppColor.blueColor,
tooltip: 'Call Passenger',
onTap: () async {
controller.isSocialPressed = true;
bool canCall = await controller.driverCallPassenger();
if (canCall) {
makePhoneCall(controller.passengerPhone.toString());
} else {
mySnackeBarError("Policy restriction on calls".tr);
}
},
),
if (showPassengerContact) const SizedBox(height: 12),
// === Message Button ===
if (showPassengerContact)
_buildModernActionButton(
icon: MaterialCommunityIcons.message_text_outline,
color: AppColor.primaryColor,
bgColor: Colors.grey.shade100,
tooltip: 'Message Passenger',
onTap: () => _showMessageOptions(context, controller),
),
// === SOS Button ===
if (showSos)
_buildModernActionButton(
icon: MaterialIcons.warning,
color: Colors.white,
bgColor: AppColor.redColor,
tooltip: 'EMERGENCY SOS',
isPulsing: true,
onTap: () => _handleSosCall(controller),
),
_buildModernActionButton(
icon: MaterialIcons.warning,
color: Colors.white,
bgColor: AppColor.redColor,
tooltip: 'EMERGENCY SOS',
isPulsing: true,
onTap: () => _handleSosCall(controller),
),
],
),
);
@@ -140,7 +105,7 @@ class SosConnect extends StatelessWidget {
child: MyTextForm(
controller: mapDriverController.sosEmergincyNumberCotroller,
label: 'Phone Number'.tr,
hint: '01xxxxxxxxx',
hint: '0923456789',
type: TextInputType.phone,
),
),
@@ -163,71 +128,4 @@ class SosConnect extends StatelessWidget {
launchCommunication('phone', box.read(BoxName.sosPhoneDriver), '');
}
}
void _showMessageOptions(
BuildContext context, MapDriverController controller) {
Get.bottomSheet(
Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(25)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Quick Messages'.tr,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 15),
_buildQuickMessageItem("Where are you, sir?".tr, controller),
_buildQuickMessageItem("I've arrived.".tr, controller),
const Divider(),
Row(
children: [
Expanded(
child: TextField(
controller: controller.messageToPassenger,
decoration:
InputDecoration(hintText: 'Type a message...'.tr),
),
),
IconButton(
icon: const Icon(Icons.send),
onPressed: () {
_sendMessage(controller, controller.messageToPassenger.text,
'cancel');
controller.messageToPassenger.clear();
Get.back();
},
),
],
),
],
),
),
);
}
Widget _buildQuickMessageItem(String text, MapDriverController controller) {
return ListTile(
title: Text(text),
onTap: () {
_sendMessage(controller, text, 'ding');
Get.back();
},
);
}
void _sendMessage(MapDriverController controller, String body, String tone) {
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'Driver Message'.tr,
body: body,
isTopic: false,
tone: tone,
driverList: [],
category: 'message From Driver',
);
}
}

View File

@@ -229,8 +229,8 @@ class _OrderOverlayState extends State<OrderOverlay>
// بيانات أساسية
'driver_id': driverId,
'status': 'Apply',
'passengerLocation': _getData(0),
'passengerDestination': _getData(1),
'passengerLocation': '${_getData(0)},${_getData(1)}',
'passengerDestination': '${_getData(3)},${_getData(4)}',
'Duration': _getData(4),
'totalCost': _getData(26),
'Distance': _getData(5),

View File

@@ -12,32 +12,58 @@ class SchedulePage extends StatelessWidget {
return Scaffold(
backgroundColor: FinanceDesignSystem.backgroundColor,
appBar: AppBar(
title: Text('My Schedule'.tr, style: TextStyle(fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
backgroundColor: Colors.transparent, elevation: 0, centerTitle: true,
leading: IconButton(icon: Icon(Icons.arrow_back_ios_new_rounded, color: FinanceDesignSystem.primaryDark, size: 20), onPressed: () => Get.back()),
title: Text('My Schedule'.tr,
style: TextStyle(
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios_new_rounded,
color: FinanceDesignSystem.primaryDark, size: 20),
onPressed: () => Get.back()),
),
body: GetBuilder<ScheduleController>(builder: (sc) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// Summary Card
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: FinanceDesignSystem.balanceGradient,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
borderRadius:
BorderRadius.circular(FinanceDesignSystem.cardRadius),
),
child: Row(children: [
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text('Weekly Plan'.tr, style: TextStyle(color: Colors.white.withValues(alpha: 0.7), fontSize: 14)),
const SizedBox(height: 8),
Text('${sc.totalWeeklyHours.toStringAsFixed(1)}h', style: const TextStyle(fontSize: 32, fontWeight: FontWeight.w900, color: Colors.white)),
Text('${sc.activeDays} ${'Days'.tr}', style: TextStyle(color: Colors.white.withValues(alpha: 0.6), fontSize: 13)),
])),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Weekly Plan'.tr,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.7),
fontSize: 14)),
const SizedBox(height: 8),
Text('${sc.totalWeeklyHours.toStringAsFixed(1)}h',
style: const TextStyle(
fontSize: 32,
fontWeight: FontWeight.w900,
color: Colors.white)),
Text('${sc.activeDays} ${'Days'.tr}',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.6),
fontSize: 13)),
])),
Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(color: Colors.white.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(14)),
child: const Icon(Icons.calendar_today_rounded, color: Colors.white, size: 28),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(14)),
child: const Icon(Icons.calendar_today_rounded,
color: Colors.white, size: 28),
),
]),
),
@@ -53,7 +79,8 @@ class SchedulePage extends StatelessWidget {
);
}
Widget _buildDayCard(BuildContext context, WorkSlot slot, ScheduleController sc) {
Widget _buildDayCard(
BuildContext context, WorkSlot slot, ScheduleController sc) {
final isAr = Get.locale?.languageCode == 'ar';
return Container(
margin: const EdgeInsets.only(bottom: 10),
@@ -61,7 +88,14 @@ class SchedulePage extends StatelessWidget {
decoration: BoxDecoration(
color: slot.isActive ? Colors.white : Colors.grey.shade50,
borderRadius: BorderRadius.circular(14),
boxShadow: slot.isActive ? [BoxShadow(color: Colors.black.withValues(alpha: 0.03), blurRadius: 8, offset: const Offset(0, 3))] : null,
boxShadow: slot.isActive
? [
BoxShadow(
color: Colors.black.withValues(alpha: 0.03),
blurRadius: 8,
offset: const Offset(0, 3))
]
: null,
),
child: Row(children: [
// Toggle
@@ -69,34 +103,57 @@ class SchedulePage extends StatelessWidget {
onTap: () => sc.toggleDay(slot.dayOfWeek),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
width: 44, height: 44,
width: 44,
height: 44,
decoration: BoxDecoration(
color: slot.isActive ? FinanceDesignSystem.accentBlue.withValues(alpha: 0.1) : Colors.grey.shade200,
color: slot.isActive
? FinanceDesignSystem.accentBlue.withValues(alpha: 0.1)
: Colors.grey.shade200,
borderRadius: BorderRadius.circular(12),
),
child: Center(child: Text(
child: Center(
child: Text(
isAr ? slot.dayNameAr.substring(0, 2) : slot.dayName,
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold,
color: slot.isActive ? FinanceDesignSystem.accentBlue : Colors.grey.shade400),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: slot.isActive
? FinanceDesignSystem.accentBlue
: Colors.grey.shade400),
)),
),
),
const SizedBox(width: 14),
// Day name
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(isAr ? slot.dayNameAr : slot.dayName.tr, style: TextStyle(
fontSize: 14, fontWeight: FontWeight.w600,
color: slot.isActive ? FinanceDesignSystem.primaryDark : Colors.grey.shade400)),
Expanded(
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(isAr ? slot.dayNameAr : slot.dayName.tr,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: slot.isActive
? FinanceDesignSystem.primaryDark
: Colors.grey.shade400)),
if (slot.isActive)
Text(slot.timeRange, style: TextStyle(fontSize: 12, color: Colors.grey.shade500)),
Text(slot.timeRange,
style: TextStyle(fontSize: 12, color: Colors.grey.shade500)),
if (!slot.isActive)
Text('Day Off'.tr, style: TextStyle(fontSize: 12, color: Colors.grey.shade400, fontStyle: FontStyle.italic)),
Text('Day Off'.tr,
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade400,
fontStyle: FontStyle.italic)),
])),
// Time pickers
if (slot.isActive) ...[
_timePicker(context, slot.startTime, (t) => sc.updateStartTime(slot.dayOfWeek, t)),
Padding(padding: const EdgeInsets.symmetric(horizontal: 4), child: Text('-', style: TextStyle(color: Colors.grey.shade400))),
_timePicker(context, slot.endTime, (t) => sc.updateEndTime(slot.dayOfWeek, t)),
_timePicker(context, slot.startTime,
(t) => sc.updateStartTime(slot.dayOfWeek, t)),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text('-', style: TextStyle(color: Colors.grey.shade400))),
_timePicker(context, slot.endTime,
(t) => sc.updateEndTime(slot.dayOfWeek, t)),
],
// Toggle switch
Switch(
@@ -108,17 +165,25 @@ class SchedulePage extends StatelessWidget {
);
}
Widget _timePicker(BuildContext context, TimeOfDay time, Function(TimeOfDay) onChanged) {
Widget _timePicker(
BuildContext context, TimeOfDay time, Function(TimeOfDay) onChanged) {
return GestureDetector(
onTap: () async {
final picked = await showTimePicker(context: context, initialTime: time);
final picked =
await showTimePicker(context: context, initialTime: time);
if (picked != null) onChanged(picked);
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(8)),
child: Text('${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: FinanceDesignSystem.primaryDark)),
decoration: BoxDecoration(
color: Colors.grey.shade100,
borderRadius: BorderRadius.circular(8)),
child: Text(
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: FinanceDesignSystem.primaryDark)),
),
);
}

View File

@@ -0,0 +1,278 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_driver/constant/style.dart';
import 'package:sefer_driver/controller/home/profile/complaint_controller.dart';
import 'package:sefer_driver/views/widgets/my_scafold.dart';
import 'package:sefer_driver/views/widgets/mycircular.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart';
import '../../../controller/functions/audio_recorder_controller.dart';
class ComplaintPage extends StatelessWidget {
ComplaintPage({super.key});
final ComplaintController complaintController =
Get.put(ComplaintController());
final AudioRecorderController audioRecorderController =
Get.put(AudioRecorderController());
@override
Widget build(BuildContext context) {
return MyScafolld(
title: 'Submit a Complaint'.tr,
isleading: true,
body: [
GetBuilder<ComplaintController>(
builder: (controller) {
if (controller.isLoading && controller.ridesList.isEmpty) {
return const MyCircularProgressIndicator();
}
return Stack(
children: [
Form(
key: controller.formKey,
child: ListView(
padding: const EdgeInsets.all(16.0),
children: [
// --- 1. Select Ride Section ---
_buildSectionCard(
title: '1. Select Ride'.tr,
child: controller.ridesList.isEmpty
? Text('No rides found to complain about.'.tr,
style: AppStyle.subtitle)
: DropdownButtonFormField<Map<String, dynamic>>(
value: controller.selectedRide,
dropdownColor: AppColor.surfaceColor,
items: controller.ridesList.map((ride) {
return DropdownMenuItem<Map<String, dynamic>>(
value: ride,
child: Text(
'${'Ride'.tr} #${ride['id']} (${ride['date']})',
style: AppStyle.subtitle,
),
);
}).toList(),
onChanged: (ride) {
if (ride != null) {
controller.selectRide(ride);
}
},
decoration: InputDecoration(
filled: true,
fillColor:
AppColor.secondaryColor.withOpacity(0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
),
),
),
// --- 2. Describe Your Issue Section ---
_buildSectionCard(
title: '2. Describe Your Issue'.tr,
child: TextFormField(
controller: controller.complaintController,
decoration: InputDecoration(
hintText: 'Enter your complaint here...'.tr,
filled: true,
fillColor:
AppColor.secondaryColor.withOpacity(0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.all(16),
),
maxLines: 6,
style: AppStyle.subtitle,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a description of the issue.'
.tr;
}
return null;
},
),
),
// --- 3. Attach Recorded Audio Section ---
if (controller.selectedRide != null)
_buildSectionCard(
title: '3. Attach Recorded Audio (Optional)'.tr,
child: FutureBuilder<List<String>>(
future: audioRecorderController.getRecordedFiles(),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator());
}
final rideId =
controller.selectedRide!['id'].toString();
// Filter files to only show the audio file associated with the selected Ride ID
final matchingFiles = snapshot.data
?.where((path) =>
path.endsWith('_${rideId}.m4a'))
.toList() ??
[];
if (snapshot.hasError || matchingFiles.isEmpty) {
return Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0),
child: Text(
'No audio files found for this ride.'.tr,
style: AppStyle.subtitle),
),
);
}
return Column(
children: matchingFiles.map((audioFilePath) {
final audioFile = File(audioFilePath);
final isUploaded =
controller.audioLink.isNotEmpty &&
controller.attachedFileName ==
audioFilePath.split('/').last;
return ListTile(
leading: Icon(
isUploaded
? Icons.check_circle
: Icons.mic,
color: isUploaded
? AppColor.greenColor
: AppColor.redColor),
title: Text(audioFilePath.split('/').last,
style: AppStyle.subtitle,
overflow: TextOverflow.ellipsis),
subtitle: isUploaded
? Text('Uploaded'.tr,
style: const TextStyle(
color: AppColor.greenColor))
: null,
onTap: isUploaded
? null
: () {
MyDialogContent().getDialog(
'Confirm Attachment'.tr,
Text(
'Attach this audio file?'
.tr), () async {
await controller
.uploadAudioFile(audioFile);
});
},
);
}).toList(),
);
},
),
),
// --- 4. Review Details & Response Section ---
if (controller.selectedRide != null)
_buildSectionCard(
title: '4. Review Details & Response'.tr,
child: Column(
children: [
_buildDetailRow(
Icons.calendar_today_outlined,
'Date'.tr,
controller.selectedRide!['date'] ?? ''),
_buildDetailRow(
Icons.monetization_on_outlined,
'Price'.tr,
'${controller.selectedRide!['price'] ?? ''}'),
const Divider(height: 24),
ListTile(
leading: const Icon(
Icons.support_agent_outlined,
color: AppColor.primaryColor),
title: Text("Intaleq's Response".tr,
style: AppStyle.title),
subtitle: Text(
controller.driverReport?['body']
?.toString() ??
'Awaiting response...'.tr,
style:
AppStyle.subtitle.copyWith(height: 1.5),
),
),
],
),
),
// --- 5. Submit Button ---
const SizedBox(height: 24),
MyElevatedButton(
onPressed: () async {
await controller.submitComplaintToServer();
},
title: 'Submit Complaint'.tr,
),
const SizedBox(height: 24),
],
),
),
if (controller.isLoading)
Container(
color: Colors.black.withOpacity(0.5),
child: const MyCircularProgressIndicator(),
),
],
);
},
),
],
);
}
Widget _buildSectionCard({required String title, required Widget child}) {
return Card(
margin: const EdgeInsets.only(bottom: 20),
elevation: 4,
shadowColor: Colors.black.withOpacity(0.1),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: AppStyle.headTitle.copyWith(fontSize: 18)),
const SizedBox(height: 12),
child,
],
),
),
);
}
Widget _buildDetailRow(IconData icon, String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
children: [
Icon(icon, color: AppColor.writeColor.withOpacity(0.6), size: 20),
const SizedBox(width: 12),
Text('${label.tr}:',
style: AppStyle.subtitle
.copyWith(color: AppColor.writeColor.withOpacity(0.7))),
const Spacer(),
Text(value,
style: AppStyle.title.copyWith(fontWeight: FontWeight.bold)),
],
),
);
}
}

View File

@@ -4,14 +4,12 @@ import 'package:get/get.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/controller/profile/captain_profile_controller.dart';
import 'package:sefer_driver/main.dart';
import 'package:sefer_driver/views/auth/captin/criminal_documents_page.dart';
import 'package:sefer_driver/views/widgets/my_scafold.dart';
import 'package:sefer_driver/views/widgets/mycircular.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import '../../../constant/links.dart';
import '../../../controller/functions/crud.dart';
import 'behavior_page.dart';
import 'captains_cars.dart';
import 'complaint_page.dart';
// الصفحة الرئيسية الجديدة
class ProfileCaptain extends StatelessWidget {
@@ -121,8 +119,8 @@ class ProfileHeader extends StatelessWidget {
const SizedBox(width: 4),
Text(
'${rating.toStringAsFixed(1)} (${'reviews'.tr} $ratingCount)',
style: theme.textTheme.titleMedium
?.copyWith(color: theme.hintColor),
style:
theme.textTheme.titleMedium?.copyWith(color: theme.hintColor),
),
],
),
@@ -131,7 +129,6 @@ class ProfileHeader extends StatelessWidget {
}
}
/// 2. ويدجت شبكة الأزرار
class ActionsGrid extends StatelessWidget {
const ActionsGrid({super.key});
@@ -171,6 +168,11 @@ class ActionsGrid extends StatelessWidget {
icon: Icons.checklist_rtl,
onTap: () => Get.to(() => BehaviorPage()),
),
_ActionTile(
title: 'Submit a Complaint'.tr,
icon: Icons.note_add_rounded,
onTap: () => Get.to(() => ComplaintPage()),
),
],
);
}
@@ -198,207 +200,206 @@ void showShamCashInput() {
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
boxShadow: [
BoxShadow(
color: theme.shadowColor.withOpacity(0.2), blurRadius: 10, offset: const Offset(0, -2))
color: theme.shadowColor.withOpacity(0.2),
blurRadius: 10,
offset: const Offset(0, -2))
],
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// --- 1. المقبض العلوي ---
Center(
child: Container(
height: 5,
width: 50,
decoration: BoxDecoration(
color: theme.dividerColor,
borderRadius: BorderRadius.circular(10)),
margin: const EdgeInsets.only(bottom: 20),
),
),
// --- 2. العنوان والأيقونة ---
Image.asset(
'assets/images/shamCash.png',
height: 50,
),
// const Icon(Icons.account_balance_wallet_rounded,
// size: 45, color: Colors.blueAccent),
const SizedBox(height: 10),
Text(
"ربط حساب شام كاش 🔗",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.blueGrey[900]),
),
const SizedBox(height: 5),
const Text(
"أدخل بيانات حسابك لاستقبال الأرباح فوراً",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 13, color: Colors.grey),
),
const SizedBox(height: 25),
// --- 3. الحقل الأول: اسم الحساب (أعلى الباركود) ---
const Text("1. اسم الحساب (أعلى الباركود)",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
const SizedBox(height: 8),
Container(
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[300]!),
),
child: TextField(
controller: nameController,
decoration: InputDecoration(
hintText: "مثال: intaleq",
hintStyle: TextStyle(color: Colors.grey[400], fontSize: 13),
border: InputBorder.none,
prefixIcon: const Icon(Icons.person_outline_rounded,
color: Colors.blueGrey),
contentPadding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
children: [
// --- 1. المقبض العلوي ---
Center(
child: Container(
height: 5,
width: 50,
decoration: BoxDecoration(
color: theme.dividerColor,
borderRadius: BorderRadius.circular(10)),
margin: const EdgeInsets.only(bottom: 20),
),
),
),
const SizedBox(height: 15),
// --- 4. الحقل الثاني: الكود (أسفل الباركود) ---
const Text("2. كود المحفظة (أسفل الباركود)",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
const SizedBox(height: 8),
Container(
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[300]!),
// --- 2. العنوان والأيقونة ---
Image.asset(
'assets/images/shamCash.png',
height: 50,
),
child: TextField(
controller: codeController,
style: const TextStyle(
fontSize: 13,
letterSpacing: 0.5), // خط أصغر قليلاً للكود الطويل
decoration: InputDecoration(
hintText: "مثال: 80f23afe40...",
hintStyle: TextStyle(color: Colors.grey[400], fontSize: 13),
border: InputBorder.none,
prefixIcon: const Icon(Icons.qr_code_2_rounded,
color: Colors.blueGrey),
contentPadding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
// const Icon(Icons.account_balance_wallet_rounded,
// size: 45, color: Colors.blueAccent),
const SizedBox(height: 10),
Text(
"ربط حساب شام كاش 🔗",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.blueGrey[900]),
),
const SizedBox(height: 5),
const Text(
"أدخل بيانات حسابك لاستقبال الأرباح فوراً",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 13, color: Colors.grey),
),
const SizedBox(height: 25),
// زر لصق الكود
suffixIcon: IconButton(
icon: const Icon(Icons.paste_rounded, color: Colors.blue),
tooltip: "لصق الكود",
onPressed: () async {
ClipboardData? data =
await Clipboard.getData(Clipboard.kTextPlain);
if (data != null && data.text != null) {
codeController.text = data.text!;
// تحريك المؤشر للنهاية بعد اللصق
codeController.selection = TextSelection.fromPosition(
TextPosition(offset: codeController.text.length),
);
}
},
// --- 3. الحقل الأول: اسم الحساب (أعلى الباركود) ---
const Text("1. اسم الحساب (أعلى الباركود)",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
const SizedBox(height: 8),
Container(
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[300]!),
),
child: TextField(
controller: nameController,
decoration: InputDecoration(
hintText: "مثال: intaleq",
hintStyle: TextStyle(color: Colors.grey[400], fontSize: 13),
border: InputBorder.none,
prefixIcon: const Icon(Icons.person_outline_rounded,
color: Colors.blueGrey),
contentPadding: const EdgeInsets.symmetric(
vertical: 15, horizontal: 10),
),
),
),
),
const SizedBox(height: 30),
const SizedBox(height: 15),
// --- 5. زر الحفظ ---
SizedBox(
height: 50,
child: ElevatedButton(
onPressed: () async {
String name = nameController.text.trim();
String code = codeController.text.trim();
// --- 4. الحقل الثاني: الكود (أسفل الباركود) ---
const Text("2. كود المحفظة (أسفل الباركود)",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
const SizedBox(height: 8),
Container(
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[300]!),
),
child: TextField(
controller: codeController,
style: const TextStyle(
fontSize: 13,
letterSpacing: 0.5), // خط أصغر قليلاً للكود الطويل
decoration: InputDecoration(
hintText: "مثال: 80f23afe40...",
hintStyle: TextStyle(color: Colors.grey[400], fontSize: 13),
border: InputBorder.none,
prefixIcon: const Icon(Icons.qr_code_2_rounded,
color: Colors.blueGrey),
contentPadding: const EdgeInsets.symmetric(
vertical: 15, horizontal: 10),
// التحقق من صحة البيانات
if (name.isNotEmpty && code.length > 5) {
// 1. إرسال البيانات إلى السيرفر
var res = await CRUD()
.post(link: AppLink.updateShamCashDriver, payload: {
"id": box.read(BoxName.driverID),
"accountBank": name,
"bankCode": code,
});
// زر لصق الكود
suffixIcon: IconButton(
icon: const Icon(Icons.paste_rounded, color: Colors.blue),
tooltip: "لصق الكود",
onPressed: () async {
ClipboardData? data =
await Clipboard.getData(Clipboard.kTextPlain);
if (data != null && data.text != null) {
codeController.text = data.text!;
// تحريك المؤشر للنهاية بعد اللصق
codeController.selection = TextSelection.fromPosition(
TextPosition(offset: codeController.text.length),
);
}
},
),
),
),
),
if (res != 'failure') {
// 2. 🔴 الحفظ في الذاكرة المحلية (GetStorage) بعد نجاح التحديث
box.write('shamcash_name', name);
box.write('shamcash_code', code);
const SizedBox(height: 30),
Get.back(); // إغلاق النافذة
Get.snackbar(
"تم الحفظ بنجاح",
"تم ربط حساب ($name) لاستلام الأرباح.",
backgroundColor: Colors.green,
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(20),
icon: const Icon(Icons.check_circle_outline,
color: Colors.white),
);
return;
// --- 5. زر الحفظ ---
SizedBox(
height: 50,
child: ElevatedButton(
onPressed: () async {
String name = nameController.text.trim();
String code = codeController.text.trim();
// التحقق من صحة البيانات
if (name.isNotEmpty && code.length > 5) {
// 1. إرسال البيانات إلى السيرفر
var res = await CRUD()
.post(link: AppLink.updateShamCashDriver, payload: {
"id": box.read(BoxName.driverID),
"accountBank": name,
"bankCode": code,
});
if (res != 'failure') {
// 2. 🔴 الحفظ في الذاكرة المحلية (GetStorage) بعد نجاح التحديث
box.write('shamcash_name', name);
box.write('shamcash_code', code);
Get.back(); // إغلاق النافذة
Get.snackbar(
"تم الحفظ بنجاح",
"تم ربط حساب ($name) لاستلام الأرباح.",
backgroundColor: Colors.green,
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(20),
icon: const Icon(Icons.check_circle_outline,
color: Colors.white),
);
return;
} else {
// في حال فشل الإرسال إلى السيرفر
Get.snackbar(
"خطأ في السيرفر",
"فشل تحديث البيانات، يرجى المحاولة لاحقاً.",
backgroundColor: Colors.redAccent,
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(20),
);
}
} else {
// في حال فشل الإرسال إلى السيرفر
Get.snackbar(
"خطأ في السيرفر",
"فشل تحديث البيانات، يرجى المحاولة لاحقاً.",
backgroundColor: Colors.redAccent,
"بيانات ناقصة",
"يرجى التأكد من إدخال الاسم والكود بشكل صحيح.",
backgroundColor: Colors.orange,
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(20),
);
}
} else {
Get.snackbar(
"بيانات ناقصة",
"يرجى التأكد من إدخال الاسم والكود بشكل صحيح.",
backgroundColor: Colors.orange,
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(20),
);
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2ecc71), // الأخضر المالي
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
elevation: 2,
),
child: const Text(
"حفظ وتفعيل الحساب",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white),
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2ecc71), // الأخضر المالي
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
elevation: 2,
),
child: const Text(
"حفظ وتفعيل الحساب",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
),
),
const SizedBox(height: 10), // مسافة سفلية إضافية للأمان
],
const SizedBox(height: 10), // مسافة سفلية إضافية للأمان
],
),
),
),
);
}),
);
}),
isScrollControlled: true,
);
}
/// ويدجت داخلية لزر في الشبكة
class _ActionTile extends StatelessWidget {
final String title;
@@ -438,7 +439,6 @@ class _ActionTile extends StatelessWidget {
}
}
/// 3. بطاقة المعلومات الشخصية
class PersonalInfoCard extends StatelessWidget {
final Map<String, dynamic> data;
@@ -574,7 +574,7 @@ class _InfoRow extends StatelessWidget {
child: Text(
value,
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.textTheme.bodyLarge?.color?.withOpacity(0.8),
color: theme.textTheme.bodyLarge?.color?.withOpacity(0.8),
fontWeight: FontWeight.w500),
textAlign: TextAlign.end,
),
@@ -584,4 +584,3 @@ class _InfoRow extends StatelessWidget {
);
}
}

View File

@@ -151,18 +151,47 @@ class RideAvailableCard extends StatelessWidget {
),
],
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: AppColor.greenColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: AppColor.greenColor.withOpacity(0.3)),
),
child: Text(
rideInfo['carType'] ?? 'Fixed Price'.tr,
style: AppStyle.title
.copyWith(color: AppColor.greenColor, fontSize: 13),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: AppColor.greenColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: AppColor.greenColor.withOpacity(0.3)),
),
child: Text(
rideInfo['carType'] ?? 'Fixed Price'.tr,
style: AppStyle.title
.copyWith(color: AppColor.greenColor, fontSize: 13),
),
),
if (rideInfo['has_steps']?.toString() == 'true') ...[
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.orange.shade100,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.orange),
),
child: Row(
children: [
Icon(Icons.alt_route, color: Colors.orange.shade800, size: 14),
const SizedBox(width: 4),
Text(
'متعددة التوقفات',
style: AppStyle.subtitle.copyWith(
color: Colors.orange.shade800,
fontSize: 11,
fontWeight: FontWeight.bold),
),
],
),
),
]
],
),
],
);
@@ -337,8 +366,12 @@ class RideAvailableCard extends StatelessWidget {
'direction':
'http://googleusercontent.com/maps.google.com/maps?saddr=${rideInfo['start_location']}&daddr=${rideInfo['end_location']}',
'timeOfOrder': DateTime.now().toString(),
'isHaveSteps': 'false', // لو كان عندك خطوات في الـ waitingRides ضيفها
'step0': '', 'step1': '', 'step2': '', 'step3': '', 'step4': '',
'isHaveSteps': rideInfo['has_steps']?.toString() ?? 'false',
'step0': rideInfo['step0'] ?? '',
'step1': rideInfo['step1'] ?? '',
'step2': rideInfo['step2'] ?? '',
'step3': rideInfo['step3'] ?? '',
'step4': rideInfo['step4'] ?? '',
};
// حفظ البيانات في الصندوق احتياطياً (Crash Recovery)

View File

@@ -0,0 +1,300 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/voice_call_controller.dart';
class VoiceCallBottomSheet extends StatelessWidget {
const VoiceCallBottomSheet({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final controller = Get.find<VoiceCallController>();
final double screenHeight = MediaQuery.of(context).size.height;
final bool isDark = Theme.of(context).brightness == Brightness.dark;
// Harmonious curated colors
final Color bgColor = isDark ? const Color(0xFF121212) : Colors.white;
final Color cardColor = isDark ? const Color(0xFF1E1E1E) : const Color(0xFFF5F5F7);
final Color textColor = isDark ? Colors.white : const Color(0xFF1C1C1E);
final Color subTextColor = isDark ? Colors.white70 : Colors.black54;
return WillPopScope(
onWillPop: () async => false,
child: Container(
height: screenHeight * 0.9,
decoration: BoxDecoration(
color: bgColor,
borderRadius: const BorderRadius.vertical(top: Radius.circular(32)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 20,
offset: const Offset(0, -5),
)
],
),
child: Obx(() {
final state = controller.state.value;
final seconds = controller.elapsedSeconds.value;
final remoteName = controller.remoteName.value;
final isMuted = controller.isMuted.value;
final isSpeakerOn = controller.isSpeakerOn.value;
final errorMsg = controller.errorMessage.value;
// Progress ring logic
final double progress = seconds / 60.0;
final Color ringColor = (errorMsg.isNotEmpty || seconds <= 10)
? const Color(0xFFE74C3C)
: const Color(0xFF2ECC71);
// Status text translations
String statusText = "";
if (errorMsg.isNotEmpty) {
statusText = errorMsg;
} else {
switch (state) {
case VoiceCallState.dialing:
statusText = "${'Calling'.tr} $remoteName...";
break;
case VoiceCallState.ringing:
statusText = "${'Incoming Call...'.tr}";
break;
case VoiceCallState.connecting:
statusText = "Connecting...".tr;
break;
case VoiceCallState.active:
statusText = "Call Connected".tr;
break;
case VoiceCallState.ended:
statusText = "Call Ended".tr;
break;
case VoiceCallState.idle:
statusText = "";
break;
}
}
return Column(
children: [
// Top Drag Handle Indicator
Center(
child: Container(
margin: const EdgeInsets.only(top: 12, bottom: 24),
width: 44,
height: 5,
decoration: BoxDecoration(
color: isDark ? Colors.white24 : Colors.black12,
borderRadius: BorderRadius.circular(10),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Header Info
Column(
children: [
Text(
"Free Call".tr,
style: TextStyle(
color: ringColor,
fontWeight: FontWeight.w800,
fontSize: 14,
letterSpacing: 1.2,
),
),
const SizedBox(height: 8),
Text(
remoteName,
style: TextStyle(
color: textColor,
fontWeight: FontWeight.w900,
fontSize: 26,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
statusText,
style: TextStyle(
color: errorMsg.isNotEmpty
? const Color(0xFFE74C3C)
: subTextColor,
fontWeight: FontWeight.w600,
fontSize: 16,
),
textAlign: TextAlign.center,
),
],
),
// Avatar & Animated Progress Ring
Stack(
alignment: Alignment.center,
children: [
// Progress ring around avatar (Active state only)
if (state == VoiceCallState.active)
SizedBox(
width: 172,
height: 172,
child: CircularProgressIndicator(
value: progress,
strokeWidth: 5,
backgroundColor: isDark ? Colors.white10 : Colors.black12,
valueColor: AlwaysStoppedAnimation<Color>(ringColor),
),
),
// Main Avatar Card
Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: cardColor,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 15,
offset: const Offset(0, 8),
)
],
),
child: Center(
child: remoteName.isNotEmpty
? Text(
remoteName[0].toUpperCase(),
style: TextStyle(
color: textColor,
fontWeight: FontWeight.bold,
fontSize: 54,
),
)
: Icon(
Icons.person,
color: textColor.withOpacity(0.6),
size: 64,
),
),
),
],
),
// Timer Counter Display
if (state == VoiceCallState.active)
Text(
"0:${seconds.toString().padLeft(2, '0')}",
style: TextStyle(
color: seconds > 10 ? textColor : const Color(0xFFE74C3C),
fontWeight: FontWeight.bold,
fontSize: 22,
fontFamily: 'monospace',
),
)
else
const SizedBox(height: 24),
// Action Controls Block
if (state == VoiceCallState.ringing)
// Incoming Ringing Controls: Accept / Decline
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildCircleActionButton(
icon: Icons.call_end_rounded,
color: Colors.white,
bgColor: const Color(0xFFE74C3C),
onTap: () => controller.declineCall(),
label: "Decline".tr,
),
_buildCircleActionButton(
icon: Icons.call_rounded,
color: Colors.white,
bgColor: const Color(0xFF2ECC71),
onTap: () => controller.acceptCall(),
label: "Accept".tr,
),
],
)
else
// Dialing or Connected Controls: Speaker / Mute / Hangup
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Speakerphone toggle
_buildCircleActionButton(
icon: isSpeakerOn ? Icons.volume_up_rounded : Icons.volume_down_rounded,
color: isSpeakerOn ? Colors.white : textColor,
bgColor: isSpeakerOn ? const Color(0xFF2ECC71) : cardColor,
onTap: () => controller.toggleSpeaker(),
label: "Speaker".tr,
),
// Hangup Call
_buildCircleActionButton(
icon: Icons.call_end_rounded,
color: Colors.white,
bgColor: const Color(0xFFE74C3C),
onTap: () => controller.hangup(),
label: "End".tr,
),
// Mute Microphone
_buildCircleActionButton(
icon: isMuted ? Icons.mic_off_rounded : Icons.mic_rounded,
color: isMuted ? Colors.white : textColor,
bgColor: isMuted ? const Color(0xFFE74C3C) : cardColor,
onTap: () => controller.toggleMute(),
label: "Mute".tr,
),
],
),
],
),
),
),
],
);
}),
),
);
}
Widget _buildCircleActionButton({
required IconData icon,
required Color color,
required Color bgColor,
required VoidCallback onTap,
required String label,
}) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: onTap,
style: ElevatedButton.styleFrom(
shape: const CircleBorder(),
padding: const EdgeInsets.all(18),
backgroundColor: bgColor,
foregroundColor: color,
elevation: 2,
),
child: Icon(icon, size: 28),
),
const SizedBox(height: 8),
Text(
label,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
),
],
);
}
}