using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Xamarin.Forms; namespace comal.timesheets { public partial class ToolEntry : Grid { public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(ToolEntry), ""); public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(ImageSource), typeof(ToolEntry), null); public ImageSource Image { get { return (ImageSource)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } } public static readonly BindableProperty IndicatorProperty = BindableProperty.Create(nameof(Indicator), typeof(string), typeof(ToolEntry), null); public string Indicator { get { return (string)GetValue(IndicatorProperty); } set { SetValue(IndicatorProperty, value); UpdateIndicator(); } } public int ID { get; set; } public event EventHandler Tapped; public ToolEntry() { InitializeComponent(); } private void UpdateIndicator() { if (!String.IsNullOrWhiteSpace(Indicator)) { indicatorLbl.Text = Indicator; indicatorFrame.IsVisible = true; Task.Run(() => { Thread.Sleep(1000); Device.BeginInvokeOnMainThread(() => { indicatorFrame.TranslateTo(0, -10, 250); indicatorFrame.TranslateTo(0, 0, 250); }); }); } else indicatorFrame.IsVisible = false; } async void ImageTapped(System.Object sender, System.EventArgs e) { await toolFrame.TranslateTo(0, -15, 150); await toolFrame.TranslateTo(0, 0, 150); Tapped?.Invoke(this, new EventArgs()); } } }