From b0f19ec5c723ff6b436e393937db148de9c3325c Mon Sep 17 00:00:00 2001 From: Mark M2 Macbook Date: Sun, 15 Nov 2026 09:40:29 +0100 Subject: [PATCH] fix overlay multipli x stesso codice --- .../presentation/screens/scanner_screen.dart | 14 ++++++++------ .../presentation/widgets/ar_barcode_overlay.dart | 9 ++++++--- .../presentation/widgets/ar_frozen_picker.dart | 2 +- app/pubspec.yaml | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/lib/features/scanner/presentation/screens/scanner_screen.dart b/app/lib/features/scanner/presentation/screens/scanner_screen.dart index 345fa56..29eea13 100644 --- a/app/lib/features/scanner/presentation/screens/scanner_screen.dart +++ b/app/lib/features/scanner/presentation/screens/scanner_screen.dart @@ -287,15 +287,15 @@ class _ScannerScreenState extends State final now = DateTime.now(); - // 1. Update/Add detected items into sticky cache + // 1. Update/Add detected items into sticky cache - key is unique code to prevent duplicate badges for (final item in items) { - final key = item.selectionKey; - if (_trackedArItems.containsKey(key)) { - final entry = _trackedArItems[key]!; - entry.item = item; // Update coordinates for live tracking + final code = item.code; + if (_trackedArItems.containsKey(code)) { + final entry = _trackedArItems[code]!; + entry.item = item; // Update coordinates for smooth live tracking entry.lastSeen = now; } else { - _trackedArItems[key] = _TrackedBarcodeEntry( + _trackedArItems[code] = _TrackedBarcodeEntry( item: item, lastSeen: now, ); @@ -451,8 +451,10 @@ class _ScannerScreenState extends State if (success) { setState(() { if (_frozenSnapshot != null) { + _sentFrozenKeys.add(item.code); _sentFrozenKeys.add(item.selectionKey); } else { + _sentLiveKeys.add(item.code); _sentLiveKeys.add(item.selectionKey); } }); diff --git a/app/lib/features/scanner/presentation/widgets/ar_barcode_overlay.dart b/app/lib/features/scanner/presentation/widgets/ar_barcode_overlay.dart index e58c76b..9423bb6 100644 --- a/app/lib/features/scanner/presentation/widgets/ar_barcode_overlay.dart +++ b/app/lib/features/scanner/presentation/widgets/ar_barcode_overlay.dart @@ -35,7 +35,8 @@ class ArBarcodeOverlay extends StatelessWidget { safeBounds: safeBounds, measureBadge: (item) => _measureBadge( item, - isSent: sentKeys.contains(item.selectionKey), + isSent: sentKeys.contains(item.code) || + sentKeys.contains(item.selectionKey), ), ) : const {}; @@ -71,7 +72,8 @@ class ArBarcodeOverlay extends StatelessWidget { rect: rect, child: _ArCodeBadge( item: item, - isSent: sentKeys.contains(item.selectionKey), + isSent: sentKeys.contains(item.code) || + sentKeys.contains(item.selectionKey), onTap: onTapBarcode != null ? () => onTapBarcode!(item) : null, ), ), @@ -197,7 +199,8 @@ class _ArPolygonPainter extends CustomPainter { final isPrecisionMode = !showBadges; final isHighlighted = highlightedIndex == item.index; - final isSent = sentKeys.contains(item.selectionKey); + final isSent = sentKeys.contains(item.code) || + sentKeys.contains(item.selectionKey); final Color strokeColor; final double strokeWidth; diff --git a/app/lib/features/scanner/presentation/widgets/ar_frozen_picker.dart b/app/lib/features/scanner/presentation/widgets/ar_frozen_picker.dart index 2e7965a..22bb09c 100644 --- a/app/lib/features/scanner/presentation/widgets/ar_frozen_picker.dart +++ b/app/lib/features/scanner/presentation/widgets/ar_frozen_picker.dart @@ -250,7 +250,7 @@ class _ArFrozenPickerState extends State { const SizedBox(height: 8), itemBuilder: (context, index) { final item = snapshot.items[index]; - final isSent = + final isSent = widget.sentKeys.contains(item.code) || widget.sentKeys.contains(item.selectionKey); return _FrozenCodeRow( item: item, diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 1efecad..28ba261 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.2+3 +version: 1.0.3+4 environment: sdk: ^3.13.4