Update: 2026-07-04 17:02:24
This commit is contained in:
+3
@@ -25,6 +25,9 @@ object CarNavigationData {
|
||||
var isNavigating: Boolean = false
|
||||
var currentSpeed: Double = 0.0 // km/h
|
||||
|
||||
// --- إعدادات المظهر ---
|
||||
var isMapDarkMode: Boolean = false // true = dark (style_dark.json), false = light (style.json)
|
||||
|
||||
// --- نظام المستمعين ---
|
||||
private val listeners = mutableListOf<() -> Unit>()
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
CarNavigationData.estimatedTimeRemainingSeconds = call.argument<Double>("eta") ?: CarNavigationData.estimatedTimeRemainingSeconds
|
||||
CarNavigationData.maneuverType = call.argument<Int>("maneuver") ?: CarNavigationData.maneuverType
|
||||
CarNavigationData.isNavigating = call.argument<Boolean>("isNavigating") ?: CarNavigationData.isNavigating
|
||||
CarNavigationData.isMapDarkMode = call.argument<Boolean>("isMapDarkMode") ?: CarNavigationData.isMapDarkMode
|
||||
CarNavigationData.notifyListeners()
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
+21
-3
@@ -25,6 +25,21 @@ class MapPresentation(outerContext: Context, display: Display) : Presentation(ou
|
||||
|
||||
private val locationListener: () -> Unit = {
|
||||
updateCameraPosition()
|
||||
reloadStyleIfNeeded()
|
||||
}
|
||||
|
||||
private var currentStyleLoaded: String? = null
|
||||
|
||||
private fun reloadStyleIfNeeded() {
|
||||
val expectedStyle = if (CarNavigationData.isMapDarkMode)
|
||||
"asset://packages/intaleq_maps/assets/style_dark.json"
|
||||
else
|
||||
"asset://packages/intaleq_maps/assets/style.json"
|
||||
|
||||
if (currentStyleLoaded != expectedStyle && isMapReady) {
|
||||
currentStyleLoaded = expectedStyle
|
||||
mapboxMap?.setStyle(Style.Builder().fromUri(expectedStyle)) { isMapReady = true }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -51,9 +66,12 @@ class MapPresentation(outerContext: Context, display: Display) : Presentation(ou
|
||||
mapView.getMapAsync { map ->
|
||||
mapboxMap = map
|
||||
|
||||
// تحميل ستايل خرائط سيرو من أصول فلاتر
|
||||
val styleUrl = "asset://flutter_assets/assets/style.json"
|
||||
map.setStyle(Style.Builder().fromUri(styleUrl)) {
|
||||
// تحميل ستايل خرائط سيرو من حزمة intaleq_maps حسب الوضعية
|
||||
currentStyleLoaded = if (CarNavigationData.isMapDarkMode)
|
||||
"asset://packages/intaleq_maps/assets/style_dark.json"
|
||||
else
|
||||
"asset://packages/intaleq_maps/assets/style.json"
|
||||
map.setStyle(Style.Builder().fromUri(currentStyleLoaded)) {
|
||||
isMapReady = true
|
||||
updateCameraPosition()
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class CarPlatformBridge {
|
||||
required double eta,
|
||||
required int maneuver,
|
||||
required bool isNavigating,
|
||||
bool isMapDarkMode = false,
|
||||
}) async {
|
||||
try {
|
||||
await _channel.invokeMethod('updateNavState', {
|
||||
@@ -46,6 +47,7 @@ class CarPlatformBridge {
|
||||
'eta': eta,
|
||||
'maneuver': maneuver,
|
||||
'isNavigating': isNavigating,
|
||||
'isMapDarkMode': isMapDarkMode,
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
@@ -1347,6 +1347,7 @@ class NavigationController extends GetxController
|
||||
? currentManeuverModifier as int
|
||||
: int.tryParse(currentManeuverModifier.toString()) ?? 0,
|
||||
isNavigating: true,
|
||||
isMapDarkMode: box.read('isMapDarkMode') ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user