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.5KB

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