MobileModuleItem.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.ComponentModel;
  3. using System.Runtime.CompilerServices;
  4. using Xamarin.Forms;
  5. namespace InABox.Mobile
  6. {
  7. public class ModuleMenuItemTappedArgs :EventArgs
  8. {
  9. }
  10. public delegate void ModuleMenuItemTapped(MobileModuleItem sender, ModuleMenuItemTappedArgs args);
  11. public interface IModuleMenuItem
  12. {
  13. String Header { get; set; }
  14. String Description { get; set; }
  15. ImageSource Thumbnail { get; set; }
  16. bool IsEnabled { get; set; }
  17. bool IsVisible { get; set; }
  18. event ModuleMenuItemTapped Tapped;
  19. void Tap();
  20. }
  21. public class MobileModuleItem : BindableObject, IModuleMenuItem
  22. {
  23. public static readonly BindableProperty HeaderProperty =
  24. BindableProperty.Create(nameof(Header), typeof(String), typeof(MobileModuleItem), "");
  25. public string Header
  26. {
  27. get => (String)GetValue(HeaderProperty);
  28. set => SetValue(HeaderProperty, value);
  29. }
  30. public static readonly BindableProperty DescriptionProperty =
  31. BindableProperty.Create(nameof(Description), typeof(String), typeof(MobileModuleItem), "");
  32. public string Description
  33. {
  34. get => (String)GetValue(DescriptionProperty);
  35. set => SetValue(DescriptionProperty, value);
  36. }
  37. public static readonly BindableProperty ThumbnailProperty =
  38. BindableProperty.Create(nameof(Thumbnail), typeof(ImageSource), typeof(MobileModuleItem), null);
  39. public ImageSource Thumbnail
  40. {
  41. get => (ImageSource)GetValue(ThumbnailProperty);
  42. set => SetValue(ThumbnailProperty, value);
  43. }
  44. public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
  45. nameof(BackgroundColor),
  46. typeof(Color),
  47. typeof(MobileModuleItem),
  48. XF.Material.Forms.Material.Color.Surface);
  49. public Color BackgroundColor
  50. {
  51. get => (Color)GetValue(BackgroundColorProperty);
  52. set => SetValue(BackgroundColorProperty, value);
  53. }
  54. public static readonly BindableProperty BorderColorProperty = BindableProperty.Create(
  55. nameof(BorderColor),
  56. typeof(Color),
  57. typeof(MobileModuleItem),
  58. XF.Material.Forms.Material.Color.SecondaryVariant);
  59. public Color BorderColor
  60. {
  61. get => (Color)GetValue(BorderColorProperty);
  62. set => SetValue(BorderColorProperty, value);
  63. }
  64. public static readonly BindableProperty TextColorProperty = BindableProperty.Create(
  65. nameof(TextColor),
  66. typeof(Color),
  67. typeof(MobileModuleItem),
  68. XF.Material.Forms.Material.Color.OnSurface);
  69. public Color TextColor
  70. {
  71. get => (Color)GetValue(TextColorProperty);
  72. set => SetValue(TextColorProperty, value);
  73. }
  74. public static readonly BindableProperty IsEnabledProperty =
  75. BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(MobileModuleItem), true);
  76. public bool IsEnabled
  77. {
  78. get => (bool)GetValue(IsEnabledProperty);
  79. set => SetValue(IsEnabledProperty, value);
  80. }
  81. public static readonly BindableProperty IsVisibleProperty =
  82. BindableProperty.Create(nameof(IsVisible), typeof(bool), typeof(MobileModuleItem), true);
  83. public bool IsVisible
  84. {
  85. get => (bool)GetValue(IsVisibleProperty);
  86. set => SetValue(IsVisibleProperty, value);
  87. }
  88. public event ModuleMenuItemTapped Tapped;
  89. public void Tap() => Tapped?.Invoke(this, new ModuleMenuItemTappedArgs());
  90. }
  91. }