Update: 2026-08-07 01:35:27
This commit is contained in:
@@ -49,6 +49,21 @@ class OrderRequestController extends GetxController
|
||||
List<dynamic>? myList;
|
||||
Map<dynamic, dynamic>? myMapData;
|
||||
|
||||
/// نوع الطلب: 'exclusive' خلال ثواني السبق الحصري، 'public' بعد إطلاقه
|
||||
/// للجميع، و null في وضع البثّ الحر (DISPATCH_MODE غير مضبوط) — عندها
|
||||
/// لا تُعرض أي شارة.
|
||||
///
|
||||
/// المصدر: حقل offer_type في حمولة السوكِت (new_ride_request /
|
||||
/// market_new_ride). الطلبات القادمة عبر FCM أو القائمة المسبقة لا تحمله.
|
||||
Map<String, dynamic>? get offerInfo {
|
||||
final t = myMapData?['offer_type'];
|
||||
if (t == null) return null;
|
||||
return {
|
||||
'offer_type': t.toString(),
|
||||
'offer_expires_in': myMapData?['offer_expires_in'],
|
||||
};
|
||||
}
|
||||
|
||||
IntaleqMapController? mapController;
|
||||
|
||||
// الإحداثيات (أزلنا late لتجنب الأخطاء القاتلة)
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:intaleq_maps/intaleq_maps.dart';
|
||||
import 'package:siro_driver/constant/api_key.dart';
|
||||
import 'package:siro_driver/constant/colors.dart';
|
||||
import 'package:siro_driver/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:siro_driver/views/widgets/offer_type_badge.dart';
|
||||
import 'package:siro_driver/constant/currency.dart';
|
||||
import 'package:siro_driver/views/widgets/driver_earnings_badge.dart';
|
||||
|
||||
@@ -109,6 +110,11 @@ class OrderRequestPage extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// شارة الطلب الخاص/العام — تختفي في وضع البثّ الحر
|
||||
if (controller.offerInfo != null) ...[
|
||||
OfferTypeBadge(rideInfo: controller.offerInfo!),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
const Icon(Icons.near_me,
|
||||
color: Colors.amber, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
/// شارة نوع الطلب: خاص أم عام.
|
||||
///
|
||||
/// الخادم يمنح السائق الأفضل ترتيباً سبقاً حصرياً بضع ثوانٍ قبل أن يُطلق
|
||||
/// الطلب للجميع (DISPATCH_MODE=batched). بدون هذه الشارة يبدو الفرق
|
||||
/// عشوائياً للسائق؛ معها يفهم أنه صاحب الأولوية الآن وأن التأخير يكلّفه
|
||||
/// الطلب.
|
||||
///
|
||||
/// المصدر: حقل `offer_type` في حمولة السوكِت — 'exclusive' أو 'public'.
|
||||
/// غيابه يعني طلباً عاماً (كل المسارات القديمة والبثّ الحر)، فلا تظهر
|
||||
/// الشارة إطلاقاً في وضع البثّ العادي.
|
||||
class OfferTypeBadge extends StatelessWidget {
|
||||
final Map rideInfo;
|
||||
|
||||
const OfferTypeBadge({Key? key, required this.rideInfo}) : super(key: key);
|
||||
|
||||
bool get _isExclusive =>
|
||||
rideInfo['offer_type']?.toString() == 'exclusive';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// لا شارة في الوضع العادي — لا نضيف ضجيجاً بصرياً بلا معنى.
|
||||
if (rideInfo['offer_type'] == null) return const SizedBox.shrink();
|
||||
|
||||
final Color color = _isExclusive ? Colors.amber.shade800 : Colors.blueGrey;
|
||||
final IconData icon = _isExclusive ? Icons.star_rounded : Icons.public;
|
||||
final String label = _isExclusive ? 'طلب خاص لك'.tr : 'طلب عام'.tr;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: color.withOpacity(0.5)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user