import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

enum RoomStatusTag { hasPerson, powerOn, wifiNormal }

class RoomDevice {
  final String name;
  final IconData icon;
  final bool isOn;
  final String? statusText;

  const RoomDevice({
    required this.name,
    required this.icon,
    this.isOn = false,
    this.statusText,
  });
}

class ControlDevice {
  final String name;
  final IconData icon;
  final bool isOn;
  final String? detailText;

  const ControlDevice({
    required this.name,
    required this.icon,
    this.isOn = false,
    this.detailText,
  });
}

class ServiceRoomState extends Equatable {
  final String roomNumber;
  final String roomStatus;
  final List<RoomStatusTag> statusTags;
  final List<RoomDevice> roomDevices;
  final bool mainPowerOn;
  final List<ControlDevice> controlDevices;

  const ServiceRoomState({
    this.roomNumber = '302',
    this.roomStatus = '入住中',
    this.statusTags = const [RoomStatusTag.hasPerson, RoomStatusTag.powerOn, RoomStatusTag.wifiNormal],
    this.roomDevices = const [],
    this.mainPowerOn = false,
    this.controlDevices = const [],
  });

  ServiceRoomState copyWith({
    String? roomNumber,
    String? roomStatus,
    List<RoomStatusTag>? statusTags,
    List<RoomDevice>? roomDevices,
    bool? mainPowerOn,
    List<ControlDevice>? controlDevices,
  }) {
    return ServiceRoomState(
      roomNumber: roomNumber ?? this.roomNumber,
      roomStatus: roomStatus ?? this.roomStatus,
      statusTags: statusTags ?? this.statusTags,
      roomDevices: roomDevices ?? this.roomDevices,
      mainPowerOn: mainPowerOn ?? this.mainPowerOn,
      controlDevices: controlDevices ?? this.controlDevices,
    );
  }

  @override
  List<Object?> get props => [
        roomNumber,
        roomStatus,
        statusTags,
        roomDevices,
        mainPowerOn,
        controlDevices,
      ];
}