using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Comal.Classes; using InABox.Configuration; using InABox.Core; using InABox.Mobile; using Syncfusion.OfficeChart.Implementation; using Xamarin.Forms; using Xamarin.Forms.Xaml; using XF.Material.Forms; using XF.Material.Forms.UI; using XF.Material.Forms.UI.Dialogs; namespace PRS.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class DeliveryModule { private DeliveryItemBarcodeModel _deliveryitems; private Task _cache; public DeliveryModule() { InitializeComponent(); _deliveryitems = new DeliveryItemBarcodeModel(App.Data, null); _cache = Task.Run(() => _deliveryitems.Refresh(false)); } private void DeliveryScanner_OnTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args) { var scannerPage = new ScannerPage(); scannerPage.ItemScanned = async (e) => { Device.BeginInvokeOnMainThread(() => { ProgressVisible = true; _cache.Wait(); var barcode = _deliveryitems.FirstOrDefault(x => String.Equals(x.Barcode, e.Text)); if (barcode != null) Navigation.PushAsync(new FrameDetailsPage(barcode.ID)); else DisplayAlert("ERROR", "Barcode not found!", "OK"); ProgressVisible = false; }); }; Navigation.PushAsync(scannerPage); } private void DeliveryList_OnTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args) { Navigation.PushAsync(new DeliveryList()); } } }