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 aiPath = item.categorySuggestionPath;
final aiLabel = (aiPath != null && aiPath.isNotEmpty) final aiLabel = (aiPath != null && aiPath.isNotEmpty)
? aiPath ? aiPath
: ((aiCategory != null && aiCategory.isNotEmpty) : ((aiCategory != null && aiCategory.isNotEmpty) ? aiCategory : null);
? aiCategory final suggestedProductLabel = (item.suggestedProductId != null &&
: (item.suggestedProductName?.isNotEmpty == true item.suggestedProductName?.isNotEmpty == true &&
item.matchedProductId == null)
? item.suggestedProductName ? item.suggestedProductName
: null)); : null;
final currentQuantity = final currentQuantity =
double.tryParse(_quantityCtrl.text.replaceAll(',', '.')) ?? widget.item.quantity; double.tryParse(_quantityCtrl.text.replaceAll(',', '.')) ?? widget.item.quantity;
final currentUnit = _unitCtrl.text.trim().isEmpty ? widget.item.unit : _unitCtrl.text.trim(); final currentUnit = _unitCtrl.text.trim().isEmpty ? widget.item.unit : _unitCtrl.text.trim();
@@ -431,8 +432,24 @@ class _EditDialogState extends State<_EditDialog> {
), ),
], ],
), ),
if (aiLabel != null) ...[ if (suggestedProductLabel != null) ...[ const SizedBox(height: 8),
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( ActionChip(
avatar: Icon( avatar: Icon(
Icons.auto_awesome, Icons.auto_awesome,
@@ -440,7 +457,7 @@ class _EditDialogState extends State<_EditDialog> {
color: Colors.green.shade700, color: Colors.green.shade700,
), ),
label: Text( label: Text(
'AI-forslag: $aiLabel', 'AI-kategori: $aiLabel',
style: theme.textTheme.labelSmall, style: theme.textTheme.labelSmall,
), ),
backgroundColor: Colors.green.shade50, backgroundColor: Colors.green.shade50,