import 'package:equatable/equatable.dart';
import 'package:krow_domain/krow_domain.dart';
import 'package:geolocator/geolocator.dart';


enum ClockInStatus { initial, loading, success, failure, actionInProgress }

class ClockInState extends Equatable {

  const ClockInState({
    this.status = ClockInStatus.initial,
    this.todayShifts = const <Shift>[],
    this.selectedShift,
    this.attendance = const AttendanceStatus(),
    required this.selectedDate,
    this.checkInMode = 'swipe',
    this.errorMessage,
    this.currentLocation,
    this.distanceFromVenue,
    this.isLocationVerified = false,
    this.isCommuteModeOn = false,
    this.hasLocationConsent = false,
    this.etaMinutes,
  });
  final ClockInStatus status;
  final List<Shift> todayShifts;
  final Shift? selectedShift;
  final AttendanceStatus attendance;
  final DateTime selectedDate;
  final String checkInMode;
  final String? errorMessage;

  final Position? currentLocation;
  final double? distanceFromVenue;
  final bool isLocationVerified;
  final bool isCommuteModeOn;
  final bool hasLocationConsent;
  final int? etaMinutes;

  ClockInState copyWith({
    ClockInStatus? status,
    List<Shift>? todayShifts,
    Shift? selectedShift,
    AttendanceStatus? attendance,
    DateTime? selectedDate,
    String? checkInMode,
    String? errorMessage,
    Position? currentLocation,
    double? distanceFromVenue,
    bool? isLocationVerified,
    bool? isCommuteModeOn,
    bool? hasLocationConsent,
    int? etaMinutes,
  }) {
    return ClockInState(
      status: status ?? this.status,
      todayShifts: todayShifts ?? this.todayShifts,
      selectedShift: selectedShift ?? this.selectedShift,
      attendance: attendance ?? this.attendance,
      selectedDate: selectedDate ?? this.selectedDate,
      checkInMode: checkInMode ?? this.checkInMode,
      errorMessage: errorMessage,
      currentLocation: currentLocation ?? this.currentLocation,
      distanceFromVenue: distanceFromVenue ?? this.distanceFromVenue,
      isLocationVerified: isLocationVerified ?? this.isLocationVerified,
      isCommuteModeOn: isCommuteModeOn ?? this.isCommuteModeOn,
      hasLocationConsent: hasLocationConsent ?? this.hasLocationConsent,
      etaMinutes: etaMinutes ?? this.etaMinutes,
    );
  }

  @override
  List<Object?> get props => <Object?>[
        status,
        todayShifts,
        selectedShift,
        attendance,
        selectedDate,
        checkInMode,
        errorMessage,
        currentLocation,
        distanceFromVenue,
        isLocationVerified,
        isCommuteModeOn,
        hasLocationConsent,
        etaMinutes,
      ];
}
