From a75245b183f473b9e8b8d1e29cfc05f67cd6329c Mon Sep 17 00:00:00 2001 From: Alexander Leisentritt Date: Wed, 19 Nov 2025 20:44:02 +0100 Subject: [PATCH] Add zoom slider to barcode scanning (#725) --- lib/barcode/camera_controller.dart | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/barcode/camera_controller.dart b/lib/barcode/camera_controller.dart index c4567210..0cfe9cbd 100644 --- a/lib/barcode/camera_controller.dart +++ b/lib/barcode/camera_controller.dart @@ -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(), ], ), ),