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