import 'package:flutter/material.dart'; import 'package:em2rp/utils/colors.dart'; import 'package:em2rp/models/container_model.dart'; /// Widget pour afficher les caractéristiques physiques d'un container class ContainerPhysicalCharacteristics extends StatelessWidget { final ContainerModel container; const ContainerPhysicalCharacteristics({ super.key, required this.container, }); @override Widget build(BuildContext context) { final hasDimensions = container.length != null || container.width != null || container.height != null; final hasWeight = container.weight != null; final hasVolume = container.volume != null; if (!hasDimensions && !hasWeight) { return const SizedBox.shrink(); } return Card( elevation: 2, child: Padding( padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Caractéristiques physiques', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), const Divider(height: 24), if (hasWeight) _buildCharacteristicRow( 'Poids à vide', '${container.weight} kg', Icons.scale, ), if (hasDimensions) ...[ if (hasWeight) const SizedBox(height: 12), _buildCharacteristicRow( 'Dimensions (L×l×H)', '${container.length ?? '?'} × ${container.width ?? '?'} × ${container.height ?? '?'} cm', Icons.straighten, ), ], if (hasVolume) ...[ const SizedBox(height: 12), _buildCharacteristicRow( 'Volume', '${container.volume!.toStringAsFixed(3)} m³', Icons.view_in_ar, ), ], ], ), ), ); } Widget _buildCharacteristicRow(String label, String value, IconData icon) { return Row( children: [ Icon(icon, size: 20, color: AppColors.rouge), const SizedBox(width: 12), Expanded( child: Text( label, style: const TextStyle(fontSize: 14), ), ), Text( value, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, ), ), ], ); } }