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

class FourSceneModelState {
  dynamic scene_1;
  dynamic scene_2;
  dynamic scene_3;
  dynamic scene_4;
  dynamic scene_id_group_id;
  dynamic switch_backlight;

  FourSceneModelState({
    required this.scene_1,
    required this.scene_2,
    required this.scene_3,
    required this.scene_4,
    required this.scene_id_group_id,
    required this.switch_backlight,
  });

  factory FourSceneModelState.fromJson(List<StatusModel> jsonList) {
    late dynamic _scene_1;
    late dynamic _scene_2;
    late dynamic _scene_3;
    late dynamic _scene_4;
    late dynamic _scene_id_group_id;
    late dynamic _switch_backlight;

    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_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 FourSceneModelState(
      scene_1: _scene_1,
      scene_2: _scene_2,
      scene_3: _scene_3,
      scene_4: _scene_4,
      scene_id_group_id: _scene_id_group_id,
      switch_backlight: _switch_backlight,
    );
  }
}
