import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../controller/anwendung_controller.dart'; import '../helper/input_validators.dart'; import 'entry_panel.dart'; class AnwendungForm extends StatelessWidget { const AnwendungForm({super.key, required this.controller}); final AnwendungController controller; @override Widget build(BuildContext context) { final filament = controller.filament.value!; return EntryPanel( title: 'Verarbeitung erfassen', subtitle: '${filament.marke} · ${filament.material} · ${filament.farbe}\n' 'Speichere die Einstellungen für dieses Filament als Profil.', child: Form( key: controller.formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ EntryFieldGrid( children: [ EntryNumberField( controller: controller.druckController, label: 'Drucktemperatur', unit: '°C', validator: InputValidators.positive, ), EntryNumberField( controller: controller.druckbettController, label: 'Druckbetttemperatur', unit: '°C', validator: InputValidators.nonNegative, ), ], ), const SizedBox(height: 16), Material( color: Colors.transparent, child: Obx( () => SwitchListTile.adaptive( contentPadding: EdgeInsets.zero, title: const Text('Bauraum geschlossen'), subtitle: Text( controller.bauraumGeschlossen.value ? 'Ja' : 'Nein', ), value: controller.bauraumGeschlossen.value, onChanged: (value) => controller.bauraumGeschlossen.value = value, ), ), ), const SizedBox(height: 16), EntryNumberField( controller: controller.bauraumController, label: 'Bauraumtemperatur (optional)', unit: '°C', validator: (value) => InputValidators.nonNegative(value, optional: true), ), const SizedBox(height: 16), TextFormField( controller: controller.sonstigesController, minLines: 3, maxLines: 6, decoration: const InputDecoration( labelText: 'Sonstiges (optional)', alignLabelWithHint: true, hintText: 'Zum Beispiel Geschwindigkeit, Kühlung oder Besonderheiten', ), ), const SizedBox(height: 24), Obx( () => FilledButton.icon( onPressed: controller.isSaving.value ? null : controller.saveAnwendung, icon: const Icon(Icons.save_outlined), label: Text( controller.isSaving.value ? 'Wird gespeichert …' : 'Verarbeitungsprofil speichern', ), ), ), Obx( () => EntryMessage( message: controller.message.value, hasError: controller.hasError.value, ), ), ], ), ), ); } }