import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_control.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_batch_status_view.dart';
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_status_view.dart';
import 'package:syncrow_web/pages/device_managment/curtain_module/view/curtain_module_batch.dart';
import 'package:syncrow_web/pages/device_managment/curtain_module/view/curtain_module_items.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_control_view.dart';
import 'package:syncrow_web/pages/device_managment/flush_mounted_presence_sensor/views/flush_mounted_presence_sensor_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/flush_mounted_presence_sensor/views/flush_mounted_presence_sensor_control_view.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/view/garage_door_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/view/garage_door_control_view.dart';
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_control_view.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/view/one_gang_glass_switch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_device_control.dart';
import 'package:syncrow_web/pages/device_managment/power_clamp/view/power_clamp_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/power_clamp/view/smart_power_device_control.dart';
import 'package:syncrow_web/pages/device_managment/sos/view/sos_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/sos/view/sos_device_control_view.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_device_control.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/two_gang_switch/view/wall_light_device_control.dart';
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/view/water_heater_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/view/water_heater_device_control.dart';
import 'package:syncrow_web/pages/device_managment/water_leak/view/water_leak_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/water_leak/view/water_leak_control_view.dart';

mixin RouteControlsBasedCode {
  Widget routeControlsWidgets({required AllDevicesModel device}) {
    switch (device.productType) {
      case '1G':
        return WallLightDeviceControl(
          deviceId: device.uuid!,
        );
      case '2G':
        return TwoGangDeviceControlView(
          deviceId: device.uuid!,
        );
      case '3G':
        return LivingRoomDeviceControlsView(
          deviceId: device.uuid!,
        );
      case '1GT':
        return OneGangGlassSwitchControlView(
          deviceId: device.uuid!,
        );
      case '2GT':
        return TwoGangGlassSwitchControlView(
          deviceId: device.uuid!,
        );
      case '3GT':
        return ThreeGangGlassSwitchControlView(
          deviceId: device.uuid!,
        );
      case 'GW':
        return GateWayControlsView(
          gatewayId: device.uuid!,
        );
      case 'DL':
        return DoorLockControlsView(device: device);
      case 'WPS':
        return WallSensorControlsView(device: device);
      case 'CPS':
        return CeilingSensorControlsView(
          device: device,
        );
      case 'CUR':
        return CurtainStatusControlsView(
          deviceId: device.uuid!,
        );
      case 'CUR_2':
        return CurtainModuleItems(
          deviceId: device.uuid!,
        );
      case 'AC':
        return AcDeviceControlsView(device: device);
      case 'WH':
        return WaterHeaterDeviceControlView(
          device: device,
        );
      case 'DS':
        return MainDoorSensorControlView(device: device);
      case 'GD':
        return GarageDoorControlView(
          deviceId: device.uuid!,
        );
      case 'WL':
        return WaterLeakView(
          deviceId: device.uuid!,
        );
      case 'PC':
        return SmartPowerDeviceControl(
          deviceId: device.uuid!,
        );
      case 'SOS':
        return SosDeviceControlsView(device: device);

      case 'NCPS':
        return FlushMountedPresenceSensorControlView(device: device);
      default:
        return const SizedBox();
    }
  }

  /*
  3G: 
  1G: 
  2G:
  GW: 
  DL: 
  WPS: 
  CPS:
  AC: 
  CUR:
  WH:
  DS:
  */

  Widget routeBatchControlsWidgets({required List<AllDevicesModel> devices}) {
    switch (devices.first.productType) {
      case '1G':
        return WallLightBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == '1G')
              .map((e) => e.uuid!)
              .toList(),
        );
      case '2G':
        return TwoGangBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == '2G')
              .map((e) => e.uuid!)
              .toList(),
        );
      case '3G':
        return LivingRoomBatchControlsView(
          deviceIds: devices
              .where((e) => e.productType == '3G')
              .map((e) => e.uuid!)
              .toList(),
        );
      case '1GT':
        return OneGangGlassSwitchBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == '1GT')
              .map((e) => e.uuid!)
              .toList(),
        );
      case '2GT':
        return TwoGangGlassSwitchBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == '2GT')
              .map((e) => e.uuid!)
              .toList(),
        );
      case '3GT':
        return ThreeGangGlassSwitchBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == '3GT')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'GW':
        return GatewayBatchControlView(
          gatewayIds: devices
              .where((e) => e.productType == 'GW')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'DL':
        return DoorLockBatchControlView(
            devicesIds: devices
                .where((e) => e.productType == 'DL')
                .map((e) => e.uuid!)
                .toList());
      case 'WPS':
        return WallSensorBatchControlView(
            devicesIds: devices
                .where((e) => e.productType == 'WPS')
                .map((e) => e.uuid!)
                .toList());
      case 'CPS':
        return CeilingSensorBatchControlView(
          devicesIds: devices
              .where((e) => e.productType == 'CPS')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'CUR':
        return CurtainBatchStatusView(
          devicesIds: devices
              .where((e) => e.productType == 'CUR')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'CUR_2':
        return CurtainModuleBatchView(
          devicesIds: devices
              .where((e) => e.productType == 'CUR_2')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'AC':
        return AcDeviceBatchControlView(
            devicesIds: devices
                .where((e) => e.productType == 'AC')
                .map((e) => e.uuid!)
                .toList());
      case 'WH':
        return WaterHEaterBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == 'WH')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'DS':
        return MainDoorSensorBatchView(
          devicesIds: devices
              .where((e) => e.productType == 'DS')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'GD':
        return GarageDoorBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == 'GD')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'WL':
        return WaterLeakBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == 'WL')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'PC':
        return PowerClampBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == 'PC')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'SOS':
        return SOSBatchControlView(
          deviceIds: devices
              .where((e) => e.productType == 'SOS')
              .map((e) => e.uuid!)
              .toList(),
        );
      case 'NCPS':
        return FlushMountedPresenceSensorBatchControlView(
          devicesIds: devices
              .where((e) => e.productType == 'NCPS')
              .map((e) => e.uuid!)
              .toList(),
        );
      default:
        return const SizedBox();
    }
  }
}
