DigitalFormUtils.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Xamarin.Forms;
  2. namespace PRS.Mobile
  3. {
  4. public class DigitalFormColorSet
  5. {
  6. public Color Background { get; set; }
  7. public Color Foreground { get; set; }
  8. public Color Border { get; set; }
  9. }
  10. public static class DigitalFormUtils
  11. {
  12. private static DigitalFormColorSet RequiredColors => new()
  13. {
  14. Background = Color.Orange,
  15. Border = Color.Firebrick,
  16. Foreground = Color.White,
  17. };
  18. private static DigitalFormColorSet DisabledColors => new()
  19. {
  20. Background = Color.Silver,
  21. Border = Color.Gray,
  22. Foreground = Color.WhiteSmoke,
  23. };
  24. private static DigitalFormColorSet ValueColors => new()
  25. {
  26. Background = XF.Material.Forms.Material.Color.Surface,
  27. Border = XF.Material.Forms.Material.Color.SecondaryVariant,
  28. Foreground = XF.Material.Forms.Material.Color.OnSurface,
  29. };
  30. private static DigitalFormColorSet SelectorColors => new()
  31. {
  32. Background = XF.Material.Forms.Material.Color.Secondary,
  33. Border = XF.Material.Forms.Material.Color.SecondaryVariant,
  34. Foreground = XF.Material.Forms.Material.Color.OnSecondary,
  35. };
  36. public static DigitalFormColorSet GetColors(bool disabled, bool required, bool selector)
  37. {
  38. return disabled
  39. ? DisabledColors
  40. : required
  41. ? RequiredColors
  42. : selector
  43. ? SelectorColors
  44. : ValueColors;
  45. }
  46. }
  47. }