part of 'event_details_bloc.dart';

enum GeofencingDialogState {
  none,
  tooFar,
  locationDisabled,
  goToSettings,
  permissionDenied,
}

@immutable
class EventDetailsState {
  final EventEntity event;
  final List<ShiftState> shifts;
  final bool inLoading;
  final bool isPreview;
  final String? showErrorPopup;
  final bool needDeepPop;
  final GeofencingDialogState geofencingDialogState;

  const EventDetailsState({
    required this.event,
    this.shifts = const [],
    this.inLoading = false,
    this.isPreview = false,
    this.needDeepPop = false,
    this.showErrorPopup,
    this.geofencingDialogState = GeofencingDialogState.none,
  });

  EventDetailsState copyWith({
    EventEntity? event,
    List<ShiftState>? shifts,
    bool? inLoading,
    bool? isPreview,
    bool? needDeepPop,
    String? showErrorPopup,
    GeofencingDialogState? geofencingDialogState,
  }) {
    return EventDetailsState(
      event: event ?? this.event,
      shifts: shifts ?? this.shifts,
      inLoading: inLoading ?? this.inLoading,
      isPreview: isPreview ?? this.isPreview,
      needDeepPop: needDeepPop ?? this.needDeepPop,
      showErrorPopup: showErrorPopup,
      geofencingDialogState:
          geofencingDialogState ?? GeofencingDialogState.none,
    );
  }
}

class ShiftState {
  final bool isExpanded;
  final ShiftEntity shift;
  final List<PositionState> positions;

  ShiftState({
    this.isExpanded = false,
    required this.shift,
    this.positions = const [],
  });

  ShiftState copyWith({
    bool? isExpanded,
    ShiftEntity? shift,
    List<PositionState>? positions,
    DateTime? date,
  }) {
    return ShiftState(
      isExpanded: isExpanded ?? this.isExpanded,
      shift: shift ?? this.shift,
      positions: positions ?? this.positions,
    );
  }
}

class PositionState {
  final PositionEntity position;
  final bool isExpanded;
  final bool isStaffExpanded;

  PositionState(
      {required this.position,
      this.isExpanded = false,
      this.isStaffExpanded = false});

  PositionState copyWith({
    PositionEntity? position,
    bool? isExpanded,
    bool? isStaffExpanded,
  }) {
    return PositionState(
      position: position ?? this.position,
      isExpanded: isExpanded ?? this.isExpanded,
      isStaffExpanded: isStaffExpanded ?? this.isStaffExpanded,
    );
  }
}
