push scene devices body with blocs. need to drop the future builder - enhancment

This commit is contained in:
ashrafzarkanisala
2024-06-13 02:13:44 +03:00
parent 4a93bc2892
commit a8132c37db
12 changed files with 253 additions and 13 deletions
+12 -5
View File
@@ -291,8 +291,10 @@ class DevicesCubit extends Cubit<DevicesState> {
if (roomId == null) return;
emitSafe(GetDevicesLoading());
int roomIndex =
HomeCubit.getInstance().selectedSpace!.rooms!.indexWhere((element) => element.id == roomId);
int roomIndex = HomeCubit.getInstance()
.selectedSpace!
.rooms!
.indexWhere((element) => element.id == roomId);
try {
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices =
await DevicesAPI.getDevicesByRoomId(roomId);
@@ -300,7 +302,9 @@ class DevicesCubit extends Cubit<DevicesState> {
emitSafe(GetDevicesError(e.toString()));
return;
}
emitSafe(GetDevicesSuccess());
final devices =
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices;
emitSafe(GetDevicesSuccess(devices));
//get status for each device
//TODO get devices status per page via page controller instead of getting all devices status at once
@@ -329,8 +333,11 @@ class DevicesCubit extends Cubit<DevicesState> {
emitSafe(GetDeviceStatusError(e.toString()));
return;
}
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices![deviceIndex].status =
statuses;
HomeCubit.getInstance()
.selectedSpace!
.rooms![roomIndex]
.devices![deviceIndex]
.status = statuses;
emitSafe(GetDeviceStatusSuccess(code: code));
}
+4 -1
View File
@@ -35,7 +35,10 @@ class GetDeviceStatusError extends DevicesState {
class GetDevicesLoading extends DevicesState {}
class GetDevicesSuccess extends DevicesState {}
class GetDevicesSuccess extends DevicesState {
GetDevicesSuccess(this.devices);
final List<DeviceModel>? devices;
}
class GetDevicesError extends DevicesState {
final String errorMsg;