Files
Holzleitner-Lieferservice-App/lib/widget/warehouse_badge.dart
Dennis Nemec a9bf8ecdd1 Final commit.
2026-06-01 17:12:28 +02:00

74 lines
2.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
/// Einheitliche Visualisierung für "Artikel aus Filiale".
///
/// Wir nutzen bewusst nur eine Farbe (Amber) — selbst bei 510 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<String> 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(" + ");
}
}