part of 'emergency_contacts_bloc.dart';

@immutable
final class EmergencyContactsState {
  const EmergencyContactsState({
    this.contacts = const [],
    this.status = StateStatus.idle,
    this.isInEditMode = true,
    this.isListReducible = false,
  });

  final List<EmergencyContactModel> contacts;
  final StateStatus status;
  final bool isInEditMode;
  final bool isListReducible;

  bool get isFilled => contacts.indexWhere((contact) => !contact.isFilled) < 0;

  EmergencyContactsState copyWith({
    List<EmergencyContactModel>? contacts,
    StateStatus? status,
    bool? isInEditMode,
    bool? isListReducible,
  }) {
    return EmergencyContactsState(
      contacts: contacts ?? this.contacts,
      status: status ?? this.status,
      isInEditMode: isInEditMode ?? this.isInEditMode,
      isListReducible: isListReducible ?? this.isListReducible,
    );
  }
}
