Stabilized UI elements across multiple devices

Synchronized ACs Status functionality
This commit is contained in:
Mohammad Salameh
2024-02-28 12:22:45 +03:00
parent 4c27cce519
commit 3fabd41e72
63 changed files with 431 additions and 383 deletions
@@ -8,7 +8,7 @@ class DevicesCategoryModel {
final Widget page;
bool switchValue;
bool devicesStatus = false;
final List<ACModel> devices;
final DeviceType type;
@@ -20,8 +20,21 @@ class DevicesCategoryModel {
required this.type,
required this.name,
required this.icon,
required this.switchValue,
required this.devices});
required this.devices}) {
//sets the initial status of the devices
if (devices.isNotEmpty) {
bool tempStatus = devices.first.status;
for (var device in devices) {
if (device.status != tempStatus) {
devicesStatus = false;
break;
}
}
devicesStatus = tempStatus;
} else {
devicesStatus = false;
}
}
}
enum DeviceType {