Merge pull request #149 from SyncrowIOT/SP-1441-FE-On-routine-creation-page-When-the-user-drags-a-card-that-has-signs-and-selects-a-sign-without-a-number-then-confirms-the-value-appears-to-be-Null

Sp 1441 fe on routine creation page when the user drags a card that has signs and selects a sign without a number then confirms the value appears to be null
This commit is contained in:
Faris Armoush
2025-04-21 10:32:38 +03:00
committed by GitHub
8 changed files with 38 additions and 38 deletions

View File

@ -225,7 +225,7 @@ class DraggableCard extends StatelessWidget {
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
return '${(function.value / 10).toStringAsFixed(0)}°C';
} else if (function.functionCode.contains('countdown')) {
final seconds = function.value.toInt();
final seconds = function.value?.toInt() ?? 0;
if (seconds >= 3600) {
final hours = (seconds / 3600).floor();
final remainingMinutes = ((seconds % 3600) / 60).floor();

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.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/ac/ac_function.dart';
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
@ -9,8 +11,6 @@ import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
class ACHelper {
static Future<Map<String, dynamic>?> showACFunctionsDialog({
@ -74,10 +74,8 @@ class ACHelper {
child: _buildFunctionsList(
context: context,
acFunctions: acFunctions,
onFunctionSelected:
(functionCode, operationName) => context
.read<FunctionBloc>()
.add(SelectFunction(
onFunctionSelected: (functionCode, operationName) =>
context.read<FunctionBloc>().add(SelectFunction(
functionCode: functionCode,
operationName: operationName,
)),
@ -191,8 +189,9 @@ class ACHelper {
required String operationName,
bool? removeComparators,
}) {
final initialVal = selectedFunction == 'temp_set' ? 200 : -100;
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
final initialValue = selectedFunctionData?.value ?? 250;
final initialValue = selectedFunctionData?.value ?? initialVal;
return _buildTemperatureSelector(
context: context,
initialValue: initialValue,
@ -205,8 +204,7 @@ class ACHelper {
);
}
final selectedFn =
acFunctions.firstWhere((f) => f.code == selectedFunction);
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
final values = selectedFn.getOperationalValues();
return _buildOperationalValuesList(
@ -287,7 +285,9 @@ class ACHelper {
functionCode: selectCode,
operationName: operationName,
condition: conditions[index],
value: selectedFunctionData?.value,
value: selectedFunctionData?.value ?? selectCode == 'temp_set'
? 200
: -100,
valueDescription: selectedFunctionData?.valueDescription,
),
),
@ -302,8 +302,7 @@ class ACHelper {
minHeight: 40.0,
minWidth: 40.0,
),
isSelected:
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
children: conditions.map((c) => Text(c)).toList(),
);
}
@ -317,6 +316,7 @@ class ACHelper {
DeviceFunctionData? selectedFunctionData,
String selectCode,
) {
final initialVal = selectCode == 'temp_set' ? 200 : -100;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
@ -324,7 +324,7 @@ class ACHelper {
borderRadius: BorderRadius.circular(10),
),
child: Text(
'${(initialValue ?? 200) / 10}°C',
'${(initialValue ?? initialVal) / 10}°C',
style: context.textTheme.headlineMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
),
@ -397,9 +397,7 @@ class ACHelper {
style: context.textTheme.bodyMedium,
),
trailing: Icon(
isSelected
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
size: 24,
color: isSelected
? ColorsManager.primaryColorWithOpacity
@ -415,8 +413,7 @@ class ACHelper {
operationName: operationName,
value: value.value,
condition: selectedFunctionData?.condition,
valueDescription:
selectedFunctionData?.valueDescription,
valueDescription: selectedFunctionData?.valueDescription,
),
),
);

View File

@ -46,7 +46,7 @@ class CpsDialogSliderSelector extends StatelessWidget {
functionCode: selectedFunction,
operationName: operationName,
condition: condition,
value: selectedFunctionData.value,
value: selectedFunctionData.value ?? 0,
),
),
),

View File

@ -164,7 +164,7 @@ class OneGangSwitchHelper {
required bool removeComparetors,
}) {
if (selectedFunction == 'countdown_1') {
final initialValue = selectedFunctionData?.value ?? 200;
final initialValue = selectedFunctionData?.value ?? 0;
return _buildCountDownSelector(
context: context,
initialValue: initialValue,
@ -250,7 +250,7 @@ class OneGangSwitchHelper {
functionCode: selectCode,
operationName: operationName,
condition: conditions[index],
value: selectedFunctionData?.value,
value: selectedFunctionData?.value ?? 0,
valueDescription: selectedFunctionData?.valueDescription,
),
),

View File

@ -170,7 +170,7 @@ class ThreeGangSwitchHelper {
if (selectedFunction == 'countdown_1' ||
selectedFunction == 'countdown_2' ||
selectedFunction == 'countdown_3') {
final initialValue = selectedFunctionData?.value ?? 200;
final initialValue = selectedFunctionData?.value ?? 0;
return _buildTemperatureSelector(
context: context,
initialValue: initialValue,
@ -251,7 +251,7 @@ class ThreeGangSwitchHelper {
functionCode: selectCode,
operationName: operationName,
condition: conditions[index],
value: selectedFunctionData?.value,
value: selectedFunctionData?.value ?? 0,
valueDescription: selectedFunctionData?.valueDescription,
),
),

View File

@ -169,7 +169,7 @@ class TwoGangSwitchHelper {
}) {
if (selectedFunction == 'countdown_1' ||
selectedFunction == 'countdown_2') {
final initialValue = selectedFunctionData?.value ?? 200;
final initialValue = selectedFunctionData?.value ?? 0;
return _buildTemperatureSelector(
context: context,
initialValue: initialValue,
@ -250,7 +250,7 @@ class TwoGangSwitchHelper {
functionCode: selectCode,
operationName: operationName,
condition: conditions[index],
value: selectedFunctionData?.value,
value: selectedFunctionData?.value ?? 0,
valueDescription: selectedFunctionData?.valueDescription,
),
),

View File

@ -36,7 +36,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
dialogType: dialogType,
sliderRange: sliderRange,
displayedValue: getDisplayText,
initialValue: functionData.value ?? 250,
initialValue: functionData.value ?? 0.0,
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
AddFunction(
functionData: DeviceFunctionData(
@ -44,7 +44,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
functionCode: selectedFunction,
operationName: functionData.operationName,
condition: condition,
value: functionData.value,
value: functionData.value ?? 0,
),
),
),
@ -87,7 +87,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
final intValue = int.tryParse('${functionData.value ?? ''}');
return switch (functionData.functionCode) {
'presence_time' => '${intValue ?? '0'}',
'dis_current' => '${intValue ?? '250'}',
'dis_current' => '${intValue ?? '0'}',
'illuminance_value' => '${intValue ?? '0'}',
_ => '$intValue',
};

View File

@ -136,6 +136,17 @@ class _SidebarWidgetState extends State<SidebarWidget> {
}
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
final spaces = community.spaces
.where(
(space) =>
{
SpaceStatus.deleted,
SpaceStatus.parentDeleted,
}.contains(space.status) ==
false,
)
.map((space) => _buildSpaceTile(space: space, community: community))
.toList();
return CommunityTile(
title: community.name,
key: ValueKey(community.uuid),
@ -154,15 +165,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
);
},
onExpansionChanged: (title, expanded) {},
children: community.spaces
.where(
(space) => {
SpaceStatus.deleted,
SpaceStatus.parentDeleted,
}.contains(space.status),
)
.map((space) => _buildSpaceTile(space: space, community: community))
.toList(),
children: spaces,
);
}