fix modalità normale e precisione
This commit is contained in:
1 parent
b0f19ec5c7
commit
119cc4993a
2 files changed
+43
-22
No files matched your search
@@ -245,13 +245,45 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
_precisionTargetIndex = null;
|
||||
});
|
||||
}
|
||||
final barcodes = capture.barcodes;
|
||||
if (barcodes.isEmpty) return;
|
||||
final first = barcodes.first;
|
||||
final rawValue = first.rawValue ?? first.displayValue;
|
||||
if (rawValue == null || rawValue.trim().isEmpty) return;
|
||||
final formatName = first.format.name.replaceAll('BarcodeFormat.', '');
|
||||
context.read<ScannerCubit>().processBarcode(rawValue, format: formatName);
|
||||
|
||||
final standardReticle = ScannerReticleGeometry.scanRect(
|
||||
_viewportSize,
|
||||
ScanAimMode.standard,
|
||||
);
|
||||
|
||||
final items = BarcodeGeometry.mapCaptureToItems(
|
||||
capture: capture,
|
||||
widgetSize: _viewportSize,
|
||||
deviceOrientation: deviceOrientation,
|
||||
);
|
||||
|
||||
if (items.isNotEmpty && standardReticle != null) {
|
||||
// Check barcodes whose center or bounding box falls inside the reticle
|
||||
final inside = items.where((item) =>
|
||||
standardReticle.contains(item.center) ||
|
||||
standardReticle.overlaps(item.boundingRect)).toList();
|
||||
if (inside.isEmpty) return;
|
||||
|
||||
// Pick the barcode closest to the reticle center
|
||||
inside.sort((a, b) =>
|
||||
(a.center - standardReticle.center).distanceSquared.compareTo(
|
||||
(b.center - standardReticle.center).distanceSquared));
|
||||
|
||||
final best = inside.first;
|
||||
context.read<ScannerCubit>().processBarcode(
|
||||
best.code,
|
||||
format: best.format,
|
||||
);
|
||||
} else {
|
||||
// Fallback if geometric mapping is unavailable
|
||||
final barcodes = capture.barcodes;
|
||||
if (barcodes.isEmpty) return;
|
||||
final first = barcodes.first;
|
||||
final rawValue = first.rawValue ?? first.displayValue;
|
||||
if (rawValue == null || rawValue.trim().isEmpty) return;
|
||||
final formatName = first.format.name.replaceAll('BarcodeFormat.', '');
|
||||
context.read<ScannerCubit>().processBarcode(rawValue, format: formatName);
|
||||
}
|
||||
|
||||
case ScanAimMode.precision:
|
||||
final items = BarcodeGeometry.mapCaptureToItems(
|
||||
@@ -266,7 +298,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
final target = BarcodeGeometry.selectPrecisionTarget(
|
||||
items: items,
|
||||
crosshairCenter: crosshairCenter,
|
||||
hitRadius: 16.0,
|
||||
hitRadius: 24.0,
|
||||
);
|
||||
|
||||
_updateLiveArItems(items, precisionTargetIndex: target?.index);
|
||||
@@ -477,7 +509,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleTapToFocus(TapUpDetails details) async {
|
||||
void _handleTapToFocus(TapUpDetails details) {
|
||||
if (_frozenSnapshot != null ||
|
||||
_viewportSize.isEmpty ||
|
||||
!_scannerController.value.isRunning) {
|
||||
@@ -485,9 +517,6 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
}
|
||||
|
||||
final local = details.localPosition;
|
||||
final rx = (local.dx / _viewportSize.width).clamp(0.0, 1.0);
|
||||
final ry = (local.dy / _viewportSize.height).clamp(0.0, 1.0);
|
||||
|
||||
_focusRingTimer?.cancel();
|
||||
setState(() {
|
||||
_focusRingPosition = local;
|
||||
@@ -498,9 +527,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
await _scannerController.setFocusPoint(Offset(rx, ry));
|
||||
} catch (_) {}
|
||||
_feedbackService.triggerSelection();
|
||||
}
|
||||
|
||||
void _toggleTorch() {
|
||||
@@ -537,10 +564,6 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
_viewportSize = constraints.biggest;
|
||||
final scanWindow = ScannerReticleGeometry.scanRect(
|
||||
_viewportSize,
|
||||
aimMode,
|
||||
);
|
||||
|
||||
final topSafe = MediaQuery.paddingOf(context).top + 124.0;
|
||||
final bottomReserved = (lastScan != null ? 250.0 : 165.0) +
|
||||
@@ -575,8 +598,6 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
},
|
||||
child: MobileScanner(
|
||||
controller: _scannerController,
|
||||
scanWindow: scanWindow,
|
||||
scanWindowUpdateThreshold: 4.0,
|
||||
onDetect: _onDetect,
|
||||
),
|
||||
),
|
||||
|
||||
+1
-1
@@ -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.3+4
|
||||
version: 1.0.4+5
|
||||
|
||||
environment:
|
||||
sdk: ^3.13.4
|
||||
|
||||
Reference in new issue
Block a user