From 47e4e13878026c2044f7b5eb317b2585c9d42bab Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 15 Feb 2021 21:14:24 +1100 Subject: [PATCH] Add overlay text to barcode scanner view --- lib/barcode.dart | 28 +++++++++++++++++++++++++++- lib/l10n | 2 +- lib/widget/location_display.dart | 5 ++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/barcode.dart b/lib/barcode.dart index a58c37b3..8345dea5 100644 --- a/lib/barcode.dart +++ b/lib/barcode.dart @@ -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 onBarcodeUnknown(Map data) { showErrorDialog( @@ -220,6 +225,9 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler { StockItemBarcodeAssignmentHandler(this.item); + @override + String getOverlayText(BuildContext context) => I18N.of(context).barcodeScanAssign; + @override Future onBarcodeMatched(Map data) { // If the barcode is known, we can't asisgn it to the stock item! @@ -324,7 +332,7 @@ class _QRViewState extends State { this.context = context; return Scaffold( - body: Column( + body: Stack( children: [ Expanded( flex: 4, @@ -339,6 +347,21 @@ class _QRViewState extends State { 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 onBarcodeMatched(Map data) { // If the barcode points to a 'stocklocation', great! diff --git a/lib/l10n b/lib/l10n index 81a41ca5..dd7073d7 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit 81a41ca5d698b540af9fd00300d3159ba943a13d +Subproject commit dd7073d7434d5359ebbf9febff4e319ca0ec2ce0 diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index b6336e53..5c26f418 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -207,10 +207,13 @@ class _LocationDisplayState extends RefreshableState { icon: FaIcon(FontAwesomeIcons.boxes), label: I18N.of(context).stock, ), + // TODO - Add in actions when they are written... + /* BottomNavigationBarItem( icon: FaIcon(FontAwesomeIcons.wrench), label: I18N.of(context).actions, ) + */ ] ); } @@ -225,7 +228,7 @@ class _LocationDisplayState extends RefreshableState { return ListView( children: stockTiles(), ); - case 1: + case 2: return ListView( children: ListTile.divideTiles( context: context,