using Comal.Classes; using InABox.Clients; using InABox.Core; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Xamarin.Essentials; using Xamarin.Forms; using ZXing; using Xamarin.Forms.PlatformConfiguration.AndroidSpecific; using XF.Material.Forms.UI.Dialogs; using comal.timesheets.QAForms; using InABox.Mobile; using LogType = InABox.Core.LogType; namespace comal.timesheets { public class ScannerPageItemScannedArgs : EventArgs { public String Text { get; set; } public ScannerPageItemScannedArgs(String text) { Text = text; } } public partial class ScannerPage { bool bProcessing = false; public Func ItemScanned; public ScannerPage() { InitializeComponent(); var options = new ZXing.Mobile.MobileBarcodeScanningOptions() { PossibleFormats = new List() { ZXing.BarcodeFormat.QR_CODE }, AutoRotate = false, TryInverted = true, TryHarder = true, }; _scanView.Options = options; _scanView.IsAnalyzing = false; _scanView.IsScanning = true; } protected override void OnAppearing() { base.OnAppearing(); _scanView.IsAnalyzing = true; } protected override void OnDisappearing() { _scanView.IsAnalyzing = false; base.OnDisappearing(); } public async void _scanView_OnScanResult(ZXing.Result result) { if (bProcessing) return; bProcessing = true; Vibration.Vibrate(); if (ItemScanned != null) await ItemScanned?.Invoke(new ScannerPageItemScannedArgs(result.Text))!; bProcessing = false; } } }