import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../controller/home_controller.dart'; import '../widgets/filament_item_widget.dart'; class HomePage extends GetView { static const String namedRoute = '/home-page'; const HomePage({super.key}); @override Widget build(BuildContext context) { var hCtrl = controller; return Scaffold( backgroundColor: Colors.grey.shade50, appBar: AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.teal.shade400, foregroundColor: Colors.white, title: const Text( 'Filament Lager', style: TextStyle(fontWeight: FontWeight.bold), ), actions: [ IconButton( icon: const Icon(Icons.logout), onPressed: hCtrl.logout, ), ], ), floatingActionButton: FloatingActionButton.extended( backgroundColor: Colors.teal.shade400.withValues(alpha: 0.4), foregroundColor: Colors.grey.shade200, onPressed: hCtrl.addFilament, icon: const Icon(Icons.add), label: const Text('Filament'), ), body: Obx(() { if (hCtrl.isLoading.value) { return const Center(child: CircularProgressIndicator()); } if (hCtrl.filamentModelList.isEmpty) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.inventory_2_outlined, size: 64, color: Colors.grey.shade400), const SizedBox(height: 16), Text( 'Keine Filamente vorhanden', style: TextStyle(fontSize: 16, color: Colors.grey.shade600), ), ], ), ); } return RefreshIndicator( onRefresh: hCtrl.loadFilamentListPerUser, child: ListView.builder( padding: const EdgeInsets.only(top: 8, bottom: 80), itemCount: hCtrl.filamentModelList.length, itemBuilder: (context, index) { final filament = hCtrl.filamentModelList[index]; return FilamentItemWidget( filament: filament, onTap: () { // Optionale Detailansicht oder Bearbeitung }, ); }, ), ); }), ); } }