Update: 2026-07-12 06:04:42

This commit is contained in:
Hamza-Ayed
2026-07-12 06:04:42 +03:00
parent 1f68cb7333
commit 08340493c0
4 changed files with 85 additions and 90 deletions
@@ -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();
}
}
@@ -103,7 +103,7 @@ class NavigationView extends StatelessWidget {
),
// ── 11. Navigation Icon (Fixed Center) ────────────────────────
if (c.isNavigating) const _NavigationCenterIcon(),
// Removed _NavigationCenterIcon as per user request
],
),
),
@@ -134,43 +134,7 @@ class NavigationView extends StatelessWidget {
}
}
class _NavigationCenterIcon extends StatelessWidget {
const _NavigationCenterIcon({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return IgnorePointer(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: _kPrimary,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
border: Border.all(color: Colors.white, width: 3),
),
padding: const EdgeInsets.all(12),
child: const Icon(
Icons.navigation_rounded,
color: Colors.white,
size: 32,
),
),
const SizedBox(height: 40),
],
),
),
);
}
}
// _NavigationCenterIcon removed
class _ExploreTopUI extends StatelessWidget {
final NavigationController controller;
@@ -209,13 +209,16 @@ class _HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
children: [
_LogoBadge(),
const SizedBox(width: 10),
Text(
AppInformation.appName.split(' ')[0].tr,
style: const TextStyle(
color: _Token.accent,
fontSize: 20,
fontWeight: FontWeight.w800,
letterSpacing: 0.8,
Expanded(
child: Text(
AppInformation.appName.split(' ')[0].tr,
style: const TextStyle(
color: _Token.accent,
fontSize: 20,
fontWeight: FontWeight.w800,
letterSpacing: 0.8,
),
overflow: TextOverflow.ellipsis,
),
),
],
@@ -423,6 +426,7 @@ class _MapView extends StatelessWidget {
builder: (loc) => IntaleqMap(
apiKey: Env.mapSaasKey,
onMapCreated: ctrl.onMapCreated,
onStyleLoaded: ctrl.onStyleLoaded,
minMaxZoomPreference: const MinMaxZoomPreference(6, 18),
initialCameraPosition: CameraPosition(
target: (loc.myLocation.latitude == 0 ||
@@ -22,7 +22,7 @@ class TransitDriverHomePage extends StatelessWidget {
return MyScafolld(
title: 'Mawasalati'.tr,
isleading: true,
body: const [Expanded(child: Center(child: CircularProgressIndicator()))],
body: const [Column(children: [Expanded(child: Center(child: CircularProgressIndicator()))])],
);
}
@@ -31,17 +31,21 @@ class TransitDriverHomePage extends StatelessWidget {
title: 'Mawasalati'.tr,
isleading: true,
body: [
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
'This account is not registered as a bus driver in any institution'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
Column(
children: [
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
'This account is not registered as a bus driver in any institution'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
),
),
),
),
],
),
],
);
@@ -51,26 +55,30 @@ class TransitDriverHomePage extends StatelessWidget {
title: c.orgName,
isleading: true,
body: [
Expanded(
child: RefreshIndicator(
onRefresh: c.fetchTodayTrips,
child: c.isLoadingTrips
? const Center(child: CircularProgressIndicator())
: c.todayTrips.isEmpty
? ListView(
children: [
const SizedBox(height: 80),
Center(
child: Text('No trips today'.tr, style: AppStyle.title),
Column(
children: [
Expanded(
child: RefreshIndicator(
onRefresh: c.fetchTodayTrips,
child: c.isLoadingTrips
? const Center(child: CircularProgressIndicator())
: c.todayTrips.isEmpty
? ListView(
children: [
const SizedBox(height: 80),
Center(
child: Text('No trips today'.tr, style: AppStyle.title),
),
],
)
: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: c.todayTrips.length,
itemBuilder: (_, i) => _tripCard(c, c.todayTrips[i]),
),
],
)
: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: c.todayTrips.length,
itemBuilder: (_, i) => _tripCard(c, c.todayTrips[i]),
),
),
),
),
],
),
],
);