formatted all files.

This commit is contained in:
Faris Armoush
2025-06-12 15:33:32 +03:00
parent 29959f567e
commit 04250ebc98
474 changed files with 5425 additions and 4338 deletions

View File

@ -1,4 +1,5 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:syncrow_web/pages/routines/widgets/condition_toggle.dart';
@ -45,10 +46,10 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
String? errorMessage;
int getDecimalPlaces(double step) {
String stepStr = step.toString();
final stepStr = step.toString();
if (stepStr.contains('.')) {
List<String> parts = stepStr.split('.');
String decimalPart = parts[1];
final parts = stepStr.split('.');
var decimalPart = parts[1];
decimalPart = decimalPart.replaceAll(RegExp(r'0+$'), '');
return decimalPart.isEmpty ? 0 : decimalPart.length;
} else {
@ -111,13 +112,11 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
}
}
void _validateInput(String value) {
final doubleValue = double.tryParse(value);
if (doubleValue == null) {
setState(() {
errorMessage = "Invalid number";
errorMessage = 'Invalid number';
hasError = true;
});
return;
@ -128,23 +127,23 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
if (doubleValue < min) {
setState(() {
errorMessage = "Value must be at least $min";
errorMessage = 'Value must be at least $min';
hasError = true;
});
} else if (doubleValue > max) {
setState(() {
errorMessage = "Value must be at most $max";
errorMessage = 'Value must be at most $max';
hasError = true;
});
} else {
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
int factor = pow(10, decimalPlaces).toInt();
int scaledStep = (widget.stepIncreaseAmount * factor).round();
int scaledValue = (doubleValue * factor).round();
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
final factor = pow(10, decimalPlaces).toInt();
final scaledStep = (widget.stepIncreaseAmount * factor).round();
final scaledValue = (doubleValue * factor).round();
if (scaledValue % scaledStep != 0) {
setState(() {
errorMessage = "must be a multiple of ${widget.stepIncreaseAmount}";
errorMessage = 'must be a multiple of ${widget.stepIncreaseAmount}';
hasError = true;
});
} else {
@ -156,11 +155,10 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
}
}
void _correctAndUpdateValue(String value) {
final doubleValue = double.tryParse(value) ?? 0.0;
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
double rounded = (doubleValue / widget.stepIncreaseAmount).round() *
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
var rounded = (doubleValue / widget.stepIncreaseAmount).round() *
widget.stepIncreaseAmount;
rounded = rounded.clamp(widget.sliderRange.$1, widget.sliderRange.$2);
rounded = double.parse(rounded.toStringAsFixed(decimalPlaces));
@ -179,9 +177,9 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
@override
Widget build(BuildContext context) {
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
List<TextInputFormatter> formatters = [];
final formatters = <TextInputFormatter>[];
if (decimalPlaces == 0) {
formatters.add(FilteringTextInputFormatter.digitsOnly);
} else {
@ -233,7 +231,7 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
color: ColorsManager.lightGrayBorderColor, width: 1),
boxShadow: [
BoxShadow(
color: ColorsManager.blackColor.withOpacity(0.05),
color: ColorsManager.blackColor.withValues(alpha: 0.05),
blurRadius: 8,
offset: const Offset(0, 4),
),