mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Update operation names in CpsFunctions and add toggle codes to CeilingSensorHelper
This commit is contained in:
22
assets/icons/communication_fault.svg
Normal file
22
assets/icons/communication_fault.svg
Normal file
@ -0,0 +1,22 @@
|
||||
<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.72272 14.6122L6.18327 14.354L2.97852 19.0925H6.55507L6.89972 18.8677V14.7744L6.72272 14.6122Z" fill="#407093"/>
|
||||
<path d="M6.23049 14.3775L5.01761 13.7969H4.78901L1.35938 18.8679L1.56355 19.0926H3.04156L6.23049 14.3775Z" fill="#365E7D"/>
|
||||
<path d="M7.54213 18.8677H2.81285C2.59801 18.8677 2.42383 19.0418 2.42383 19.2567V19.7497C2.42383 19.9645 2.59797 20.1386 2.81277 20.1386H7.54213C7.75698 20.1386 7.93116 19.9645 7.93116 19.7497V19.2567C7.93116 19.0418 7.75698 18.8677 7.54213 18.8677Z" fill="#4A80AA"/>
|
||||
<path d="M2.50507 19.7497V19.2567C2.50507 19.0419 2.67925 18.8677 2.89409 18.8677H0.389022C0.174179 18.8677 0 19.0418 0 19.2567V19.7497C0 19.9645 0.174179 20.1386 0.389022 20.1386H2.89405C2.67921 20.1386 2.50507 19.9645 2.50507 19.7497Z" fill="#407093"/>
|
||||
<path d="M6.06769 11.5625C5.92211 11.8628 5.83984 12.1995 5.83984 12.5557C5.83984 13.5291 6.44937 14.3595 7.30726 14.688C7.67558 14.5726 8.00285 14.3644 8.26136 14.0903V13.593L6.06769 11.5625Z" fill="#4A80AA"/>
|
||||
<path d="M5.88003 12.5635C5.88003 12.2155 5.9605 11.8866 6.10296 11.5934L5.40175 10.9443H5.11722C4.68695 11.3502 4.41797 11.9253 4.41797 12.5635C4.41797 13.7929 5.41461 14.7896 6.64406 14.7896C6.90015 14.7896 7.14573 14.7456 7.37464 14.666C6.50464 14.3633 5.88003 13.5366 5.88003 12.5635Z" fill="#407093"/>
|
||||
<path d="M18.8025 0.40287C18.4502 0.0506057 17.8791 0.0506057 17.5268 0.40287L16.666 1.26369V1.37279L17.7404 2.49283L17.9416 2.53931L18.8024 1.67849C19.1547 1.32627 19.1547 0.755135 18.8025 0.40287Z" fill="#FFD086"/>
|
||||
<path d="M19.0404 0.82865C19.0028 0.672713 18.9242 0.524628 18.8025 0.40287C18.4502 0.0506057 17.8791 0.0506057 17.5268 0.40287L16.666 1.26369V1.37279L17.2357 1.96662C17.5753 1.61322 17.9125 1.26447 18.0859 1.09107C18.3749 0.802049 18.7971 0.799822 19.0404 0.82865Z" fill="#FFC365"/>
|
||||
<path d="M15.8571 2.69561C15.8473 2.69561 15.8373 2.6951 15.8272 2.69413L5.87968 1.71499C5.71378 1.69866 5.59257 1.55097 5.6089 1.38507C5.62522 1.21917 5.773 1.09804 5.93882 1.11425L15.8864 2.09335C16.0522 2.10967 16.1735 2.25737 16.1571 2.42327C16.1418 2.57917 16.0105 2.69561 15.8571 2.69561Z" fill="#365E7D"/>
|
||||
<path d="M8.75675 4.55789C8.62288 4.55789 8.50058 4.46812 8.46503 4.33258C8.42273 4.17133 8.51917 4.00633 8.68038 3.96402L15.7804 2.10172C15.9416 2.0595 16.1066 2.15586 16.1489 2.31711C16.1912 2.47832 16.0948 2.64332 15.9336 2.68563L8.83355 4.54793C8.80784 4.55465 8.78206 4.55789 8.75675 4.55789Z" fill="#407093"/>
|
||||
<path d="M17.7843 13.6061C17.6308 13.6061 17.4995 13.4895 17.4843 13.3336L16.5112 3.37993C16.495 3.21407 16.6163 3.06641 16.7822 3.05016C16.9481 3.0347 17.0957 3.15532 17.112 3.32122L18.085 13.2749C18.1012 13.4407 17.9799 13.5884 17.814 13.6046C17.804 13.6056 17.7941 13.6061 17.7843 13.6061Z" fill="#365E7D"/>
|
||||
<path d="M14.9212 10.781C14.8956 10.781 14.8696 10.7777 14.8437 10.7709C14.6825 10.7281 14.5866 10.5629 14.6293 10.4018L16.519 3.27433C16.5617 3.11315 16.7269 3.01733 16.8881 3.05991C17.0492 3.10265 17.1452 3.26788 17.1025 3.42901L15.2127 10.5565C15.1769 10.6917 15.0548 10.781 14.9212 10.781Z" fill="#407093"/>
|
||||
<path d="M15.8027 2.12842L16.6657 1.26541L17.9412 2.54085L17.0782 3.40386L15.8027 2.12842Z" fill="#FFC365"/>
|
||||
<path d="M16.4582 2.78031C16.6656 2.56312 16.9895 2.22437 17.3028 1.89867L16.6678 1.26367L15.8047 2.12679L16.4582 2.78031Z" fill="#FFA90F"/>
|
||||
<path d="M17.2722 3.89628C17.195 3.89628 17.1177 3.86679 17.0588 3.80788L15.399 2.14805C15.2811 2.03016 15.2811 1.8391 15.399 1.72117C15.5168 1.60336 15.7079 1.60336 15.8258 1.72117L17.4857 3.38101C17.6036 3.4989 17.6036 3.68995 17.4857 3.80788C17.4267 3.86683 17.3495 3.89628 17.2722 3.89628Z" fill="#4A80AA"/>
|
||||
<path d="M17.4668 14.1492L7.36085 3.95557C6.02101 6.98032 5.78835 10.2274 6.7914 13.0274C9.56154 15.5262 13.6996 15.9099 17.5091 14.3392L17.4668 14.1492Z" fill="#B5DCFF"/>
|
||||
<path d="M7.4139 4.01031L5.09848 1.6748L4.86645 1.6977C3.23512 5.65405 3.71145 9.96509 6.47621 12.7299C6.64367 12.8973 6.81695 13.0562 6.99535 13.207C5.82988 10.4102 6.01929 7.08393 7.4139 4.01031Z" fill="#8BCAFF"/>
|
||||
<path d="M18.3911 13.4249L8.14156 3.17529C8.0407 3.19084 7.94359 3.2367 7.86594 3.31435L7.42012 3.76021C7.32437 3.85596 7.27676 3.98099 7.27539 4.1065L17.4925 14.3235C17.6444 14.4755 17.8907 14.4755 18.0426 14.3235L18.3912 13.975C18.5431 13.8231 18.5431 13.5768 18.3911 13.4249Z" fill="#DBEDFF"/>
|
||||
<path d="M7.4351 3.76805L7.87162 3.33153C7.95201 3.25114 8.05354 3.20512 8.1583 3.19266L5.78221 0.816572C5.6303 0.664658 5.38401 0.664658 5.23206 0.816572L4.88347 1.16516C4.73155 1.31708 4.73155 1.56337 4.88347 1.71528L7.29295 4.12477C7.28979 3.99602 7.33686 3.86629 7.4351 3.76805Z" fill="#B5DCFF"/>
|
||||
<path d="M14.5 10.9887C11.9318 10.9887 9.85 13.0705 9.85 15.6387C9.85 18.2068 11.9318 20.2887 14.5 20.2887C17.0682 20.2887 19.15 18.2068 19.15 15.6387C19.15 13.0705 17.0682 10.9887 14.5 10.9887ZM10.9594 15.6387C10.9594 14.4992 11.4977 13.4855 12.3344 12.8377L15.6926 18.9731C15.3201 19.1064 14.9187 19.1792 14.5 19.1792C12.5446 19.1793 10.9594 17.5941 10.9594 15.6387ZM18.0404 15.6387C18.0404 16.7782 17.5021 17.7919 16.6655 18.4397L13.3073 12.3042C13.6798 12.1709 14.0813 12.0981 14.5 12.0981C16.4554 12.0981 18.0404 13.6833 18.0404 15.6387Z" fill="#FF5A73" stroke="#FF5A73" stroke-width="0.3"/>
|
||||
</svg>
|
After Width: | Height: | Size: 5.2 KiB |
@ -90,8 +90,8 @@ final class CpsSensitivityFunction extends CpsFunctions {
|
||||
step = 1,
|
||||
scale = 0,
|
||||
super(
|
||||
code: 'far_detection',
|
||||
operationName: 'Far Detection',
|
||||
code: 'sensitivity',
|
||||
operationName: 'Sensitivity',
|
||||
icon: Assets.sensitivity,
|
||||
);
|
||||
|
||||
@ -123,7 +123,7 @@ final class CpsMovingSpeedFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Moving Speed',
|
||||
icon: Assets.speedoMeter,
|
||||
);
|
||||
@override
|
||||
@ -139,7 +139,7 @@ final class CpsSpatialStaticValueFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Spacial Static Value',
|
||||
icon: Assets.spatialStaticValue,
|
||||
);
|
||||
@override
|
||||
@ -149,7 +149,6 @@ final class CpsSpatialStaticValueFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsSpatialMotionValueFunction extends CpsFunctions {
|
||||
CpsSpatialMotionValueFunction({
|
||||
required super.deviceId,
|
||||
@ -157,7 +156,7 @@ final class CpsSpatialMotionValueFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Spatial Motion Value',
|
||||
icon: Assets.spatialMotionValue,
|
||||
);
|
||||
@override
|
||||
@ -167,7 +166,6 @@ final class CpsSpatialMotionValueFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
|
||||
CpsMaxDistanceOfDetectionFunction({
|
||||
required super.deviceId,
|
||||
@ -175,7 +173,7 @@ final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Maximum Distance Of Detection',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
@override
|
||||
@ -185,7 +183,6 @@ final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
|
||||
CpsMaxDistanceOfStaticDetectionFunction({
|
||||
required super.deviceId,
|
||||
@ -193,7 +190,7 @@ final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Maximum Distance Of Static Detection',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
@override
|
||||
@ -203,7 +200,6 @@ final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsDetectionRangeFunction extends CpsFunctions {
|
||||
CpsDetectionRangeFunction({
|
||||
required super.deviceId,
|
||||
@ -211,7 +207,7 @@ final class CpsDetectionRangeFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Detection Range',
|
||||
icon: Assets.farDetection,
|
||||
);
|
||||
@override
|
||||
@ -221,7 +217,6 @@ final class CpsDetectionRangeFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
|
||||
CpsDistanceOfMovingObjectsFunction({
|
||||
required super.deviceId,
|
||||
@ -229,7 +224,7 @@ final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Distance Of Moving Objects',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
@override
|
||||
@ -239,7 +234,6 @@ final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsPresenceJudgementThrsholdFunction extends CpsFunctions {
|
||||
CpsPresenceJudgementThrsholdFunction({
|
||||
required super.deviceId,
|
||||
@ -247,7 +241,7 @@ final class CpsPresenceJudgementThrsholdFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Presence Judgement Threshold',
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
);
|
||||
@override
|
||||
@ -264,7 +258,7 @@ final class CpsMotionAmplitudeTriggerThresholdFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Motion Amplitude Trigger Threshold',
|
||||
icon: Assets.presenceJudgementThrshold,
|
||||
);
|
||||
@override
|
||||
@ -274,7 +268,6 @@ final class CpsMotionAmplitudeTriggerThresholdFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsPerpetualBoundaryFunction extends CpsFunctions {
|
||||
CpsPerpetualBoundaryFunction({
|
||||
required super.deviceId,
|
||||
@ -282,7 +275,7 @@ final class CpsPerpetualBoundaryFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Perpetual Boundary',
|
||||
icon: Assets.boundary,
|
||||
);
|
||||
@override
|
||||
@ -292,9 +285,6 @@ final class CpsPerpetualBoundaryFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
|
||||
CpsMotionTriggerBoundaryFunction({
|
||||
required super.deviceId,
|
||||
@ -302,7 +292,7 @@ final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Motion Trigger Boundary',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
@override
|
||||
@ -312,7 +302,6 @@ final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsMotionTriggerTimeFunction extends CpsFunctions {
|
||||
CpsMotionTriggerTimeFunction({
|
||||
required super.deviceId,
|
||||
@ -320,7 +309,7 @@ final class CpsMotionTriggerTimeFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Motion Trigger Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
@override
|
||||
@ -337,7 +326,7 @@ final class CpsMotionToStaticTimeFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Motion To Static Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
@override
|
||||
@ -354,7 +343,7 @@ final class CpsEnteringNoBodyStateTimeFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Entering Nobody State Time',
|
||||
icon: Assets.motionMeter,
|
||||
);
|
||||
@override
|
||||
@ -364,8 +353,6 @@ final class CpsEnteringNoBodyStateTimeFunction extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
final class CpsSelfTestResultFunctions extends CpsFunctions {
|
||||
CpsSelfTestResultFunctions({
|
||||
required super.deviceId,
|
||||
@ -404,6 +391,11 @@ final class CpsSelfTestResultFunctions extends CpsFunctions {
|
||||
icon: Assets.communicationFault,
|
||||
value: 'communication_fault',
|
||||
),
|
||||
CpsOperationalValue(
|
||||
description: 'Radar Fault',
|
||||
icon: Assets.radarFault,
|
||||
value: 'radar_fault',
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -503,7 +495,6 @@ final class CpsMovementFunctions extends CpsFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final class CpsCustomModeFunction extends CpsFunctions {
|
||||
CpsCustomModeFunction({
|
||||
required super.deviceId,
|
||||
@ -624,7 +615,7 @@ final class CpsSportsParaFunction extends CpsFunctions {
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: '',
|
||||
operationName: '',
|
||||
operationName: 'Sports Para',
|
||||
icon: Assets.sportsPara,
|
||||
);
|
||||
@override
|
||||
|
@ -3,9 +3,13 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/ceiling_presence_sensor_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialog_function_list_tile.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialog_selection_list_tile.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class CeilingSensorDialog extends StatefulWidget {
|
||||
const CeilingSensorDialog({
|
||||
@ -27,6 +31,20 @@ class CeilingSensorDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
||||
late final List<CpsFunctions> _cpsFunctions;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_cpsFunctions = widget.functions.whereType<CpsFunctions>().where((function) {
|
||||
if (widget.dialogType == 'THEN') {
|
||||
return function.type == 'THEN' || function.type == 'BOTH';
|
||||
}
|
||||
return function.type == 'IF' || function.type == 'BOTH';
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
@ -56,17 +74,20 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const DialogHeader('Presence Sensor Condition'),
|
||||
Expanded(child: _buildMainContent(context, state)),
|
||||
DialogFooter(
|
||||
onCancel: () => Navigator.pop(context),
|
||||
onConfirm: state.addedFunctions.isNotEmpty
|
||||
? () {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
state.addedFunctions, '{uniqueCustomId}'),
|
||||
state.addedFunctions,
|
||||
'${widget.uniqueCustomId}',
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.pop(context, {
|
||||
// 'deviceId': functions.first.deviceId,
|
||||
'deviceId': widget.functions.first.deviceId,
|
||||
});
|
||||
}
|
||||
: null,
|
||||
@ -79,4 +100,130 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent(BuildContext context, FunctionBlocState state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
||||
(f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
operationName: '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
final selectedCpsFunctions = _cpsFunctions.firstWhere(
|
||||
(f) => f.code == selectedFunction,
|
||||
orElse: () => CpsMovementFunctions(
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
type: '',
|
||||
),
|
||||
);
|
||||
final operations = selectedCpsFunctions.getOperationalValues();
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CpsFunctionsList(cpsFunctions: _cpsFunctions),
|
||||
if (state.selectedFunction != null)
|
||||
Expanded(
|
||||
child: CpsDialogValueSelector(
|
||||
operations: operations,
|
||||
selectedFunction: selectedFunction ?? '',
|
||||
selectedFunctionData: selectedFunctionData,
|
||||
cpsFunctions: _cpsFunctions,
|
||||
operationName: selectedOperationName ?? '',
|
||||
device: widget.device,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CpsFunctionsList extends StatelessWidget {
|
||||
const CpsFunctionsList({required this.cpsFunctions, super.key});
|
||||
|
||||
final List<CpsFunctions> cpsFunctions;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 360,
|
||||
child: ListView.separated(
|
||||
shrinkWrap: false,
|
||||
itemCount: cpsFunctions.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: Divider(color: ColorsManager.dividerColor),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final function = cpsFunctions[index];
|
||||
return RoutineDialogFunctionListTile(
|
||||
iconPath: function.icon,
|
||||
operationName: function.operationName,
|
||||
onTap: () => context.read<FunctionBloc>().add(
|
||||
SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CpsDialogValueSelector extends StatelessWidget {
|
||||
const CpsDialogValueSelector({
|
||||
required this.operations,
|
||||
required this.selectedFunction,
|
||||
required this.selectedFunctionData,
|
||||
required this.cpsFunctions,
|
||||
required this.device,
|
||||
required this.operationName,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<CpsOperationalValue> operations;
|
||||
final String selectedFunction;
|
||||
final DeviceFunctionData? selectedFunctionData;
|
||||
final List<CpsFunctions> cpsFunctions;
|
||||
final AllDevicesModel? device;
|
||||
final String operationName;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemCount: operations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final operation = operations[index];
|
||||
final isSelected = selectedFunctionData?.value == operation.value;
|
||||
return RoutineDialogSelectionListTile(
|
||||
iconPath: operation.icon,
|
||||
description: operation.description,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: operationName,
|
||||
value: operation.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -162,4 +162,15 @@ abstract final class CeilingSensorHelper {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
static const toggleCodes = <String>{
|
||||
'radar_switch',
|
||||
'space_para_switch',
|
||||
'self_test_result',
|
||||
'nobody_time',
|
||||
'movement',
|
||||
'custom_mode',
|
||||
'space_type',
|
||||
'presence_state',
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user