feat: enhance AI suggestion display in edit dialog with product name and category labels

This commit is contained in:
Nils-Johan Gynther
2026-05-01 23:41:18 +02:00
parent 51e654c592
commit 2c71970fb5
@@ -327,11 +327,12 @@ class _EditDialogState extends State<_EditDialog> {
final aiPath = item.categorySuggestionPath;
final aiLabel = (aiPath != null && aiPath.isNotEmpty)
? aiPath
: ((aiCategory != null && aiCategory.isNotEmpty)
? aiCategory
: (item.suggestedProductName?.isNotEmpty == true
? item.suggestedProductName
: null));
: ((aiCategory != null && aiCategory.isNotEmpty) ? aiCategory : null);
final suggestedProductLabel = (item.suggestedProductId != null &&
item.suggestedProductName?.isNotEmpty == true &&
item.matchedProductId == null)
? item.suggestedProductName
: null;
final currentQuantity =
double.tryParse(_quantityCtrl.text.replaceAll(',', '.')) ?? widget.item.quantity;
final currentUnit = _unitCtrl.text.trim().isEmpty ? widget.item.unit : _unitCtrl.text.trim();
@@ -431,8 +432,24 @@ class _EditDialogState extends State<_EditDialog> {
),
],
),
if (aiLabel != null) ...[
const SizedBox(height: 8),
if (suggestedProductLabel != null) ...[ const SizedBox(height: 8),
ActionChip(
avatar: Icon(
Icons.search,
size: 14,
color: Colors.blue.shade700,
),
label: Text(
'Förslag: $suggestedProductLabel',
style: theme.textTheme.labelSmall,
),
backgroundColor: Colors.blue.shade50,
side: BorderSide(color: Colors.blue.shade300),
visualDensity: VisualDensity.compact,
onPressed: _applyAiSuggestionForExistingSelection,
),
],
if (aiLabel != null) ...[ const SizedBox(height: 8),
ActionChip(
avatar: Icon(
Icons.auto_awesome,
@@ -440,7 +457,7 @@ class _EditDialogState extends State<_EditDialog> {
color: Colors.green.shade700,
),
label: Text(
'AI-forslag: $aiLabel',
'AI-kategori: $aiLabel',
style: theme.textTheme.labelSmall,
),
backgroundColor: Colors.green.shade50,