mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
94 lines
3.1 KiB
Dart
94 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
|
|
|
class AutomationDialog extends StatefulWidget {
|
|
final String automationName;
|
|
final String automationId;
|
|
|
|
const AutomationDialog({
|
|
Key? key,
|
|
required this.automationName,
|
|
required this.automationId,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_AutomationDialogState createState() => _AutomationDialogState();
|
|
}
|
|
|
|
class _AutomationDialogState extends State<AutomationDialog> {
|
|
bool _isEnabled = true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
child: Container(
|
|
width: 400,
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
DialogHeader(widget.automationName),
|
|
const SizedBox(height: 16),
|
|
ListTile(
|
|
leading: SvgPicture.asset(Assets.acPower, width: 24, height: 24),
|
|
title: const Text('Enable'),
|
|
trailing: Radio<bool>(
|
|
value: true,
|
|
groupValue: _isEnabled,
|
|
onChanged: (bool? value) {
|
|
setState(() {
|
|
_isEnabled = value!;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
ListTile(
|
|
leading:
|
|
SvgPicture.asset(Assets.acPowerOff, width: 24, height: 24),
|
|
title: const Text('Disable'),
|
|
trailing: Radio<bool>(
|
|
value: false,
|
|
groupValue: _isEnabled,
|
|
onChanged: (bool? value) {
|
|
setState(() {
|
|
_isEnabled = value!;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
DialogFooter(
|
|
onConfirm: () {
|
|
context.read<RoutineBloc>().add(
|
|
AddFunctionToRoutine(
|
|
[
|
|
DeviceFunctionData(
|
|
entityId: widget.automationId,
|
|
functionCode: '',
|
|
value: _isEnabled,
|
|
operationName: 'Automation',
|
|
),
|
|
],
|
|
widget.automationId,
|
|
),
|
|
);
|
|
Navigator.of(context).pop(true);
|
|
},
|
|
onCancel: () => Navigator.of(context).pop(false),
|
|
isConfirmEnabled: true,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|