mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 21:34:54 +00:00
adding the delay
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/alert_dialog_countdown.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/light_divider.dart';
|
||||
|
||||
@ -74,10 +79,74 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
||||
size: 16,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
onPressed: () {},
|
||||
onPressed: () => _onDelayActionPressed(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onDelayActionPressed(BuildContext context) {
|
||||
final functionValues =
|
||||
context.read<CreateSceneBloc>().selectedValues['delay'];
|
||||
final functions = [
|
||||
SceneStaticFunction(
|
||||
deviceId: 'delay',
|
||||
deviceName: 'Delay The Action',
|
||||
icon: '',
|
||||
operationName: 'Delay The Action',
|
||||
code: 'delay',
|
||||
functionValue: 0,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
),
|
||||
];
|
||||
context.customAlertDialog(
|
||||
alertBody: AlertDialogCountdown(
|
||||
durationValue: functions[0].operationalValues.first.value,
|
||||
function: functions[0],
|
||||
functionValue: functionValues,
|
||||
),
|
||||
title: functions[0].operationName,
|
||||
onConfirm: () {
|
||||
final selectedValue =
|
||||
context.read<CreateSceneBloc>().selectedValues[functions[0].code];
|
||||
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
||||
deviceControlModel: DeviceControlModel(
|
||||
deviceId: 'delay',
|
||||
code: functions[0].code,
|
||||
value: selectedValue,
|
||||
),
|
||||
deviceId: 'delay',
|
||||
operation: functions[0].operationName,
|
||||
icon: Assets.delay,
|
||||
deviceName: 'Delay The Action',
|
||||
uniqueId: functions[0].uniqueCustomId,
|
||||
));
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(const AddTaskEvent(updateTaskListFromTemp: true));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onDismiss: () {
|
||||
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
||||
if (tempTaskList.isEmpty) {
|
||||
context.read<CreateSceneBloc>().add(const ClearTempTaskListEvent());
|
||||
} else {
|
||||
for (var element in tempTaskList) {
|
||||
if (element.code == functions[0].code) {
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(RemoveTempTaskByIdEvent(code: functions[0].code));
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(RemoveFromSelectedValueById(code: functions[0].code));
|
||||
}
|
||||
}
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user