import 'package:equatable/equatable.dart';
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/function_model.dart';

class DeviceManagerState extends Equatable {
  final bool loading;
  final String? error;
  final List<DevicesCategoryModel>? allCategories;
  final List<DeviceModel>? devices;
  final bool categoryChanged;
  final bool deviceSelected;
  final bool functionsLoading;
  final FunctionModel? deviceFunctions;

  const DeviceManagerState({
    required this.loading,
    this.error,
    this.allCategories,
    this.devices,
    this.categoryChanged = false,
    this.deviceSelected = false,
    this.functionsLoading = false,
    this.deviceFunctions,
  });

  factory DeviceManagerState.initial() {
    return const DeviceManagerState(
      loading: false,
      error: null,
      allCategories: null,
      devices: null,
      categoryChanged: false,
      deviceSelected: false,
      functionsLoading: false,
      deviceFunctions: null,
    );
  }

  DeviceManagerState copyWith({
    bool? loading,
    String? error,
    List<DevicesCategoryModel>? allCategories,
    List<DeviceModel>? devices,
    bool? categoryChanged,
    bool? deviceSelected,
    bool? functionsLoading,
    FunctionModel? deviceFunctions,
  }) {
    return DeviceManagerState(
      loading: loading ?? this.loading,
      error: error ?? this.error,
      allCategories: allCategories ?? this.allCategories,
      devices: devices ?? this.devices,
      categoryChanged: categoryChanged ?? this.categoryChanged,
      deviceSelected: deviceSelected ?? this.deviceSelected,
      functionsLoading: functionsLoading ?? this.functionsLoading,
      deviceFunctions: deviceFunctions ?? this.deviceFunctions,
    );
  }

  @override
  List<Object?> get props => [
        loading,
        error,
        allCategories,
        devices,
        categoryChanged,
        deviceSelected,
        functionsLoading,
        deviceFunctions,
      ];
}
