push autoamtion api connect

This commit is contained in:
ashrafzarkanisala
2024-07-24 01:41:10 +03:00
parent 9a088353e0
commit 7a773f1653
20 changed files with 874 additions and 272 deletions
@@ -24,7 +24,7 @@ class AlertDialogSliderSteps extends StatefulWidget {
class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
double? groupValue;
int selectedToggleIndex = 0;
int selectedToggleIndex = 1;
@override
void didChangeDependencies() {
@@ -33,23 +33,53 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
if (widget.isAutomation) {
final automationTempTaskList =
context.read<CreateSceneBloc>().automationTempTasksList;
final automationComparatorValues =
context.read<CreateSceneBloc>().automationComparatorValues;
if (automationTempTaskList.isNotEmpty) {
for (var element in automationTempTaskList) {
if (element.code == widget.taskItem.code) {
groupValue = element.functionValue;
} else {
context.read<CreateSceneBloc>().add(RemoveFromSelectedValueById(
code: widget.taskItem.code, isAutomation: widget.isAutomation));
selectedToggleIndex =
_comparatorToIndex(automationComparatorValues[element.code]);
}
}
}
if (widget.functionValue != null) {
setState(() {
groupValue = widget.functionValue;
});
groupValue = widget.functionValue;
} else {
groupValue = widget.taskItem.operationalValues[0].minValue;
}
if (widget.taskItem.comparator != null) {
selectedToggleIndex = _comparatorToIndex(widget.taskItem.comparator);
}
setState(() {});
}
}
int _comparatorToIndex(String? comparator) {
switch (comparator) {
case "<=":
return 0;
case "==":
return 1;
case ">=":
return 2;
default:
return 1;
}
}
String _indexToComparator(int index) {
switch (index) {
case 0:
return "<=";
case 1:
return "==";
case 2:
return ">=";
default:
return "==";
}
}
@@ -68,6 +98,10 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
setState(() {
selectedToggleIndex = index;
});
context.read<CreateSceneBloc>().add(SelectedValueEvent(
code: widget.taskItem.code,
isAutomation: widget.isAutomation,
comparator: _indexToComparator(selectedToggleIndex)));
},
borderRadius: BorderRadius.circular(30),
selectedColor: Colors.white,
@@ -164,7 +198,9 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
context.read<CreateSceneBloc>().add(SelectedValueEvent(
value: groupValue,
code: widget.taskItem.code,
isAutomation: widget.isAutomation));
isAutomation: widget.isAutomation,
comparator:
_indexToComparator(selectedToggleIndex)));
},
),
),