import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:krow/core/application/di/injectable.dart';
import 'package:krow/core/sevices/geofencing_serivce.dart';
import 'package:krow/features/shifts/domain/shift_entity.dart';
import 'package:krow/features/shifts/domain/shifts_repository.dart';


StreamSubscription? geofencingClockOutStream;

@singleton
class ForceClockoutService {
  final GeofencingService geofencingService;

  ForceClockoutService(this.geofencingService);

  startTrackOngoingLocation(ShiftEntity shift, VoidCallback? onClockOut) {
    // if (geofencingClockOutStream != null) {
    //   geofencingClockOutStream?.cancel();
    // }
    //
    // geofencingClockOutStream = geofencingService
    //     .isInRangeStream(
    //         pointLatitude: shift.locationLat, pointLongitude: shift.locationLon)
    //     .listen(
    //   (isInRange) async {
    //     if (!isInRange) {
    //       await getIt<ShiftsRepository>().forceClockOut(shift.id);
    //       onClockOut?.call();
    //       geofencingClockOutStream?.cancel();
    //     }
    //   },
    // );
  }
}
