Update: 2026-07-04 16:16:49
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class CarPlatformBridge {
|
||||
CarPlatformBridge._();
|
||||
|
||||
static const _channel = MethodChannel('com.siro.siro_driver/car_navigation');
|
||||
|
||||
static bool _isInitialized = false;
|
||||
|
||||
static void ensureInitialized() {
|
||||
if (_isInitialized) return;
|
||||
_channel.setMethodCallHandler(_handleMethodCall);
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
static Future<dynamic> _handleMethodCall(MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case 'isCarAppConnected':
|
||||
return false;
|
||||
default:
|
||||
throw MissingPluginException();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> updateNavState({
|
||||
required double lat,
|
||||
required double lng,
|
||||
required double bearing,
|
||||
required double speed,
|
||||
required String instruction,
|
||||
required double distanceToStep,
|
||||
required double totalDistance,
|
||||
required double eta,
|
||||
required int maneuver,
|
||||
required bool isNavigating,
|
||||
}) async {
|
||||
try {
|
||||
await _channel.invokeMethod('updateNavState', {
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
'bearing': bearing,
|
||||
'speed': speed,
|
||||
'instruction': instruction,
|
||||
'distanceToStep': distanceToStep,
|
||||
'totalDistance': totalDistance,
|
||||
'eta': eta,
|
||||
'maneuver': maneuver,
|
||||
'isNavigating': isNavigating,
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
static Future<void> updateLocation({
|
||||
required double lat,
|
||||
required double lng,
|
||||
required double bearing,
|
||||
required double speed,
|
||||
}) async {
|
||||
try {
|
||||
await _channel.invokeMethod('updateLocation', {
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
'bearing': bearing,
|
||||
'speed': speed,
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
static Future<void> updateInstruction({
|
||||
required String instruction,
|
||||
required int maneuver,
|
||||
required double distanceToStep,
|
||||
}) async {
|
||||
try {
|
||||
await _channel.invokeMethod('updateInstruction', {
|
||||
'instruction': instruction,
|
||||
'maneuver': maneuver,
|
||||
'distanceToStep': distanceToStep,
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
static Future<void> stopNavigation() async {
|
||||
try {
|
||||
await _channel.invokeMethod('stopNavigation');
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user