From 2c71970fb518fb3c6fc5066d74fbe95da6482f2a Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Fri, 1 May 2026 23:41:18 +0200 Subject: [PATCH] feat: enhance AI suggestion display in edit dialog with product name and category labels --- .../presentation/receipt_import_tab.dart | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/flutter/lib/features/import/presentation/receipt_import_tab.dart b/flutter/lib/features/import/presentation/receipt_import_tab.dart index 691264ca..06c20906 100644 --- a/flutter/lib/features/import/presentation/receipt_import_tab.dart +++ b/flutter/lib/features/import/presentation/receipt_import_tab.dart @@ -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,