Refactor PresenceUpdateData widget to support decimal values.

This commit is contained in:
Faris Armoush
2025-04-23 10:23:28 +03:00
parent 8c637e40ff
commit 367d6717e7

View File

@ -13,6 +13,7 @@ class PresenceUpdateData extends StatefulWidget {
required this.maxValue, required this.maxValue,
required this.steps, required this.steps,
this.description, this.description,
this.valuesPercision = 0,
}); });
final String title; final String title;
@ -22,6 +23,7 @@ class PresenceUpdateData extends StatefulWidget {
final double steps; final double steps;
final Function action; final Function action;
final String? description; final String? description;
final int valuesPercision;
@override @override
State<PresenceUpdateData> createState() => _CurrentTempState(); State<PresenceUpdateData> createState() => _CurrentTempState();
@ -45,7 +47,7 @@ class _CurrentTempState extends State<PresenceUpdateData> {
} }
void _onValueChanged(double newValue) { void _onValueChanged(double newValue) {
widget.action(newValue.toInt()); widget.action(newValue);
} }
@override @override
@ -66,7 +68,7 @@ class _CurrentTempState extends State<PresenceUpdateData> {
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 10), color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 10),
), ),
IncrementDecrementWidget( IncrementDecrementWidget(
value: widget.value.toString(), value: widget.value.toStringAsFixed(widget.valuesPercision),
description: widget.description ?? '', description: widget.description ?? '',
descriptionColor: ColorsManager.blackColor, descriptionColor: ColorsManager.blackColor,
onIncrement: () { onIncrement: () {