| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 | using System;using System.ComponentModel;using System.Runtime.CompilerServices;using Xamarin.Forms;namespace InABox.Mobile{    public class ModuleMenuItemTappedArgs :EventArgs    {            }        public delegate void ModuleMenuItemTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args);        public interface IModuleMenuItem    {        String Header { get; set; }        String Description { get; set; }        ImageSource Thumbnail { get; set; }        bool IsEnabled { get; set; }        bool IsVisible { get; set; }        event ModuleMenuItemTapped Tapped;        string Alert { get; set; }        void Tap();    }        public class MobileModuleItem : BindableObject, IModuleMenuItem    {                public static readonly BindableProperty HeaderProperty =            BindableProperty.Create(nameof(Header), typeof(String), typeof(MobileModuleItem), "");        public string Header        {            get => (String)GetValue(HeaderProperty);            set => SetValue(HeaderProperty, value);        }                public static readonly BindableProperty DescriptionProperty =            BindableProperty.Create(nameof(Description), typeof(String), typeof(MobileModuleItem), "");        public string Description        {            get => (String)GetValue(DescriptionProperty);            set => SetValue(DescriptionProperty, value);        }        public static readonly BindableProperty ThumbnailProperty =            BindableProperty.Create(nameof(Thumbnail), typeof(ImageSource), typeof(MobileModuleItem), null);        public ImageSource Thumbnail        {            get => (ImageSource)GetValue(ThumbnailProperty);            set => SetValue(ThumbnailProperty, value);        }                public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(            nameof(BackgroundColor),            typeof(Color),            typeof(MobileModuleItem),            XF.Material.Forms.Material.Color.Surface);        public Color BackgroundColor        {            get => (Color)GetValue(BackgroundColorProperty);            set => SetValue(BackgroundColorProperty, value);        }        public static readonly BindableProperty BorderColorProperty = BindableProperty.Create(            nameof(BorderColor),            typeof(Color),            typeof(MobileModuleItem),            XF.Material.Forms.Material.Color.SecondaryVariant);        public Color BorderColor        {            get => (Color)GetValue(BorderColorProperty);            set => SetValue(BorderColorProperty, value);        }                public static readonly BindableProperty TextColorProperty = BindableProperty.Create(            nameof(TextColor),            typeof(Color),            typeof(MobileModuleItem),            XF.Material.Forms.Material.Color.OnSurface);        public Color TextColor        {            get => (Color)GetValue(TextColorProperty);            set => SetValue(TextColorProperty, value);        }                public static readonly BindableProperty IsEnabledProperty =            BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(MobileModuleItem), true);        public bool IsEnabled        {            get => (bool)GetValue(IsEnabledProperty);            set => SetValue(IsEnabledProperty, value);        }        public static readonly BindableProperty IsVisibleProperty =            BindableProperty.Create(nameof(IsVisible), typeof(bool), typeof(MobileModuleItem), true);        public bool IsVisible        {            get => (bool)GetValue(IsVisibleProperty);            set => SetValue(IsVisibleProperty, value);        }                public static readonly BindableProperty AlertProperty = BindableProperty.Create(            nameof(Alert),             typeof(string),             typeof(MobileModuleItem),             null);                public string Alert        {            get { return (string)GetValue(AlertProperty); }            set {                 SetValue(AlertProperty, value);                OnPropertyChanged(nameof(AlertVisible));            }        }                public bool AlertVisible => !String.IsNullOrWhiteSpace(Alert);                public event ModuleMenuItemTapped Tapped;        public void Tap() => Tapped?.Invoke(this, new ModuleMenuItemTappedArgs());    }}
 |