2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-12-03 18:59:50 +00:00

Add zoom slider to barcode scanning (#725)

This commit is contained in:
Alexander Leisentritt
2025-11-19 20:44:02 +01:00
committed by GitHub
parent 8a4750d298
commit a75245b183

View File

@@ -41,6 +41,8 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
String scanned_code = "";
double zoomFactor = 0.0;
final MobileScannerController controller = MobileScannerController(
autoZoom: true,
);
@@ -311,6 +313,60 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
return SpeedDial(icon: Icons.more_horiz, children: actions);
}
Widget zoomSlider() {
return Positioned(
left: 0,
right: 0,
bottom: 16,
child: Center(
child: Container(
width: 225,
height: 56,
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(28),
),
padding: EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Icon(TablerIcons.zoom_out, color: Colors.white, size: 20),
Expanded(
child: Slider(
value: zoomFactor,
min: 0.0,
max: 1.0,
activeColor: Colors.white,
inactiveColor: Colors.white.withValues(alpha: 0.3),
onChanged: (value) {
setState(() {
zoomFactor = value;
controller.setZoomScale(value);
});
},
onChangeStart: (value) async {
if (mounted) {
setState(() {
scanning_paused = true;
});
}
},
onChangeEnd: (value) async {
if (mounted) {
setState(() {
scanning_paused = false;
});
}
},
),
),
Icon(TablerIcons.zoom_in, color: Colors.white, size: 20),
],
),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -333,6 +389,7 @@ class _CameraBarcodeControllerState extends InvenTreeBarcodeControllerState {
Column(children: [Expanded(child: BarcodeReader(context))]),
topCenterOverlay(),
bottomCenterOverlay(),
zoomSlider(),
],
),
),