mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
rule_disable selected & CreateAutomation actionType
This commit is contained in:
@ -23,7 +23,7 @@ class AutomationDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, state) {
|
||||
final isEnabled = state.automationActionExecutor == 'rule_enable';
|
||||
final String? initialSelection = state.automationActionExecutor;
|
||||
|
||||
return Dialog(
|
||||
shape:
|
||||
@ -40,14 +40,14 @@ class AutomationDialog extends StatelessWidget {
|
||||
leading:
|
||||
SvgPicture.asset(Assets.acPower, width: 24, height: 24),
|
||||
title: const Text('Enable'),
|
||||
trailing: Radio<bool>(
|
||||
value: true,
|
||||
groupValue: isEnabled,
|
||||
onChanged: (bool? value) {
|
||||
if (value == true) {
|
||||
trailing: Radio<String?>(
|
||||
value: 'rule_enable',
|
||||
groupValue: initialSelection,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<RoutineBloc>().add(
|
||||
const SetAutomationActionExecutor(
|
||||
automationActionExecutor: 'rule_enable',
|
||||
SetAutomationActionExecutor(
|
||||
automationActionExecutor: value,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -58,14 +58,14 @@ class AutomationDialog extends StatelessWidget {
|
||||
leading: SvgPicture.asset(Assets.acPowerOff,
|
||||
width: 24, height: 24),
|
||||
title: const Text('Disable'),
|
||||
trailing: Radio<bool>(
|
||||
value: false,
|
||||
groupValue: isEnabled,
|
||||
onChanged: (bool? value) {
|
||||
if (value == false) {
|
||||
trailing: Radio<String?>(
|
||||
value: 'rule_disable',
|
||||
groupValue: initialSelection,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<RoutineBloc>().add(
|
||||
const SetAutomationActionExecutor(
|
||||
automationActionExecutor: 'rule_disable',
|
||||
SetAutomationActionExecutor(
|
||||
automationActionExecutor: value,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -75,23 +75,25 @@ class AutomationDialog extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
DialogFooter(
|
||||
onConfirm: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
[
|
||||
DeviceFunctionData(
|
||||
entityId: automationId,
|
||||
functionCode: 'automation',
|
||||
value: state.automationActionExecutor,
|
||||
operationName: 'Automation',
|
||||
),
|
||||
],
|
||||
uniqueCustomId,
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop(true);
|
||||
if (state.automationActionExecutor != null) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
[
|
||||
DeviceFunctionData(
|
||||
entityId: automationId,
|
||||
functionCode: 'automation',
|
||||
value: state.automationActionExecutor,
|
||||
operationName: 'Automation',
|
||||
),
|
||||
],
|
||||
uniqueCustomId,
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
onCancel: () => Navigator.of(context).pop(false),
|
||||
isConfirmEnabled: true,
|
||||
isConfirmEnabled: state.automationActionExecutor != null,
|
||||
dialogWidth: 400,
|
||||
),
|
||||
],
|
||||
|
Reference in New Issue
Block a user