using System; using System.Linq; using System.Threading.Tasks; using Comal.Classes; using InABox.Core; using Xamarin.Forms; using Xamarin.Forms.Xaml; using XF.Material.Forms.UI.Dialogs; namespace comal.timesheets { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class EquipmentModule { public EquipmentModule () { InitializeComponent (); } protected override void UpdateTransportStatus() { base.UpdateTransportStatus(); LiveMaps.IsEnabled = App.Data.IsConnected(); } private async void EquipmentScanner_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args) { var scannerPage = new ScannerPage(); scannerPage.ItemScanned = async (e) => { if (!Guid.TryParse(e.Text, out Guid equipmentid)) { await MaterialDialog.Instance.AlertAsync("Invalid Code", "Error"); return; } var model = new EquipmentDetailModel(App.Data, () => new Filter(x => x.ID).IsEqualTo(equipmentid)); using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Checking Code")) model.Load(); if (model.Item != null) Device.BeginInvokeOnMainThread(() => Navigation.PushAsync(new EquipmentDetailsPage(model))); else await MaterialDialog.Instance.AlertAsync("Code Not Found", "Error"); }; Navigation.PushAsync(scannerPage); } private void EquipmentList_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args) { Navigation.PushAsync(new EquipmentList()); } private void LiveMaps_Tapped(ModuleMenuItem sender, ModuleMenuItemTappedArgs args) { Navigation.PushAsync(new LiveMapsTwo()); } } }