add some new features

This commit is contained in:
2026-10-29 15:03:48 +01:00
parent c876405a8f
commit 20012db615
39 changed files with 2908 additions and 97 deletions
+19 -1
View File
@@ -54,6 +54,7 @@ class HomeController extends GetxController {
final preisController = TextEditingController();
final markeController = TextEditingController();
final gewichtController = TextEditingController();
final bruttoGewichtController = TextEditingController();
final materialController = TextEditingController(text: 'PLA');
final kaufdatum = DateTime.now().obs;
@@ -163,6 +164,18 @@ class HomeController extends GetxController {
);
}
String? validateBruttogewicht(String? value) {
if ((value ?? '').trim().isEmpty) return null;
final error = InputValidators.positive(value);
if (error != null) return error;
final brutto = InputValidators.number(value)!;
final netto = InputValidators.number(gewichtController.text);
if (netto != null && netto.isFinite && brutto < netto) {
return 'Bruttogewicht muss mindestens dem Nettogewicht entsprechen.';
}
return null;
}
Future<void> saveFilament() async {
if (!formKey.currentState!.validate()) return;
@@ -186,7 +199,7 @@ class HomeController extends GetxController {
gewicht < bereitsVerbraucht) {
Get.snackbar(
'Ungültiges Gewicht',
'Das Startgewicht muss positiv sein und mindestens dem bereits gebuchten Verbrauch entsprechen.',
'Das Nettostartgewicht muss positiv sein und mindestens dem bereits gebuchten Verbrauch entsprechen.',
);
return;
}
@@ -202,6 +215,7 @@ class HomeController extends GetxController {
preis: preis,
farbe: farbeController.text.trim(),
gewicht: gewicht.toString(),
bruttoGewichtGramm: InputValidators.number(bruttoGewichtController.text),
);
if (editingId.value == null) {
@@ -231,6 +245,8 @@ class HomeController extends GetxController {
haendlerController.text = filament.haendler;
selectMaterial(filament.material);
preisController.text = filament.preis.toStringAsFixed(2);
bruttoGewichtController.text =
filament.bruttoGewichtGramm?.toString().replaceAll('.', ',') ?? '';
farbeController.text = filament.farbe;
gewichtController.text = filament.gewichtGramm == null
? filament.gewicht
@@ -272,6 +288,7 @@ class HomeController extends GetxController {
selectMaterial(materialien.firstOrNull ?? '');
materialMessage.value = null;
gewichtController.clear();
bruttoGewichtController.clear();
}
@override
@@ -283,6 +300,7 @@ class HomeController extends GetxController {
farbeController.dispose();
preisController.dispose();
gewichtController.dispose();
bruttoGewichtController.dispose();
materialController.dispose();
super.onClose();
}