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 is MobileCard card) && (card.BindingContext is IModuleMenuItem module) && module.IsEnabled) { card.Scale = 0.5; await card.ScaleTo(1, 150); module.Tap(); } } catch (Exception err) { MobileLogging.Log(err,"MobileToolGrid"); } AfterTap?.Invoke(this, EventArgs.Empty); debounce = false; } } }