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
+47 -4
View File
@@ -11,6 +11,29 @@ class BauteilFilamentAuswahl extends StatelessWidget {
const BauteilFilamentAuswahl({super.key, required this.controller});
final BauteilController controller;
Future<void> _waehleFilament(BuildContext context, String id) async {
controller.toggleFilament(id, true);
final warnung = controller.pruefeFilamentVorrat();
if (warnung == null || !context.mounted) return;
await showDialog<void>(
context: context,
barrierDismissible: false,
builder: (dialogContext) => PopScope(
canPop: false,
child: AlertDialog(
title: const Text('Achtung: zu wenig Filament'),
content: Text(warnung),
actions: [
FilledButton(
onPressed: () => Navigator.of(dialogContext).pop(),
child: const Text('OK'),
),
],
),
),
);
}
@override
Widget build(BuildContext context) => Obx(() {
final ids = controller.selectedFilamente.keys.toList();
@@ -36,21 +59,41 @@ class BauteilFilamentAuswahl extends StatelessWidget {
.toString(),
),
isExpanded: true,
itemHeight: 64,
decoration: const InputDecoration(labelText: 'Filament hinzufügen'),
hint: const Text('Filament auswählen'),
items: availableFilamente
.map(
(item) => DropdownMenuItem(
value: item.filamentId,
child: Text(
controller.filamentLabel(item.filamentId),
overflow: TextOverflow.ellipsis,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
controller.filamentLabel(item.filamentId),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
controller.restgewichtGramm(item.filamentId) == null
? 'Restgewicht unbekannt'
: 'Restgewicht: ${DisplayFormats.number(controller.restgewichtGramm(item.filamentId)!)} g',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppTheme.teal,
fontSize: 13,
),
),
],
),
),
)
.toList(),
onChanged: (id) {
if (id != null) controller.toggleFilament(id, true);
if (id != null) _waehleFilament(context, id);
},
),
const SizedBox(height: 12),