Refactor device status handling and update UI components

- Update device status handling from 'status' to 'isOnline' for consistency
- Remove unused imports and redundant code related to light switches
- Refactor UI components to use 'isOnline' instead of 'status' for device status
This commit is contained in:
Mohammad Salameh
2024-04-01 09:58:51 +03:00
parent 3031d19836
commit a20dfa3709
12 changed files with 152 additions and 545 deletions

View File

@ -19,7 +19,7 @@ class CustomSwitch extends StatelessWidget {
builder: (context, state) {
bool? status;
if (device != null) {
status = device!.status;
status = device!.isOnline;
} else if (category != null) {
status = category!.devicesStatus;
}

View File

@ -28,7 +28,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Container(
height: 60,
decoration: BoxDecoration(
color: model.status ?? false
color: model.isOnline ?? false
? ColorsManager.primaryColor
: Colors.white,
borderRadius: const BorderRadius.only(
@ -39,7 +39,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Center(
child: BodyMedium(
text: "ON",
fontColor: model.status ?? false ? Colors.white : null,
fontColor: model.isOnline ?? false ? Colors.white : null,
fontWeight: FontWeight.bold,
),
),
@ -54,7 +54,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Container(
height: 60,
decoration: BoxDecoration(
color: model.status ?? false
color: model.isOnline ?? false
? Colors.white
: ColorsManager.primaryColor,
borderRadius: const BorderRadius.only(
@ -65,7 +65,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Center(
child: BodyMedium(
text: "OFF",
fontColor: model.status ?? false ? null : Colors.white,
fontColor: model.isOnline ?? false ? null : Colors.white,
fontWeight: FontWeight.bold,
),
),