2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 18:25:26 +00:00

Add overlay text to barcode scanner view

This commit is contained in:
Oliver Walters
2021-02-15 21:14:24 +11:00
parent 80247f84c1
commit 47e4e13878
3 changed files with 32 additions and 3 deletions

View File

@ -28,6 +28,8 @@ class BarcodeHandler {
* based on the response returned from the InvenTree server
*/
String getOverlayText(BuildContext context) => "Barcode Overlay";
BarcodeHandler();
QRViewController _controller;
@ -132,6 +134,9 @@ class BarcodeScanHandler extends BarcodeHandler {
* Scan *any* barcode without context, and then redirect app to correct view
*/
@override
String getOverlayText(BuildContext context) => I18N.of(context).barcodeScanGeneral;
@override
Future<void> onBarcodeUnknown(Map<String, dynamic> data) {
showErrorDialog(
@ -220,6 +225,9 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
StockItemBarcodeAssignmentHandler(this.item);
@override
String getOverlayText(BuildContext context) => I18N.of(context).barcodeScanAssign;
@override
Future<void> onBarcodeMatched(Map<String, dynamic> data) {
// If the barcode is known, we can't asisgn it to the stock item!
@ -324,7 +332,7 @@ class _QRViewState extends State<InvenTreeQRView> {
this.context = context;
return Scaffold(
body: Column(
body: Stack(
children: <Widget>[
Expanded(
flex: 4,
@ -339,6 +347,21 @@ class _QRViewState extends State<InvenTreeQRView> {
cutOutSize: 300,
),
)
),
Center(
child: Column(
children: [
Spacer(),
Padding(
child: Text(_handler.getOverlayText(context),
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
),
padding: EdgeInsets.all(20),
),
]
)
)
],
)
@ -356,6 +379,9 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler {
StockItemScanIntoLocationHandler(this.item);
@override
String getOverlayText(BuildContext context) => I18N.of(context).barcodeScanLocation;
@override
Future<void> onBarcodeMatched(Map<String, dynamic> data) {
// If the barcode points to a 'stocklocation', great!