Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AprilFoolsManager.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // @flow
  2. import type {Machine} from "../screens/Proxiwash/ProxiwashScreen";
  3. /**
  4. * Singleton class used to manage april fools
  5. */
  6. export default class AprilFoolsManager {
  7. static instance: AprilFoolsManager | null = null;
  8. static fakeMachineNumber = [
  9. "",
  10. "cos(ln(1))",
  11. "0,5⁻¹",
  12. "567/189",
  13. "√2×√8",
  14. "√50×sin(9π/4)",
  15. "⌈π+e⌉",
  16. "div(rot(B))+7",
  17. "4×cosh(0)+4",
  18. "8-(-i)²",
  19. "|5√2+5√2i|",
  20. "1×10¹+1×10⁰",
  21. "Re(√192e^(iπ/6))",
  22. ];
  23. aprilFoolsEnabled: boolean;
  24. constructor() {
  25. let today = new Date();
  26. this.aprilFoolsEnabled = (today.getDate() === 1 && today.getMonth() === 3);
  27. }
  28. /**
  29. * Get this class instance or create one if none is found
  30. * @returns {ThemeManager}
  31. */
  32. static getInstance(): AprilFoolsManager {
  33. return AprilFoolsManager.instance === null ?
  34. AprilFoolsManager.instance = new AprilFoolsManager() :
  35. AprilFoolsManager.instance;
  36. }
  37. /**
  38. * Adds fake menu entries
  39. *
  40. * @param menu
  41. * @returns {Object}
  42. */
  43. static getFakeMenuItem(menu: Array<{dishes: Array<{name: string}>}>) {
  44. menu[1]["dishes"].splice(4, 0, {name: "Coq au vin"});
  45. menu[1]["dishes"].splice(2, 0, {name: "Bat'Soupe"});
  46. menu[1]["dishes"].splice(1, 0, {name: "Pave de loup"});
  47. menu[1]["dishes"].splice(0, 0, {name: "Béranger à point"});
  48. menu[1]["dishes"].splice(0, 0, {name: "Pieds d'Arnaud"});
  49. return menu;
  50. }
  51. /**
  52. * Changes proxiwash dryers order
  53. *
  54. * @param dryers
  55. */
  56. static getNewProxiwashDryerOrderedList(dryers: Array<Machine> | null) {
  57. if (dryers != null) {
  58. let second = dryers[1];
  59. dryers.splice(1, 1);
  60. dryers.push(second);
  61. }
  62. }
  63. /**
  64. * Changes proxiwash washers order
  65. *
  66. * @param washers
  67. */
  68. static getNewProxiwashWasherOrderedList(washers: Array<Machine> | null) {
  69. if (washers != null) {
  70. let first = washers[0];
  71. let second = washers[1];
  72. let fifth = washers[4];
  73. let ninth = washers[8];
  74. washers.splice(8, 1, second);
  75. washers.splice(4, 1, ninth);
  76. washers.splice(1, 1, first);
  77. washers.splice(0, 1, fifth);
  78. }
  79. }
  80. /**
  81. * Gets the new display number for the given machine number
  82. *
  83. * @param number
  84. * @returns {string}
  85. */
  86. static getProxiwashMachineDisplayNumber(number: number) {
  87. return AprilFoolsManager.fakeMachineNumber[number];
  88. }
  89. /**
  90. * Gets the new and ugly april fools theme
  91. *
  92. * @param currentTheme
  93. * @returns {{colors: {textDisabled: string, agendaDayTextColor: string, surface: string, background: string, dividerBackground: string, accent: string, agendaBackgroundColor: string, tabIcon: string, card: string, primary: string}}}
  94. */
  95. static getAprilFoolsTheme(currentTheme: Object) {
  96. return {
  97. ...currentTheme,
  98. colors: {
  99. ...currentTheme.colors,
  100. primary: '#00be45',
  101. accent: '#00be45',
  102. background: '#d02eee',
  103. tabIcon: "#380d43",
  104. card: "#eed639",
  105. surface: "#eed639",
  106. dividerBackground: '#c72ce4',
  107. textDisabled: '#b9b9b9',
  108. // Calendar/Agenda
  109. agendaBackgroundColor: '#c72ce4',
  110. agendaDayTextColor: '#6d6d6d',
  111. },
  112. };
  113. }
  114. isAprilFoolsEnabled() {
  115. return this.aprilFoolsEnabled;
  116. }
  117. };