mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-26 23:44:54 +00:00
push schedules active enable api
This commit is contained in:
@ -10,7 +10,7 @@ import 'package:syncrow_web/utils/format_date_time.dart';
|
||||
|
||||
import '../helper/add_schedule_dialog_helper.dart';
|
||||
|
||||
class ScheduleTableWidget extends StatefulWidget {
|
||||
class ScheduleTableWidget extends StatelessWidget {
|
||||
final WaterHeaterDeviceStatusLoaded state;
|
||||
|
||||
const ScheduleTableWidget({
|
||||
@ -18,26 +18,6 @@ class ScheduleTableWidget extends StatefulWidget {
|
||||
required this.state,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ScheduleTableWidget> createState() => _ScheduleTableWidgetState();
|
||||
}
|
||||
|
||||
class _ScheduleTableWidgetState extends State<ScheduleTableWidget> {
|
||||
late Map<int, bool> _enabledStates;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeEnabledStates();
|
||||
}
|
||||
|
||||
void _initializeEnabledStates() {
|
||||
_enabledStates = {
|
||||
for (int i = 0; i < widget.state.schedules.length; i++)
|
||||
i: widget.state.schedules[i].enable
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@ -88,7 +68,9 @@ class _ScheduleTableWidgetState extends State<ScheduleTableWidget> {
|
||||
),
|
||||
child: _buildTableBody(state, context));
|
||||
}
|
||||
return const SizedBox();
|
||||
return const SizedBox(
|
||||
height: 200,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -162,20 +144,27 @@ class _ScheduleTableWidgetState extends State<ScheduleTableWidget> {
|
||||
return TableRow(
|
||||
children: [
|
||||
Center(
|
||||
child: Radio<bool>(
|
||||
value: true,
|
||||
groupValue: _enabledStates[index],
|
||||
onChanged: (bool? value) {
|
||||
setState(() {
|
||||
_enabledStates[index] = value!;
|
||||
});
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.read<WaterHeaterBloc>().add(UpdateScheduleEntryEvent(
|
||||
index: index,
|
||||
functionOn: value ?? false,
|
||||
enable: !schedule.enable,
|
||||
scheduleId: schedule.scheduleId,
|
||||
deviceId: state.status.uuid,
|
||||
functionOn: schedule.function.value,
|
||||
));
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: schedule.enable
|
||||
? const Icon(Icons.radio_button_checked,
|
||||
color: ColorsManager.blueColor)
|
||||
: const Icon(
|
||||
Icons.radio_button_unchecked,
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
|
||||
Reference in New Issue
Block a user