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

/// Base class for all client hubs events.
abstract class ClientHubsEvent extends Equatable {
  const ClientHubsEvent();

  @override
  List<Object?> get props => <Object?>[];
}

/// Event triggered to fetch the list of hubs.
class ClientHubsFetched extends ClientHubsEvent {
  const ClientHubsFetched();
}

/// Event triggered to add a new hub.
class ClientHubsAddRequested extends ClientHubsEvent {

  const ClientHubsAddRequested({
    required this.name,
    required this.address,
    this.placeId,
    this.latitude,
    this.longitude,
    this.city,
    this.state,
    this.street,
    this.country,
    this.zipCode,
  });
  final String name;
  final String address;
  final String? placeId;
  final double? latitude;
  final double? longitude;
  final String? city;
  final String? state;
  final String? street;
  final String? country;
  final String? zipCode;

  @override
  List<Object?> get props => <Object?>[
    name,
    address,
    placeId,
    latitude,
    longitude,
    city,
    state,
    street,
    country,
    zipCode,
  ];
}

/// Event triggered to delete a hub.
class ClientHubsDeleteRequested extends ClientHubsEvent {

  const ClientHubsDeleteRequested(this.hubId);
  final String hubId;

  @override
  List<Object?> get props => <Object?>[hubId];
}

/// Event triggered to assign an NFC tag to a hub.
class ClientHubsNfcTagAssignRequested extends ClientHubsEvent {

  const ClientHubsNfcTagAssignRequested({
    required this.hubId,
    required this.nfcTagId,
  });
  final String hubId;
  final String nfcTagId;

  @override
  List<Object?> get props => <Object?>[hubId, nfcTagId];
}

/// Event triggered to clear any error or success messages.
class ClientHubsMessageCleared extends ClientHubsEvent {
  const ClientHubsMessageCleared();
}

/// Event triggered to toggle the visibility of the "Add Hub" dialog.
class ClientHubsAddDialogToggled extends ClientHubsEvent {

  const ClientHubsAddDialogToggled({required this.visible});
  final bool visible;

  @override
  List<Object?> get props => <Object?>[visible];
}

/// Event triggered to toggle the visibility of the "Identify NFC" dialog.
class ClientHubsIdentifyDialogToggled extends ClientHubsEvent {

  const ClientHubsIdentifyDialogToggled({this.hub});
  final Hub? hub;

  @override
  List<Object?> get props => <Object?>[hub];
}
