mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 13:24:54 +00:00
reflect api selected function value in the view and connect dialog
This commit is contained in:
@ -1166,7 +1166,9 @@ mixin SceneOperationsDataHelper {
|
||||
icon: Assets.assetsTempreture,
|
||||
operationName: 'Set Temperature',
|
||||
code: 'temp_set',
|
||||
functionValue: executorProperty.functionValue,
|
||||
functionValue: executorProperty.functionValue != null
|
||||
? ((executorProperty.functionValue / 10) as double).toInt()
|
||||
: null,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsCelsiusDegrees,
|
||||
|
||||
@ -117,7 +117,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
context.customAlertDialog(
|
||||
alertBody: functions[index].code == 'temp_set'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index, functions: functions)
|
||||
index: index, functions: functions,)
|
||||
: (functions[index]
|
||||
.code
|
||||
.contains('countdown') ||
|
||||
|
||||
@ -4,19 +4,30 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
|
||||
class AlertDialogCountdown extends StatefulWidget {
|
||||
const AlertDialogCountdown({super.key, required this.durationValue});
|
||||
AlertDialogCountdown(
|
||||
{super.key, required this.durationValue, this.functionValue});
|
||||
|
||||
final int durationValue;
|
||||
dynamic functionValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||
}
|
||||
|
||||
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||
@override
|
||||
didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (widget.functionValue != null) {
|
||||
setState(() {
|
||||
durationInSeconds = widget.functionValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int durationInSeconds = 0;
|
||||
// Convert seconds to Duration.
|
||||
Duration get duration =>
|
||||
Duration(seconds: widget.durationValue) ;
|
||||
Duration get duration => Duration(seconds: widget.durationValue);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
@ -5,14 +5,16 @@ import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
|
||||
class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
||||
const AlertDialogFunctionsOperationsBody({
|
||||
AlertDialogFunctionsOperationsBody({
|
||||
super.key,
|
||||
required this.functions,
|
||||
required this.index,
|
||||
this.functionValue,
|
||||
});
|
||||
|
||||
final List<SceneStaticFunction> functions;
|
||||
final int index;
|
||||
dynamic functionValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogFunctionsOperationsBody> createState() =>
|
||||
@ -21,6 +23,16 @@ class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
||||
|
||||
class _AlertDialogFunctionsOperationsBodyState
|
||||
extends State<AlertDialogFunctionsOperationsBody> {
|
||||
@override
|
||||
didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (widget.functionValue != null) {
|
||||
setState(() {
|
||||
groupValue = widget.functionValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
dynamic groupValue;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@ -10,14 +10,16 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class AlertDialogTemperatureBody extends StatefulWidget {
|
||||
const AlertDialogTemperatureBody({
|
||||
AlertDialogTemperatureBody({
|
||||
super.key,
|
||||
required this.index,
|
||||
required this.functions,
|
||||
this.functionValue,
|
||||
});
|
||||
|
||||
final List<SceneStaticFunction> functions;
|
||||
final int index;
|
||||
dynamic functionValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogTemperatureBody> createState() =>
|
||||
@ -26,6 +28,16 @@ class AlertDialogTemperatureBody extends StatefulWidget {
|
||||
|
||||
class _AlertDialogTemperatureBodyState
|
||||
extends State<AlertDialogTemperatureBody> {
|
||||
@override
|
||||
didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (widget.functionValue != null) {
|
||||
setState(() {
|
||||
temperature = widget.functionValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int temperature = 24;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@ -3,6 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.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/alert_dialogs/alert_dialog_functions_body.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/alert_dialog_temperature_body.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
@ -11,12 +14,18 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ThenAddedTasksContainer extends StatelessWidget {
|
||||
const ThenAddedTasksContainer({
|
||||
ThenAddedTasksContainer({
|
||||
super.key,
|
||||
required this.taskList,
|
||||
this.sceneId,
|
||||
this.index,
|
||||
this.listOfSceneStaticFunction,
|
||||
});
|
||||
|
||||
final SceneStaticFunction taskList;
|
||||
String? sceneId;
|
||||
List<SceneStaticFunction>? listOfSceneStaticFunction;
|
||||
int? index;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -34,6 +43,47 @@ class ThenAddedTasksContainer extends StatelessWidget {
|
||||
operationValue = functionValue.toString();
|
||||
}
|
||||
return DefaultContainer(
|
||||
onTap: () {
|
||||
context.customAlertDialog(
|
||||
alertBody: taskList.code == 'temp_set'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index!,
|
||||
functions: listOfSceneStaticFunction ?? [],
|
||||
functionValue: taskList.functionValue,
|
||||
)
|
||||
: (listOfSceneStaticFunction![index!]
|
||||
.code
|
||||
.contains('countdown') ||
|
||||
listOfSceneStaticFunction![index!]
|
||||
.code
|
||||
.contains('presence_time'))
|
||||
? AlertDialogCountdown(
|
||||
durationValue:
|
||||
listOfSceneStaticFunction![index!].functionValue,
|
||||
functionValue: taskList.functionValue,
|
||||
)
|
||||
: AlertDialogFunctionsOperationsBody(
|
||||
index: index!,
|
||||
functions: listOfSceneStaticFunction ?? [],
|
||||
functionValue: taskList.functionValue),
|
||||
title: listOfSceneStaticFunction![index!].operationName,
|
||||
onConfirm: () {
|
||||
// final selectedValue = context.read<CreateSceneBloc>().selectedValue;
|
||||
// context.read<CreateSceneBloc>().add(AddTaskEvent(
|
||||
// deviceControlModel: DeviceControlModel(
|
||||
// deviceId: device.uuid,
|
||||
// code: functions[index].code,
|
||||
// value: selectedValue,
|
||||
// ),
|
||||
// deviceId: device.uuid ?? '',
|
||||
// operation: functions[index].operationName,
|
||||
// icon: device.icon ?? '',
|
||||
// deviceName: device.name ?? '',
|
||||
// ));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
child: Dismissible(
|
||||
key: Key(taskList.uniqueCustomId.toString()),
|
||||
|
||||
@ -66,6 +66,9 @@ class ThenDefaultContainer extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
return ThenAddedTasksContainer(
|
||||
taskList: taskLists[index],
|
||||
index: index,
|
||||
listOfSceneStaticFunction: taskLists,
|
||||
sceneId:sceneId,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user