2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Allow toggle of camera and flash when scanning barcodes

This commit is contained in:
Oliver 2022-01-05 12:10:44 +11:00
parent d296d589d9
commit b9ee0157d2
2 changed files with 31 additions and 0 deletions

View File

@ -4,6 +4,9 @@
### 0.x.x - January 2022
---
- Enable usage of camera flash when scanning barcodes
- Enable camera toggle when scanning barcodes
- Updated icon set
- Removed "upload error report" functionality (instead link to GitHub issues)
- Updated multiple language translations

View File

@ -461,6 +461,19 @@ class _QRViewState extends State<InvenTreeQRView> {
final BarcodeHandler _handler;
bool flash_status = false;
Future<void> updateFlashStatus() async {
final bool? status = await _controller?.getFlashStatus();
flash_status = status != null && status;
// Reload
setState(() {
});
}
// In order to get hot reload to work we need to pause the camera if the platform
// is android, or resume the camera if the platform is iOS.
@override
@ -494,6 +507,21 @@ class _QRViewState extends State<InvenTreeQRView> {
return Scaffold(
appBar: AppBar(
title: Text(L10().scanBarcode),
actions: [
IconButton(
icon: Icon(Icons.flip_camera_android),
onPressed: () {
_controller?.flipCamera();
}
),
IconButton(
icon: flash_status ? Icon(Icons.flash_off) : Icon(Icons.flash_on),
onPressed: () {
_controller?.toggleFlash();
updateFlashStatus();
},
)
],
),
body: Stack(
children: <Widget>[