Update: 2026-07-12 06:04:42
This commit is contained in:
@@ -32,7 +32,8 @@ class HomeCaptainController extends GetxController {
|
||||
Timer? activeTimer;
|
||||
Map data = {};
|
||||
bool isHomeMapActive = true;
|
||||
InlqBitmap carIcon = InlqBitmap.fromAsset('assets/images/car.png', size: 2.3);
|
||||
InlqBitmap carIcon =
|
||||
InlqBitmap.fromStyleImage('car_icon', size: 2.3);
|
||||
bool isMapReadyForCommands = false;
|
||||
bool isLoading = true;
|
||||
late double kazan = 0;
|
||||
@@ -262,13 +263,13 @@ class HomeCaptainController extends GetxController {
|
||||
final Set<Polygon> temp = {};
|
||||
|
||||
for (final zone in zones) {
|
||||
final double lat = (zone['lat'] as num).toDouble();
|
||||
final double lng = (zone['lng'] as num).toDouble();
|
||||
final int score = (zone['demand_score'] as num).toInt();
|
||||
final double lat = (zone['lat'] as num).toDouble();
|
||||
final double lng = (zone['lng'] as num).toDouble();
|
||||
final int score = (zone['demand_score'] as num).toInt();
|
||||
|
||||
// ألوان التنبؤ: أزرق/سماوي (مختلف تماماً عن الهيتماب)
|
||||
final Color fill = score >= 8
|
||||
? const Color(0xFF0EA5E9).withOpacity(0.35) // أزرق قوي
|
||||
final Color fill = score >= 8
|
||||
? const Color(0xFF0EA5E9).withOpacity(0.35) // أزرق قوي
|
||||
: score >= 4
|
||||
? const Color(0xFF38BDF8).withOpacity(0.30) // أزرق فاتح
|
||||
: const Color(0xFF7DD3FC).withOpacity(0.25); // سماوي خفيف
|
||||
@@ -285,7 +286,7 @@ class HomeCaptainController extends GetxController {
|
||||
LatLng(lat + offset, lng + offset),
|
||||
LatLng(lat - offset, lng + offset),
|
||||
],
|
||||
fillColor: fill,
|
||||
fillColor: fill,
|
||||
strokeColor: stroke,
|
||||
strokeWidth: 2,
|
||||
));
|
||||
@@ -641,6 +642,19 @@ class HomeCaptainController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> onStyleLoaded() async {
|
||||
print("🎨 [HomeCaptain] onStyleLoaded");
|
||||
try {
|
||||
final ByteData bytes = await rootBundle.load('assets/images/car.png');
|
||||
await mapHomeCaptainController?.addImage(
|
||||
'car_icon', bytes.buffer.asUint8List());
|
||||
carIcon = InlqBitmap.fromStyleImage('car_icon', size: 2.3);
|
||||
update();
|
||||
} catch (e) {
|
||||
print("❌ [HomeCaptain] Map icon load error: $e");
|
||||
}
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
final periods = box.read<List<dynamic>>(BoxName.periods) ?? [];
|
||||
periods.add(period.inSeconds);
|
||||
@@ -737,11 +751,13 @@ class HomeCaptainController extends GetxController {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.location_off, size: 60, color: Colors.redAccent),
|
||||
const Icon(Icons.location_off,
|
||||
size: 60, color: Colors.redAccent),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
'service_unavailable_area'.tr,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@@ -752,7 +768,6 @@ class HomeCaptainController extends GetxController {
|
||||
enableDrag: false,
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
print(
|
||||
"⚠️ [HomeCaptain] Could not get current location, using default.");
|
||||
@@ -899,20 +914,22 @@ class HomeCaptainController extends GetxController {
|
||||
var json = jsonDecode(res);
|
||||
if (json['message'] is List && json['message'].isNotEmpty) {
|
||||
final item = json['message'][0];
|
||||
|
||||
|
||||
double parseDouble(dynamic val) {
|
||||
if (val == null) return 0.0;
|
||||
return double.tryParse(val.toString()) ?? 0.0;
|
||||
}
|
||||
|
||||
|
||||
kazan = parseDouble(item['kazanPercent'] ?? item['kazan']);
|
||||
naturePrice = parseDouble(item['normalMinPrice'] ?? item['naturePrice']);
|
||||
naturePrice =
|
||||
parseDouble(item['normalMinPrice'] ?? item['naturePrice']);
|
||||
heavyPrice = parseDouble(item['peakMinPrice'] ?? item['heavyPrice']);
|
||||
latePrice = parseDouble(item['lateMinPrice'] ?? item['latePrice']);
|
||||
comfortPrice = parseDouble(item['comfortPrice']);
|
||||
speedPrice = parseDouble(item['speedPrice']);
|
||||
deliveryPrice = parseDouble(item['deliveryPrice']);
|
||||
mashwariPrice = parseDouble(item['freePrice'] ?? item['mishwarVipPrice']);
|
||||
mashwariPrice =
|
||||
parseDouble(item['freePrice'] ?? item['mishwarVipPrice']);
|
||||
familyPrice = parseDouble(item['familyPrice'] ?? item['ladyPrice']);
|
||||
fuelPrice = parseDouble(item['fuelPrice']);
|
||||
}
|
||||
@@ -927,6 +944,7 @@ class HomeCaptainController extends GetxController {
|
||||
calculateConsumptionFuel() {
|
||||
mpg = fuelPrice / 12; //todo in register car add mpg in box
|
||||
}
|
||||
|
||||
// 🆕 Gamification Streak State
|
||||
int streakCount = 0;
|
||||
bool isZeroCommissionActive = false;
|
||||
@@ -939,7 +957,7 @@ class HomeCaptainController extends GetxController {
|
||||
|
||||
countRideToday = data['message'][0]['count'].toString();
|
||||
update();
|
||||
|
||||
|
||||
// Fetch Gamification Streak as well
|
||||
getDriverStreak();
|
||||
}
|
||||
@@ -953,7 +971,8 @@ class HomeCaptainController extends GetxController {
|
||||
var decode = jsonDecode(res);
|
||||
if (decode['status'] == 'success') {
|
||||
streakCount = decode['message']['streak_count'] ?? 0;
|
||||
isZeroCommissionActive = decode['message']['is_zero_commission_active'] ?? false;
|
||||
isZeroCommissionActive =
|
||||
decode['message']['is_zero_commission_active'] ?? false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user