mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 23:27:56 +00:00
fixes
This commit is contained in:
@@ -376,40 +376,31 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
void _groupAllOn(GroupAllOnEvent event, Emitter<TwoGangState> emit) async {
|
void _groupAllOn(GroupAllOnEvent event, Emitter<TwoGangState> emit) async {
|
||||||
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
|
||||||
for (int i = 0; i < groupTwoGangList.length; i++) {
|
for (int i = 0; i < groupTwoGangList.length; i++) {
|
||||||
groupTwoGangList[i].firstSwitch = true;
|
groupTwoGangList[i].firstSwitch = true;
|
||||||
groupTwoGangList[i].secondSwitch = true;
|
groupTwoGangList[i].secondSwitch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the state with updated values
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: true));
|
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: true));
|
||||||
|
|
||||||
// Get a list of all device IDs
|
|
||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupTwoGangList.map((device) => device.deviceId).toList();
|
groupTwoGangList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
// First call for switch_1
|
|
||||||
final response1 = await DevicesAPI.deviceController(
|
final response1 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_1', // Controls first switch for all devices
|
code: 'switch_1',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Second call for switch_2
|
|
||||||
final response2 = await DevicesAPI.deviceController(
|
final response2 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_2', // Controls second switch for all devices
|
code: 'switch_2',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if either response is unsuccessful, then reset to initial state
|
|
||||||
if (!response1['success'] || !response2['success']) {
|
if (!response1['success'] || !response2['success']) {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(const InitialEvent(groupScreen: true));
|
add(const InitialEvent(groupScreen: true));
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// In case of an error, delay and reset the screen to initial state
|
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(const InitialEvent(groupScreen: true));
|
add(const InitialEvent(groupScreen: true));
|
||||||
}
|
}
|
||||||
@@ -418,40 +409,33 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
void _groupAllOff(GroupAllOffEvent event, Emitter<TwoGangState> emit) async {
|
void _groupAllOff(GroupAllOffEvent event, Emitter<TwoGangState> emit) async {
|
||||||
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
|
||||||
for (int i = 0; i < groupTwoGangList.length; i++) {
|
for (int i = 0; i < groupTwoGangList.length; i++) {
|
||||||
groupTwoGangList[i].firstSwitch = false;
|
groupTwoGangList[i].firstSwitch = false;
|
||||||
groupTwoGangList[i].secondSwitch = false;
|
groupTwoGangList[i].secondSwitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the state with updated values
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: false));
|
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: false));
|
||||||
|
|
||||||
// Get a list of all device IDs
|
|
||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupTwoGangList.map((device) => device.deviceId).toList();
|
groupTwoGangList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
// First call for switch_1
|
|
||||||
final response1 = await DevicesAPI.deviceController(
|
final response1 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_1', // Controls first switch for all devices
|
code: 'switch_1',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Second call for switch_2
|
|
||||||
final response2 = await DevicesAPI.deviceController(
|
final response2 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_2', // Controls second switch for all devices
|
code: 'switch_2',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if either response is unsuccessful, then reset to initial state
|
|
||||||
if (!response1['success'] || !response2['success']) {
|
if (!response1['success'] || !response2['success']) {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(const InitialEvent(groupScreen: true));
|
add(const InitialEvent(groupScreen: true));
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// In case of an error, delay and reset the screen to initial state
|
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(const InitialEvent(groupScreen: true));
|
add(const InitialEvent(groupScreen: true));
|
||||||
}
|
}
|
||||||
@@ -767,6 +751,4 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
add(InitialEvent(groupScreen: twoGangGroup));
|
add(InitialEvent(groupScreen: twoGangGroup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,7 +360,6 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<DeviceModel> devicesList = [];
|
|
||||||
List<GroupWHModel> groupTwoGangList = [];
|
List<GroupWHModel> groupTwoGangList = [];
|
||||||
bool allSwitchesOn = true;
|
bool allSwitchesOn = true;
|
||||||
|
|
||||||
@@ -438,39 +437,32 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
|||||||
GroupAllOnEvent event, Emitter<WaterHeaterState> emit) async {
|
GroupAllOnEvent event, Emitter<WaterHeaterState> emit) async {
|
||||||
emit(LoadingNewSate(whModel: deviceStatus));
|
emit(LoadingNewSate(whModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
|
||||||
for (int i = 0; i < groupTwoGangList.length; i++) {
|
for (int i = 0; i < groupTwoGangList.length; i++) {
|
||||||
groupTwoGangList[i].firstSwitch = true;
|
groupTwoGangList[i].firstSwitch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the state with updated values
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: true));
|
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: true));
|
||||||
|
|
||||||
// Get a list of all device IDs
|
|
||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupTwoGangList.map((device) => device.deviceId).toList();
|
groupTwoGangList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
// First call for switch_1
|
|
||||||
final response1 = await DevicesAPI.deviceController(
|
final response1 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_1', // Controls first switch for all devices
|
code: 'switch_1',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Second call for switch_2
|
|
||||||
final response2 = await DevicesAPI.deviceController(
|
final response2 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_2', // Controls second switch for all devices
|
code: 'switch_2',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if either response is unsuccessful, then reset to initial state
|
|
||||||
if (!response1['success'] || !response2['success']) {
|
if (!response1['success'] || !response2['success']) {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(InitialWizardEvent());
|
add(InitialWizardEvent());
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// In case of an error, delay and reset the screen to initial state
|
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(InitialWizardEvent());
|
add(InitialWizardEvent());
|
||||||
}
|
}
|
||||||
@@ -480,39 +472,31 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
|||||||
GroupAllOffEvent event, Emitter<WaterHeaterState> emit) async {
|
GroupAllOffEvent event, Emitter<WaterHeaterState> emit) async {
|
||||||
emit(LoadingNewSate(whModel: deviceStatus));
|
emit(LoadingNewSate(whModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
|
||||||
for (int i = 0; i < groupTwoGangList.length; i++) {
|
for (int i = 0; i < groupTwoGangList.length; i++) {
|
||||||
groupTwoGangList[i].firstSwitch = false;
|
groupTwoGangList[i].firstSwitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the state with updated values
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: false));
|
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: false));
|
||||||
|
|
||||||
// Get a list of all device IDs
|
|
||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupTwoGangList.map((device) => device.deviceId).toList();
|
groupTwoGangList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
// First call for switch_1
|
|
||||||
final response1 = await DevicesAPI.deviceController(
|
final response1 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_1', // Controls first switch for all devices
|
code: 'switch_1',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Second call for switch_2
|
|
||||||
final response2 = await DevicesAPI.deviceController(
|
final response2 = await DevicesAPI.deviceController(
|
||||||
code: 'switch_2', // Controls second switch for all devices
|
code: 'switch_2',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: true, // true (on) or false (off) depending on the event value
|
value: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if either response is unsuccessful, then reset to initial state
|
|
||||||
if (!response1['success'] || !response2['success']) {
|
if (!response1['success'] || !response2['success']) {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(InitialWizardEvent());
|
add(InitialWizardEvent());
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// In case of an error, delay and reset the screen to initial state
|
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(InitialWizardEvent());
|
add(InitialWizardEvent());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user