mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Bug fixes
This commit is contained in:
@ -1050,7 +1050,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
final automationDetails = await SceneApi.getAutomationDetails(event.automationId);
|
||||
|
||||
final Map<String, Map<String, dynamic>> deviceCards = {};
|
||||
final Map<String, Map<String, dynamic>> deviceIfCards = {};
|
||||
final Map<String, Map<String, dynamic>> deviceThenCards = {};
|
||||
|
||||
final Map<String, List<DeviceFunctionData>> updatedFunctions =
|
||||
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
||||
|
||||
@ -1066,8 +1068,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
final deviceId = condition.entityId;
|
||||
|
||||
if (!deviceCards.containsKey(deviceId)) {
|
||||
deviceCards[deviceId] = {
|
||||
if (!deviceIfCards.containsKey(deviceId)) {
|
||||
deviceIfCards[deviceId] = {
|
||||
'entityId': condition.entityId,
|
||||
'deviceId': condition.entityId,
|
||||
'uniqueCustomId': const Uuid().v4(),
|
||||
@ -1080,7 +1082,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
};
|
||||
}
|
||||
|
||||
final cardData = deviceCards[deviceId]!;
|
||||
final cardData = deviceIfCards[deviceId]!;
|
||||
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
||||
|
||||
if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
||||
@ -1117,8 +1119,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
final deviceId =
|
||||
action.actionExecutor == 'delay' ? '${action.entityId}_delay' : action.entityId;
|
||||
|
||||
if (!deviceCards.containsKey(deviceId)) {
|
||||
deviceCards[deviceId] = {
|
||||
if (!deviceThenCards.containsKey(deviceId)) {
|
||||
deviceThenCards[deviceId] = {
|
||||
'entityId': action.entityId,
|
||||
'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId,
|
||||
'uniqueCustomId': const Uuid().v4(),
|
||||
@ -1143,7 +1145,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
};
|
||||
}
|
||||
|
||||
final cardData = deviceCards[deviceId]!;
|
||||
final cardData = deviceThenCards[deviceId]!;
|
||||
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
||||
|
||||
if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
||||
@ -1192,8 +1194,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}
|
||||
}
|
||||
|
||||
final ifItems = deviceCards.values.where((card) => card['type'] == 'condition').toList();
|
||||
final thenItems = deviceCards.values
|
||||
final ifItems = deviceIfCards.values.where((card) => card['type'] == 'condition').toList();
|
||||
final thenItems = deviceThenCards.values
|
||||
.where((card) =>
|
||||
card['type'] == 'action' || card['type'] == 'automation' || card['type'] == 'scene')
|
||||
.toList();
|
||||
|
@ -26,9 +26,7 @@ class ThenContainer extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('THEN',
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const Text('THEN', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
state.isLoading && state.isUpdate == true
|
||||
? const Center(
|
||||
@ -41,17 +39,12 @@ class ThenContainer extends StatelessWidget {
|
||||
state.thenItems.length,
|
||||
(index) => GestureDetector(
|
||||
onTap: () async {
|
||||
if (state.thenItems[index]
|
||||
['deviceId'] ==
|
||||
'delay') {
|
||||
final result = await DelayHelper
|
||||
.showDelayPickerDialog(context,
|
||||
state.thenItems[index]);
|
||||
if (state.thenItems[index]['deviceId'] == 'delay') {
|
||||
final result = await DelayHelper.showDelayPickerDialog(
|
||||
context, state.thenItems[index]);
|
||||
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer({
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
...state.thenItems[index],
|
||||
'imagePath': Assets.delay,
|
||||
'title': 'Delay',
|
||||
@ -60,79 +53,58 @@ class ThenContainer extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.thenItems[index]['type'] ==
|
||||
'automation') {
|
||||
if (state.thenItems[index]['type'] == 'automation') {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
AutomationDialog(
|
||||
builder: (BuildContext context) => AutomationDialog(
|
||||
automationName:
|
||||
state.thenItems[index]
|
||||
['name'] ??
|
||||
'Automation',
|
||||
state.thenItems[index]['name'] ?? 'Automation',
|
||||
automationId:
|
||||
state.thenItems[index]
|
||||
['deviceId'] ??
|
||||
'',
|
||||
uniqueCustomId:
|
||||
state.thenItems[index]
|
||||
['uniqueCustomId'],
|
||||
state.thenItems[index]['deviceId'] ?? '',
|
||||
uniqueCustomId: state.thenItems[index]
|
||||
['uniqueCustomId'],
|
||||
),
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer({
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
...state.thenItems[index],
|
||||
'imagePath':
|
||||
Assets.automation,
|
||||
'title':
|
||||
state.thenItems[index]
|
||||
['name'] ??
|
||||
state.thenItems[index]
|
||||
['title'],
|
||||
'imagePath': Assets.automation,
|
||||
'title': state.thenItems[index]['name'] ??
|
||||
state.thenItems[index]['title'],
|
||||
}));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await DeviceDialogHelper
|
||||
.showDeviceDialog(
|
||||
context, state.thenItems[index],
|
||||
removeComparetors: true);
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
context, state.thenItems[index],
|
||||
removeComparetors: true);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToThenContainer(
|
||||
state.thenItems[index]));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer(state.thenItems[index]));
|
||||
} else if (!['AC', '1G', '2G', '3G']
|
||||
.contains(state.thenItems[index]
|
||||
['productType'])) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToThenContainer(
|
||||
state.thenItems[index]));
|
||||
.contains(state.thenItems[index]['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer(state.thenItems[index]));
|
||||
}
|
||||
},
|
||||
child: DraggableCard(
|
||||
imagePath: state.thenItems[index]
|
||||
['imagePath'] ??
|
||||
'',
|
||||
title: state.thenItems[index]
|
||||
['title'] ??
|
||||
'',
|
||||
imagePath: state.thenItems[index]['imagePath'] ?? '',
|
||||
title: state.thenItems[index]['title'] ?? '',
|
||||
deviceData: state.thenItems[index],
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4, vertical: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||
isFromThen: true,
|
||||
isFromIf: false,
|
||||
onRemove: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: true,
|
||||
key: state.thenItems[index]
|
||||
['uniqueCustomId']));
|
||||
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: true,
|
||||
key: state.thenItems[index]['uniqueCustomId']));
|
||||
},
|
||||
),
|
||||
))),
|
||||
@ -151,9 +123,14 @@ class ThenContainer extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.automationId == mutableData['deviceId'] ||
|
||||
state.sceneId == mutableData['deviceId']) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutableData['type'] == 'automation') {
|
||||
int index = state.thenItems.indexWhere(
|
||||
(item) => item['deviceId'] == mutableData['deviceId']);
|
||||
int index =
|
||||
state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
|
||||
if (index != -1) {
|
||||
return;
|
||||
}
|
||||
@ -178,8 +155,8 @@ class ThenContainer extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (mutableData['type'] == 'tap_to_run' && state.isAutomation) {
|
||||
int index = state.thenItems.indexWhere(
|
||||
(item) => item['deviceId'] == mutableData['deviceId']);
|
||||
int index =
|
||||
state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
|
||||
if (index != -1) {
|
||||
return;
|
||||
}
|
||||
@ -197,8 +174,7 @@ class ThenContainer extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (mutableData['deviceId'] == 'delay') {
|
||||
final result =
|
||||
await DelayHelper.showDelayPickerDialog(context, mutableData);
|
||||
final result = await DelayHelper.showDelayPickerDialog(context, mutableData);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
@ -210,13 +186,11 @@ class ThenContainer extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
context, mutableData,
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData,
|
||||
removeComparetors: true);
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
} else if (!['AC', '1G', '2G', '3G']
|
||||
.contains(mutableData['productType'])) {
|
||||
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user