mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 22:57:56 +00:00
push autoamtion api connect
This commit is contained in:
@@ -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)));
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user