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.ts 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import type {ProxiwashMachineType} from '../screens/Proxiwash/ProxiwashScreen';
  20. import type {RuFoodCategoryType} from '../screens/Services/SelfMenuScreen';
  21. /**
  22. * Singleton class used to manage april fools
  23. */
  24. export default class AprilFoolsManager {
  25. static instance: AprilFoolsManager | null = null;
  26. static fakeMachineNumber = [
  27. '',
  28. 'cos(ln(1))',
  29. '0,5⁻¹',
  30. '567/189',
  31. '√2×√8',
  32. '√50×sin(9π/4)',
  33. '⌈π+e⌉',
  34. 'div(rot(B))+7',
  35. '4×cosh(0)+4',
  36. '8-(-i)²',
  37. '|5√2+5√2i|',
  38. '1×10¹+1×10⁰',
  39. 'Re(√192e^(iπ/6))',
  40. ];
  41. aprilFoolsEnabled: boolean;
  42. constructor() {
  43. const today = new Date();
  44. this.aprilFoolsEnabled = today.getDate() === 1 && today.getMonth() === 3;
  45. }
  46. /**
  47. * Get this class instance or create one if none is found
  48. * @returns {ThemeManager}
  49. */
  50. static getInstance(): AprilFoolsManager {
  51. if (AprilFoolsManager.instance == null) {
  52. AprilFoolsManager.instance = new AprilFoolsManager();
  53. }
  54. return AprilFoolsManager.instance;
  55. }
  56. /**
  57. * Adds fake menu entries
  58. *
  59. * @param menu
  60. * @returns {Object}
  61. */
  62. static getFakeMenuItem(
  63. menu: Array<RuFoodCategoryType>,
  64. ): Array<RuFoodCategoryType> {
  65. menu[1].dishes.splice(4, 0, {name: 'Coq au vin'});
  66. menu[1].dishes.splice(2, 0, {name: "Bat'Soupe"});
  67. menu[1].dishes.splice(1, 0, {name: 'Pave de loup'});
  68. menu[1].dishes.splice(0, 0, {name: 'Béranger à point'});
  69. menu[1].dishes.splice(0, 0, {name: "Pieds d'Arnaud"});
  70. return menu;
  71. }
  72. /**
  73. * Changes proxiwash dryers order
  74. *
  75. * @param dryers
  76. */
  77. static getNewProxiwashDryerOrderedList(
  78. dryers: Array<ProxiwashMachineType> | null,
  79. ) {
  80. if (dryers != null) {
  81. const second = dryers[1];
  82. dryers.splice(1, 1);
  83. dryers.push(second);
  84. }
  85. }
  86. /**
  87. * Changes proxiwash washers order
  88. *
  89. * @param washers
  90. */
  91. static getNewProxiwashWasherOrderedList(
  92. washers: Array<ProxiwashMachineType> | null,
  93. ) {
  94. if (washers != null) {
  95. const first = washers[0];
  96. const second = washers[1];
  97. const fifth = washers[4];
  98. const ninth = washers[8];
  99. washers.splice(8, 1, second);
  100. washers.splice(4, 1, ninth);
  101. washers.splice(1, 1, first);
  102. washers.splice(0, 1, fifth);
  103. }
  104. }
  105. /**
  106. * Gets the new display number for the given machine number
  107. *
  108. * @param number
  109. * @returns {string}
  110. */
  111. static getProxiwashMachineDisplayNumber(number: number): string {
  112. return AprilFoolsManager.fakeMachineNumber[number];
  113. }
  114. /**
  115. * Gets the new and ugly april fools theme
  116. *
  117. * @param currentTheme
  118. * @returns {{colors: {textDisabled: string, agendaDayTextColor: string, surface: string, background: string, dividerBackground: string, accent: string, agendaBackgroundColor: string, tabIcon: string, card: string, primary: string}}}
  119. */
  120. static getAprilFoolsTheme(
  121. currentTheme: ReactNativePaper.Theme,
  122. ): ReactNativePaper.Theme {
  123. return {
  124. ...currentTheme,
  125. colors: {
  126. ...currentTheme.colors,
  127. primary: '#00be45',
  128. accent: '#00be45',
  129. background: '#d02eee',
  130. tabIcon: '#380d43',
  131. card: '#eed639',
  132. surface: '#eed639',
  133. dividerBackground: '#c72ce4',
  134. textDisabled: '#b9b9b9',
  135. // Calendar/Agenda
  136. agendaBackgroundColor: '#c72ce4',
  137. agendaDayTextColor: '#6d6d6d',
  138. },
  139. };
  140. }
  141. isAprilFoolsEnabled(): boolean {
  142. return this.aprilFoolsEnabled;
  143. }
  144. }