mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Merge pull request #571 from inventree/barcode-scan-fix
Barcode scan fix
This commit is contained in:
commit
0ef72dc3dd
@ -1,6 +1,7 @@
|
|||||||
### 0.17.1 - January 2025
|
### 0.17.1 - December 2024
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- Fixes barcode scanning bug which prevents scanning of DataMatrix codes
|
||||||
- Adds "assigned to me" filter for Purchase Order list
|
- Adds "assigned to me" filter for Purchase Order list
|
||||||
- Adds "assigned to me" filter for Sales Order list
|
- Adds "assigned to me" filter for Sales Order list
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import "dart:math";
|
import "dart:math";
|
||||||
|
import "dart:typed_data";
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||||
import "package:inventree/app_colors.dart";
|
import "package:inventree/app_colors.dart";
|
||||||
@ -93,17 +95,36 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String barcode_data = code?.text ?? "";
|
Uint8List raw_data = code?.rawBytes ?? Uint8List(0);
|
||||||
|
|
||||||
|
// Reconstruct barcode from raw data
|
||||||
|
String barcode;
|
||||||
|
|
||||||
|
if (raw_data.isNotEmpty) {
|
||||||
|
barcode = "";
|
||||||
|
|
||||||
|
final buffer = StringBuffer();
|
||||||
|
|
||||||
|
for (int i = 0; i < raw_data.length; i++) {
|
||||||
|
buffer.writeCharCode(raw_data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
barcode = buffer.toString();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
barcode = code?.text ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
scanned_code = barcode_data;
|
scanned_code = barcode;
|
||||||
scanning_paused = barcode_data.isNotEmpty;
|
scanning_paused = barcode.isNotEmpty;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (barcode_data.isNotEmpty) {
|
if (barcode.isNotEmpty) {
|
||||||
handleBarcodeData(barcode_data).then((_) {
|
|
||||||
|
handleBarcodeData(barcode).then((_) {
|
||||||
if (!single_scanning && mounted) {
|
if (!single_scanning && mounted) {
|
||||||
// Resume next scan
|
// Resume next scan
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -182,13 +203,19 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
|
|||||||
|
|
||||||
String info_text = scanning_paused ? L10().barcodeScanPaused : L10().barcodeScanPause;
|
String info_text = scanning_paused ? L10().barcodeScanPaused : L10().barcodeScanPause;
|
||||||
|
|
||||||
|
String text = scanned_code.isNotEmpty ? scanned_code : info_text;
|
||||||
|
|
||||||
|
if (text.length > 50) {
|
||||||
|
text = text.substring(0, 50) + "...";
|
||||||
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: Text(
|
child: Text(
|
||||||
scanned_code.isNotEmpty ? scanned_code : info_text,
|
text,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user