using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Xamarin.Forms; using Xamarin.Forms.Xaml; using XF.Material.Forms.UI; namespace InABox.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class MobileModuleList { public IList Items { get; } public event EventHandler BeforeTap; public event EventHandler AfterTap; public MobileModuleList() { Items = new ObservableCollection(); InitializeComponent(); Modules.ItemsSource = Items; } private bool debounce = false; private async void Module_Clicked(object sender, EventArgs e) { if (debounce) return; debounce = true; BeforeTap?.Invoke(this,EventArgs.Empty); try { if (((sender as MobileCard)?.BindingContext is IModuleMenuItem module) && module.IsEnabled) module.Tap(); } catch (Exception err) { MobileLogging.Log(err,"MobileToolGrid"); } AfterTap?.Invoke(this, EventArgs.Empty); debounce = false; } } }