import 'dart:io';
import 'package:flutter/services.dart';

class RideTrackingNative {
  static const MethodChannel _channel = MethodChannel('siro/ride_tracking');

  static Future<void> updateRideTracking({
    required String driverName,
    String driverPhone = '',
    required String carDetails,
    required double driverLat,
    required double driverLng,
    required double passengerLat,
    required double passengerLng,
    required double destLat,
    required double destLng,
    required String rideState, // "waiting" أو "inProgress"
    required int estimatedTimeMinutes,
    required double totalDistanceMeters,
  }) async {
    if (!Platform.isAndroid) return;

    await _channel.invokeMethod('updateRideTracking', {
      'driverName': driverName,
      'driverPhone': driverPhone,
      'carDetails': carDetails,
      'driverLat': driverLat,
      'driverLng': driverLng,
      'passengerLat': passengerLat,
      'passengerLng': passengerLng,
      'destLat': destLat,
      'destLng': destLng,
      'rideState': rideState,
      'estimatedTime': estimatedTimeMinutes,
      'totalDistance': totalDistanceMeters,
    });
  }

  static Future<void> stopRideTracking() async {
    if (!Platform.isAndroid) return;
    await _channel.invokeMethod('stopRideTracking');
  }
}
