water leak

This commit is contained in:
mohammad
2024-10-07 16:53:50 +03:00
parent 1f904e107a
commit 754d869fac
15 changed files with 1111 additions and 81 deletions
+3 -2
View File
@@ -74,8 +74,9 @@ class DeviceModel {
tempIcon = Assets.garageIcon;
} else if (type == DeviceType.ThreeTouch) {
tempIcon = Assets.assetsIcons3GangSwitch;
}
else {
} else if (type == DeviceType.WaterLeak) {
tempIcon = Assets.waterLeakIcon;
} else {
tempIcon = Assets.assetsIconsLogo;
}
@@ -0,0 +1,28 @@
import 'package:syncrow_app/features/devices/model/status_model.dart';
class WaterLeakModel {
bool waterContactState;
int batteryPercentage;
WaterLeakModel({
required this.waterContactState,
required this.batteryPercentage,
});
factory WaterLeakModel.fromJson(List<StatusModel> jsonList) {
late bool _waterContactState;
late int _batteryPercentage;
for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'watersensor_state') {
_waterContactState = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'battery_percentage') {
_batteryPercentage = jsonList[i].value ?? 0;
}
}
return WaterLeakModel(
waterContactState: _waterContactState,
batteryPercentage: _batteryPercentage,
);
}
}