mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 01:34:55 +00:00
Refactor UI structure in curtain and light widgets
Simplify UI structure in curtain_view.dart and light_interface.dart by rearranging the widget tree for better readability and maintainability.
This commit is contained in:
@ -24,7 +24,6 @@ part 'devices_state.dart';
|
||||
|
||||
class DevicesCubit extends Cubit<DevicesState> {
|
||||
DevicesCubit._() : super(DevicesInitial()) {
|
||||
print('device cubit created');
|
||||
if (HomeCubit.getInstance().selectedSpace != null) {
|
||||
fetchGroups(HomeCubit.getInstance().selectedSpace!.id!);
|
||||
for (var room in HomeCubit.getInstance().selectedSpace!.rooms!) {
|
||||
@ -256,20 +255,21 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
code: control.code,
|
||||
));
|
||||
try {
|
||||
await DevicesAPI.controlDevice(control).then((value) {
|
||||
await DevicesAPI.controlDevice(control).then((response) {
|
||||
emitSafe(DeviceControlSuccess(
|
||||
code: control.code,
|
||||
));
|
||||
if (value['result'] ?? false) {
|
||||
if (response['success'] ?? false) {
|
||||
Future.delayed(const Duration(milliseconds: 400), () {
|
||||
getDevicesStatues(
|
||||
deviceId,
|
||||
HomeCubit.getInstance().selectedSpace!.rooms!.indexOf(
|
||||
HomeCubit.getInstance().selectedRoom!,
|
||||
),
|
||||
code: control.code,
|
||||
);
|
||||
deviceId,
|
||||
HomeCubit.getInstance().selectedSpace!.rooms!.indexOf(
|
||||
HomeCubit.getInstance().selectedRoom!,
|
||||
),
|
||||
code: control.code);
|
||||
});
|
||||
} else {
|
||||
emitSafe(DeviceControlError('Failed to control the device'));
|
||||
}
|
||||
});
|
||||
} on DioException catch (e) {
|
||||
@ -291,8 +291,9 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
}
|
||||
}
|
||||
|
||||
fetchDevicesByRoomId(int roomId) async {
|
||||
fetchDevicesByRoomId(int? roomId) async {
|
||||
if (_isClosed) return;
|
||||
if (roomId == null) return;
|
||||
|
||||
try {
|
||||
emitSafe(GetDevicesLoading());
|
||||
|
||||
Reference in New Issue
Block a user