Bug fixes

This commit is contained in:
Abdullah Alassaf
2024-08-29 16:23:25 +03:00
parent 95b1e2c932
commit 6e183dba9f
28 changed files with 236 additions and 351 deletions

View File

@ -0,0 +1,56 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class LivingRoomStatusModel {
final String uuid;
final bool switch1;
final bool switch2;
final bool switch3;
LivingRoomStatusModel({
required this.uuid,
required this.switch1,
required this.switch2,
required this.switch3,
});
factory LivingRoomStatusModel.fromJson(String id, List<Status> jsonList) {
late bool switch1;
late bool switch2;
late bool switch3;
for (var status in jsonList) {
switch (status.code) {
case 'switch_1':
switch1 = status.value ?? false; // default to false if null
break;
case 'switch_2':
switch2 = status.value ?? false; // default to false if null
break;
case 'switch_3':
switch3 = status.value ?? false; // default to false if null
break;
}
}
return LivingRoomStatusModel(
uuid: id,
switch1: switch1,
switch2: switch2,
switch3: switch3,
);
}
LivingRoomStatusModel copyWith({
String? uuid,
bool? switch1,
bool? switch2,
bool? switch3,
}) {
return LivingRoomStatusModel(
uuid: uuid ?? this.uuid,
switch1: switch1 ?? this.switch1,
switch2: switch2 ?? this.switch2,
switch3: switch3 ?? this.switch3,
);
}
}