import 'package:flutter/material.dart'; /// Einheitliche Visualisierung für "Artikel aus Filiale". /// /// Wir nutzen bewusst nur eine Farbe (Amber) — selbst bei 5–10 möglichen /// Lagern bleibt die Karte mit einem zusätzlichen Lagernamen als Text /// lesbar. Mehrere Lager-Farben hätten zu Konfusion geführt und einzelne /// Lager nicht eindeutig zugeordnet. /// /// [warehouseNames] ist optional: ohne Namen erscheint nur "Filiale". class WarehouseBadge extends StatelessWidget { const WarehouseBadge({ super.key, this.warehouseNames = const [], this.compact = false, }); /// Die Distinct-Liste der Lagernamen (kommt typischerweise aus /// Delivery.distinctExternalWarehouseNames). final List warehouseNames; /// Kompakte Darstellung für enge Bereiche wie Sortier- und Scan-Listen. final bool compact; @override Widget build(BuildContext context) { final fg = Colors.amber.shade700; final bg = Colors.amber.shade100; final label = _buildLabel(); final iconSize = compact ? 14.0 : 16.0; final textStyle = TextStyle( color: fg, fontWeight: FontWeight.w600, fontSize: compact ? 11 : 12, ); return Semantics( label: "Artikel aus $label", child: Container( padding: EdgeInsets.symmetric( horizontal: compact ? 6 : 8, vertical: compact ? 2 : 4, ), decoration: BoxDecoration( color: bg, borderRadius: BorderRadius.circular(6), border: Border.all(color: fg.withValues(alpha: 0.4)), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.warehouse, size: iconSize, color: fg), SizedBox(width: compact ? 4 : 6), Flexible( child: Text( label, style: textStyle, overflow: TextOverflow.ellipsis, ), ), ], ), ), ); } String _buildLabel() { if (warehouseNames.isEmpty) return "Filiale"; if (warehouseNames.length == 1) return warehouseNames.first; return warehouseNames.join(" + "); } }