import 'package:syncrow_app/features/devices/model/status_model.dart';

class SixSceneModel {
  dynamic scene_1;
  dynamic scene_2;
  dynamic scene_3;
  dynamic scene_4;
  dynamic scene_5;
  dynamic scene_6;
  dynamic scene_id_group_id;
  dynamic switch_backlight;

  SixSceneModel({
    required this.scene_1,
    required this.scene_2,
    required this.scene_3,
    required this.scene_4,
    required this.scene_5,
    required this.scene_6,
    required this.scene_id_group_id,
    required this.switch_backlight,
  });

  factory SixSceneModel.fromJson(List<StatusModel> jsonList) {
    dynamic _scene_1 = '';
    dynamic _scene_2 = '';
    dynamic _scene_3 = '';
    dynamic _scene_4 = '';
    dynamic _scene_5 = '';
    dynamic _scene_6 = '';
    dynamic _scene_id_group_id = 0;
    dynamic _switch_backlight = false;

    for (int i = 0; i < jsonList.length; i++) {
      if (jsonList[i].code == 'scene_1') {
        _scene_1 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_2') {
        _scene_2 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_3') {
        _scene_3 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_4') {
        _scene_4 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_5') {
        _scene_5 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_6') {
        _scene_6 = jsonList[i].value ?? '';
      } else if (jsonList[i].code == 'scene_id_group_id') {
        _scene_id_group_id = jsonList[i].value ?? 0;
      } else if (jsonList[i].code == 'switch_backlight') {
        _switch_backlight = jsonList[i].value ?? false;
      }
    }
    return SixSceneModel(
      scene_1: _scene_1,
      scene_2: _scene_2,
      scene_3: _scene_3,
      scene_4: _scene_4,
      scene_5: _scene_5,
      scene_6: _scene_6,
      scene_id_group_id: _scene_id_group_id,
      switch_backlight: _switch_backlight,
    );
  }
}
