four_scene

This commit is contained in:
mohammad
2024-11-19 15:56:53 +03:00
parent 777bd549ca
commit 4b0270a70d
2 changed files with 9 additions and 11 deletions

View File

@ -109,7 +109,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
emit(FourSceneLoadingState());
var response = await DevicesAPI.putDeviceName(
deviceId: fourSceneId, deviceName: nameController.text);
add(FourSceneInitialInfo());
add(const FourSceneInitialInfo());
CustomSnackBar.displaySnackBar('Save Successfully');
emit(SaveState());
} catch (e) {
@ -128,12 +128,10 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
List<dynamic> response = await DevicesAPI.getFourSceneInfo(fourSceneId);
fourScene =
response.map((item) => FourSceneSwitchModel.fromJson(item)).toList();
print('Fetched response: $fourScene');
_rankFourSceneSwitches();
emit(UpdateState(device: deviceStatus));
} catch (e) {
print('Error in _fetchFourSceneSwitches: $e');
emit(FourSceneFailedState(errorMessage: e.toString()));
}
}

View File

@ -78,17 +78,17 @@ class FourSceneScreen extends StatelessWidget {
children: [
FourSwitchsCard(
title1: _bloc.fourScene.isNotEmpty
? _bloc.fourScene[0].switchName
: 'title1',
? _bloc.fourScene[0].scene.name
: '',
title2: _bloc.fourScene.length > 1
? _bloc.fourScene[1].switchName
: 'title2',
? _bloc.fourScene[0].scene.name
: '',
title3: _bloc.fourScene.length > 2
? _bloc.fourScene[2].switchName
: 'title3',
? _bloc.fourScene[0].scene.name
: '',
title4: _bloc.fourScene.length > 3
? _bloc.fourScene[3].switchName
: 'title4',
? _bloc.fourScene[0].scene.name
: '',
switch1:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn