mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 16:14: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,
|
icon: Assets.assetsTempreture,
|
||||||
operationName: 'Set Temperature',
|
operationName: 'Set Temperature',
|
||||||
code: 'temp_set',
|
code: 'temp_set',
|
||||||
functionValue: executorProperty.functionValue,
|
functionValue: executorProperty.functionValue != null
|
||||||
|
? ((executorProperty.functionValue / 10) as double).toInt()
|
||||||
|
: null,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsCelsiusDegrees,
|
icon: Assets.assetsCelsiusDegrees,
|
||||||
|
|||||||
@ -117,7 +117,7 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
context.customAlertDialog(
|
context.customAlertDialog(
|
||||||
alertBody: functions[index].code == 'temp_set'
|
alertBody: functions[index].code == 'temp_set'
|
||||||
? AlertDialogTemperatureBody(
|
? AlertDialogTemperatureBody(
|
||||||
index: index, functions: functions)
|
index: index, functions: functions,)
|
||||||
: (functions[index]
|
: (functions[index]
|
||||||
.code
|
.code
|
||||||
.contains('countdown') ||
|
.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';
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||||
|
|
||||||
class AlertDialogCountdown extends StatefulWidget {
|
class AlertDialogCountdown extends StatefulWidget {
|
||||||
const AlertDialogCountdown({super.key, required this.durationValue});
|
AlertDialogCountdown(
|
||||||
|
{super.key, required this.durationValue, this.functionValue});
|
||||||
|
|
||||||
final int durationValue;
|
final int durationValue;
|
||||||
|
dynamic functionValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||||
|
@override
|
||||||
|
didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
if (widget.functionValue != null) {
|
||||||
|
setState(() {
|
||||||
|
durationInSeconds = widget.functionValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int durationInSeconds = 0;
|
int durationInSeconds = 0;
|
||||||
// Convert seconds to Duration.
|
// Convert seconds to Duration.
|
||||||
Duration get duration =>
|
Duration get duration => Duration(seconds: widget.durationValue);
|
||||||
Duration(seconds: widget.durationValue) ;
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
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';
|
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||||
|
|
||||||
class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
||||||
const AlertDialogFunctionsOperationsBody({
|
AlertDialogFunctionsOperationsBody({
|
||||||
super.key,
|
super.key,
|
||||||
required this.functions,
|
required this.functions,
|
||||||
required this.index,
|
required this.index,
|
||||||
|
this.functionValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<SceneStaticFunction> functions;
|
final List<SceneStaticFunction> functions;
|
||||||
final int index;
|
final int index;
|
||||||
|
dynamic functionValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogFunctionsOperationsBody> createState() =>
|
State<AlertDialogFunctionsOperationsBody> createState() =>
|
||||||
@ -21,6 +23,16 @@ class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
|||||||
|
|
||||||
class _AlertDialogFunctionsOperationsBodyState
|
class _AlertDialogFunctionsOperationsBodyState
|
||||||
extends State<AlertDialogFunctionsOperationsBody> {
|
extends State<AlertDialogFunctionsOperationsBody> {
|
||||||
|
@override
|
||||||
|
didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
if (widget.functionValue != null) {
|
||||||
|
setState(() {
|
||||||
|
groupValue = widget.functionValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dynamic groupValue;
|
dynamic groupValue;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class AlertDialogTemperatureBody extends StatefulWidget {
|
class AlertDialogTemperatureBody extends StatefulWidget {
|
||||||
const AlertDialogTemperatureBody({
|
AlertDialogTemperatureBody({
|
||||||
super.key,
|
super.key,
|
||||||
required this.index,
|
required this.index,
|
||||||
required this.functions,
|
required this.functions,
|
||||||
|
this.functionValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<SceneStaticFunction> functions;
|
final List<SceneStaticFunction> functions;
|
||||||
final int index;
|
final int index;
|
||||||
|
dynamic functionValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogTemperatureBody> createState() =>
|
State<AlertDialogTemperatureBody> createState() =>
|
||||||
@ -26,6 +28,16 @@ class AlertDialogTemperatureBody extends StatefulWidget {
|
|||||||
|
|
||||||
class _AlertDialogTemperatureBodyState
|
class _AlertDialogTemperatureBodyState
|
||||||
extends State<AlertDialogTemperatureBody> {
|
extends State<AlertDialogTemperatureBody> {
|
||||||
|
@override
|
||||||
|
didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
if (widget.functionValue != null) {
|
||||||
|
setState(() {
|
||||||
|
temperature = widget.functionValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int temperature = 24;
|
int temperature = 24;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
@ -3,6 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.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/bloc/create_scene/create_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.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/scene/widgets/scene_list_tile.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.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';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class ThenAddedTasksContainer extends StatelessWidget {
|
class ThenAddedTasksContainer extends StatelessWidget {
|
||||||
const ThenAddedTasksContainer({
|
ThenAddedTasksContainer({
|
||||||
super.key,
|
super.key,
|
||||||
required this.taskList,
|
required this.taskList,
|
||||||
|
this.sceneId,
|
||||||
|
this.index,
|
||||||
|
this.listOfSceneStaticFunction,
|
||||||
});
|
});
|
||||||
|
|
||||||
final SceneStaticFunction taskList;
|
final SceneStaticFunction taskList;
|
||||||
|
String? sceneId;
|
||||||
|
List<SceneStaticFunction>? listOfSceneStaticFunction;
|
||||||
|
int? index;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -34,6 +43,47 @@ class ThenAddedTasksContainer extends StatelessWidget {
|
|||||||
operationValue = functionValue.toString();
|
operationValue = functionValue.toString();
|
||||||
}
|
}
|
||||||
return DefaultContainer(
|
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,
|
padding: EdgeInsets.zero,
|
||||||
child: Dismissible(
|
child: Dismissible(
|
||||||
key: Key(taskList.uniqueCustomId.toString()),
|
key: Key(taskList.uniqueCustomId.toString()),
|
||||||
|
|||||||
@ -66,6 +66,9 @@ class ThenDefaultContainer extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ThenAddedTasksContainer(
|
return ThenAddedTasksContainer(
|
||||||
taskList: taskLists[index],
|
taskList: taskLists[index],
|
||||||
|
index: index,
|
||||||
|
listOfSceneStaticFunction: taskLists,
|
||||||
|
sceneId:sceneId,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user