forked from vergnet/application-amicale
Improve constants to match linter
This commit is contained in:
parent
7ac62b99f4
commit
7107a8eadf
5 changed files with 654 additions and 638 deletions
|
@ -1,33 +1,35 @@
|
|||
// @flow
|
||||
|
||||
import type {Machine} from "../screens/Proxiwash/ProxiwashScreen";
|
||||
import type {ProxiwashMachineType} from '../screens/Proxiwash/ProxiwashScreen';
|
||||
import type {CustomThemeType} from './ThemeManager';
|
||||
|
||||
/**
|
||||
* Singleton class used to manage april fools
|
||||
*/
|
||||
export default class AprilFoolsManager {
|
||||
|
||||
static instance: AprilFoolsManager | null = null;
|
||||
|
||||
static fakeMachineNumber = [
|
||||
"",
|
||||
"cos(ln(1))",
|
||||
"0,5⁻¹",
|
||||
"567/189",
|
||||
"√2×√8",
|
||||
"√50×sin(9π/4)",
|
||||
"⌈π+e⌉",
|
||||
"div(rot(B))+7",
|
||||
"4×cosh(0)+4",
|
||||
"8-(-i)²",
|
||||
"|5√2+5√2i|",
|
||||
"1×10¹+1×10⁰",
|
||||
"Re(√192e^(iπ/6))",
|
||||
'',
|
||||
'cos(ln(1))',
|
||||
'0,5⁻¹',
|
||||
'567/189',
|
||||
'√2×√8',
|
||||
'√50×sin(9π/4)',
|
||||
'⌈π+e⌉',
|
||||
'div(rot(B))+7',
|
||||
'4×cosh(0)+4',
|
||||
'8-(-i)²',
|
||||
'|5√2+5√2i|',
|
||||
'1×10¹+1×10⁰',
|
||||
'Re(√192e^(iπ/6))',
|
||||
];
|
||||
|
||||
aprilFoolsEnabled: boolean;
|
||||
|
||||
constructor() {
|
||||
let today = new Date();
|
||||
this.aprilFoolsEnabled = (today.getDate() === 1 && today.getMonth() === 3);
|
||||
const today = new Date();
|
||||
this.aprilFoolsEnabled = today.getDate() === 1 && today.getMonth() === 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,9 +37,9 @@ export default class AprilFoolsManager {
|
|||
* @returns {ThemeManager}
|
||||
*/
|
||||
static getInstance(): AprilFoolsManager {
|
||||
return AprilFoolsManager.instance === null ?
|
||||
AprilFoolsManager.instance = new AprilFoolsManager() :
|
||||
AprilFoolsManager.instance;
|
||||
if (AprilFoolsManager.instance == null)
|
||||
AprilFoolsManager.instance = new AprilFoolsManager();
|
||||
return AprilFoolsManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,12 +48,14 @@ export default class AprilFoolsManager {
|
|||
* @param menu
|
||||
* @returns {Object}
|
||||
*/
|
||||
static getFakeMenuItem(menu: Array<{dishes: Array<{name: string}>}>) {
|
||||
menu[1]["dishes"].splice(4, 0, {name: "Coq au vin"});
|
||||
menu[1]["dishes"].splice(2, 0, {name: "Bat'Soupe"});
|
||||
menu[1]["dishes"].splice(1, 0, {name: "Pave de loup"});
|
||||
menu[1]["dishes"].splice(0, 0, {name: "Béranger à point"});
|
||||
menu[1]["dishes"].splice(0, 0, {name: "Pieds d'Arnaud"});
|
||||
static getFakeMenuItem(
|
||||
menu: Array<{dishes: Array<{name: string}>}>,
|
||||
): Array<{dishes: Array<{name: string}>}> {
|
||||
menu[1].dishes.splice(4, 0, {name: 'Coq au vin'});
|
||||
menu[1].dishes.splice(2, 0, {name: "Bat'Soupe"});
|
||||
menu[1].dishes.splice(1, 0, {name: 'Pave de loup'});
|
||||
menu[1].dishes.splice(0, 0, {name: 'Béranger à point'});
|
||||
menu[1].dishes.splice(0, 0, {name: "Pieds d'Arnaud"});
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -60,9 +64,11 @@ export default class AprilFoolsManager {
|
|||
*
|
||||
* @param dryers
|
||||
*/
|
||||
static getNewProxiwashDryerOrderedList(dryers: Array<Machine> | null) {
|
||||
static getNewProxiwashDryerOrderedList(
|
||||
dryers: Array<ProxiwashMachineType> | null,
|
||||
) {
|
||||
if (dryers != null) {
|
||||
let second = dryers[1];
|
||||
const second = dryers[1];
|
||||
dryers.splice(1, 1);
|
||||
dryers.push(second);
|
||||
}
|
||||
|
@ -73,12 +79,14 @@ export default class AprilFoolsManager {
|
|||
*
|
||||
* @param washers
|
||||
*/
|
||||
static getNewProxiwashWasherOrderedList(washers: Array<Machine> | null) {
|
||||
static getNewProxiwashWasherOrderedList(
|
||||
washers: Array<ProxiwashMachineType> | null,
|
||||
) {
|
||||
if (washers != null) {
|
||||
let first = washers[0];
|
||||
let second = washers[1];
|
||||
let fifth = washers[4];
|
||||
let ninth = washers[8];
|
||||
const first = washers[0];
|
||||
const second = washers[1];
|
||||
const fifth = washers[4];
|
||||
const ninth = washers[8];
|
||||
washers.splice(8, 1, second);
|
||||
washers.splice(4, 1, ninth);
|
||||
washers.splice(1, 1, first);
|
||||
|
@ -92,7 +100,7 @@ export default class AprilFoolsManager {
|
|||
* @param number
|
||||
* @returns {string}
|
||||
*/
|
||||
static getProxiwashMachineDisplayNumber(number: number) {
|
||||
static getProxiwashMachineDisplayNumber(number: number): string {
|
||||
return AprilFoolsManager.fakeMachineNumber[number];
|
||||
}
|
||||
|
||||
|
@ -102,7 +110,7 @@ export default class AprilFoolsManager {
|
|||
* @param currentTheme
|
||||
* @returns {{colors: {textDisabled: string, agendaDayTextColor: string, surface: string, background: string, dividerBackground: string, accent: string, agendaBackgroundColor: string, tabIcon: string, card: string, primary: string}}}
|
||||
*/
|
||||
static getAprilFoolsTheme(currentTheme: Object) {
|
||||
static getAprilFoolsTheme(currentTheme: CustomThemeType): CustomThemeType {
|
||||
return {
|
||||
...currentTheme,
|
||||
colors: {
|
||||
|
@ -110,9 +118,9 @@ export default class AprilFoolsManager {
|
|||
primary: '#00be45',
|
||||
accent: '#00be45',
|
||||
background: '#d02eee',
|
||||
tabIcon: "#380d43",
|
||||
card: "#eed639",
|
||||
surface: "#eed639",
|
||||
tabIcon: '#380d43',
|
||||
card: '#eed639',
|
||||
surface: '#eed639',
|
||||
dividerBackground: '#c72ce4',
|
||||
textDisabled: '#b9b9b9',
|
||||
|
||||
|
@ -123,8 +131,7 @@ export default class AprilFoolsManager {
|
|||
};
|
||||
}
|
||||
|
||||
isAprilFoolsEnabled() {
|
||||
isAprilFoolsEnabled(): boolean {
|
||||
return this.aprilFoolsEnabled;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import {SERVICES_KEY} from "./ServicesManager";
|
||||
import {SERVICES_KEY} from './ServicesManager';
|
||||
|
||||
/**
|
||||
* Singleton used to manage preferences.
|
||||
|
@ -10,7 +10,6 @@ import {SERVICES_KEY} from "./ServicesManager";
|
|||
*/
|
||||
|
||||
export default class AsyncStorageManager {
|
||||
|
||||
static instance: AsyncStorageManager | null = null;
|
||||
|
||||
static PREFERENCES = {
|
||||
|
@ -108,7 +107,7 @@ export default class AsyncStorageManager {
|
|||
key: 'gameScores',
|
||||
default: '[]',
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#currentPreferences: {[key: string]: string};
|
||||
|
||||
|
@ -121,9 +120,61 @@ export default class AsyncStorageManager {
|
|||
* @returns {AsyncStorageManager}
|
||||
*/
|
||||
static getInstance(): AsyncStorageManager {
|
||||
return AsyncStorageManager.instance === null ?
|
||||
AsyncStorageManager.instance = new AsyncStorageManager() :
|
||||
AsyncStorageManager.instance;
|
||||
if (AsyncStorageManager.instance == null)
|
||||
AsyncStorageManager.instance = new AsyncStorageManager();
|
||||
return AsyncStorageManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the value associated to the given key to preferences.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
static set(key: string, value: number | string | boolean | {...} | []) {
|
||||
AsyncStorageManager.getInstance().setPreference(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {string}
|
||||
*/
|
||||
static getString(key: string): string {
|
||||
return AsyncStorageManager.getInstance().getPreference(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static getBool(key: string): boolean {
|
||||
const value = AsyncStorageManager.getString(key);
|
||||
return value === '1' || value === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {number}
|
||||
*/
|
||||
static getNumber(key: string): number {
|
||||
return parseFloat(AsyncStorageManager.getString(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {{...}}
|
||||
*/
|
||||
// eslint-disable-next-line flowtype/no-weak-types
|
||||
static getObject(key: string): any {
|
||||
return JSON.parse(AsyncStorageManager.getString(key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,21 +184,20 @@ export default class AsyncStorageManager {
|
|||
* @return {Promise<void>}
|
||||
*/
|
||||
async loadPreferences() {
|
||||
let prefKeys = [];
|
||||
const prefKeys = [];
|
||||
// Get all available keys
|
||||
for (let key in AsyncStorageManager.PREFERENCES) {
|
||||
Object.keys(AsyncStorageManager.PREFERENCES).forEach((key: string) => {
|
||||
prefKeys.push(key);
|
||||
}
|
||||
});
|
||||
// Get corresponding values
|
||||
let resultArray: Array<Array<string>> = await AsyncStorage.multiGet(prefKeys);
|
||||
const resultArray = await AsyncStorage.multiGet(prefKeys);
|
||||
// Save those values for later use
|
||||
for (let i = 0; i < resultArray.length; i++) {
|
||||
let key: string = resultArray[i][0];
|
||||
let val: string | null = resultArray[i][1];
|
||||
if (val === null)
|
||||
val = AsyncStorageManager.PREFERENCES[key].default;
|
||||
resultArray.forEach((item: [string, string | null]) => {
|
||||
const key = item[0];
|
||||
let val = item[1];
|
||||
if (val === null) val = AsyncStorageManager.PREFERENCES[key].default;
|
||||
this.#currentPreferences[key] = val;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,15 +207,13 @@ export default class AsyncStorageManager {
|
|||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
setPreference(key: string, value: any) {
|
||||
setPreference(key: string, value: number | string | boolean | {...} | []) {
|
||||
if (AsyncStorageManager.PREFERENCES[key] != null) {
|
||||
let convertedValue = "";
|
||||
if (typeof value === "string")
|
||||
convertedValue = value;
|
||||
else if (typeof value === "boolean" || typeof value === "number")
|
||||
let convertedValue;
|
||||
if (typeof value === 'string') convertedValue = value;
|
||||
else if (typeof value === 'boolean' || typeof value === 'number')
|
||||
convertedValue = value.toString();
|
||||
else
|
||||
convertedValue = JSON.stringify(value);
|
||||
else convertedValue = JSON.stringify(value);
|
||||
this.#currentPreferences[key] = convertedValue;
|
||||
AsyncStorage.setItem(key, convertedValue);
|
||||
}
|
||||
|
@ -178,59 +226,7 @@ export default class AsyncStorageManager {
|
|||
* @param key
|
||||
* @returns {string|null}
|
||||
*/
|
||||
getPreference(key: string) {
|
||||
getPreference(key: string): string | null {
|
||||
return this.#currentPreferences[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* aves the value associated to the given key to preferences.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
static set(key: string, value: any) {
|
||||
AsyncStorageManager.getInstance().setPreference(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static getString(key: string) {
|
||||
return AsyncStorageManager.getInstance().getPreference(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static getBool(key: string) {
|
||||
const value = AsyncStorageManager.getString(key);
|
||||
return value === "1" || value === "true";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static getNumber(key: string) {
|
||||
return parseFloat(AsyncStorageManager.getString(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object value of the given preference
|
||||
*
|
||||
* @param key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static getObject(key: string) {
|
||||
return JSON.parse(AsyncStorageManager.getString(key));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,29 +10,30 @@ export default class DateManager {
|
|||
static instance: DateManager | null = null;
|
||||
|
||||
daysOfWeek = [];
|
||||
|
||||
monthsOfYear = [];
|
||||
|
||||
constructor() {
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.sunday")); // 0 represents sunday
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.monday"));
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.tuesday"));
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.wednesday"));
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.thursday"));
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.friday"));
|
||||
this.daysOfWeek.push(i18n.t("date.daysOfWeek.saturday"));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.sunday')); // 0 represents sunday
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.monday'));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.tuesday'));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.wednesday'));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.thursday'));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.friday'));
|
||||
this.daysOfWeek.push(i18n.t('date.daysOfWeek.saturday'));
|
||||
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.january"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.february"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.march"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.april"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.may"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.june"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.july"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.august"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.september"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.october"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.november"));
|
||||
this.monthsOfYear.push(i18n.t("date.monthsOfYear.december"));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.january'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.february'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.march'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.april'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.may'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.june'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.july'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.august'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.september'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.october'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.november'));
|
||||
this.monthsOfYear.push(i18n.t('date.monthsOfYear.december'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,16 +41,15 @@ export default class DateManager {
|
|||
* @returns {DateManager}
|
||||
*/
|
||||
static getInstance(): DateManager {
|
||||
return DateManager.instance === null ?
|
||||
DateManager.instance = new DateManager() :
|
||||
DateManager.instance;
|
||||
if (DateManager.instance == null) DateManager.instance = new DateManager();
|
||||
return DateManager.instance;
|
||||
}
|
||||
|
||||
static isWeekend(date: Date) {
|
||||
static isWeekend(date: Date): boolean {
|
||||
return date.getDay() === 6 || date.getDay() === 0;
|
||||
}
|
||||
|
||||
getMonthsOfYear() {
|
||||
getMonthsOfYear(): Array<string> {
|
||||
return this.monthsOfYear;
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,16 @@ export default class DateManager {
|
|||
* @param dateString The date with the format YYYY-MM-DD
|
||||
* @return {string} The translated string
|
||||
*/
|
||||
getTranslatedDate(dateString: string) {
|
||||
let dateArray = dateString.split('-');
|
||||
let date = new Date();
|
||||
date.setFullYear(parseInt(dateArray[0]), parseInt(dateArray[1]) - 1, parseInt(dateArray[2]));
|
||||
return this.daysOfWeek[date.getDay()] + " " + date.getDate() + " " + this.monthsOfYear[date.getMonth()] + " " + date.getFullYear();
|
||||
getTranslatedDate(dateString: string): string {
|
||||
const dateArray = dateString.split('-');
|
||||
const date = new Date();
|
||||
date.setFullYear(
|
||||
parseInt(dateArray[0], 10),
|
||||
parseInt(dateArray[1], 10) - 1,
|
||||
parseInt(dateArray[2], 10),
|
||||
);
|
||||
return `${this.daysOfWeek[date.getDay()]} ${date.getDate()} ${
|
||||
this.monthsOfYear[date.getMonth()]
|
||||
} ${date.getFullYear()}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
// @flow
|
||||
|
||||
import i18n from 'i18n-js';
|
||||
import * as RNLocalize from "react-native-localize";
|
||||
import * as RNLocalize from 'react-native-localize';
|
||||
|
||||
import en from '../../locales/en';
|
||||
import en from '../../locales/en.json';
|
||||
import fr from '../../locales/fr.json';
|
||||
|
||||
/**
|
||||
* Static class used to manage locales
|
||||
*/
|
||||
export default class LocaleManager {
|
||||
|
||||
/**
|
||||
* Initialize translations using language files
|
||||
*/
|
||||
static initTranslations() {
|
||||
i18n.fallbacks = true;
|
||||
i18n.translations = {fr, en};
|
||||
i18n.locale = RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
|
||||
i18n.locale = RNLocalize.findBestAvailableLanguage([
|
||||
'en',
|
||||
'fr',
|
||||
]).languageTag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// @flow
|
||||
|
||||
import AsyncStorageManager from "./AsyncStorageManager";
|
||||
import {DarkTheme, DefaultTheme} from 'react-native-paper';
|
||||
import AprilFoolsManager from "./AprilFoolsManager";
|
||||
import {Appearance} from 'react-native-appearance';
|
||||
import AsyncStorageManager from './AsyncStorageManager';
|
||||
import AprilFoolsManager from './AprilFoolsManager';
|
||||
|
||||
const colorScheme = Appearance.getColorScheme();
|
||||
|
||||
export type CustomTheme = {
|
||||
export type CustomThemeType = {
|
||||
...DefaultTheme,
|
||||
colors: {
|
||||
primary: string,
|
||||
|
@ -63,15 +63,15 @@ export type CustomTheme = {
|
|||
// Mascot Popup
|
||||
mascotMessageArrow: string,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Singleton class used to manage themes
|
||||
*/
|
||||
export default class ThemeManager {
|
||||
|
||||
static instance: ThemeManager | null = null;
|
||||
updateThemeCallback: Function;
|
||||
|
||||
updateThemeCallback: null | (() => void);
|
||||
|
||||
constructor() {
|
||||
this.updateThemeCallback = null;
|
||||
|
@ -80,25 +80,25 @@ export default class ThemeManager {
|
|||
/**
|
||||
* Gets the light theme
|
||||
*
|
||||
* @return {CustomTheme} Object containing theme variables
|
||||
* @return {CustomThemeType} Object containing theme variables
|
||||
* */
|
||||
static getWhiteTheme(): CustomTheme {
|
||||
static getWhiteTheme(): CustomThemeType {
|
||||
return {
|
||||
...DefaultTheme,
|
||||
colors: {
|
||||
...DefaultTheme.colors,
|
||||
primary: '#be1522',
|
||||
accent: '#be1522',
|
||||
tabIcon: "#929292",
|
||||
card: "#fff",
|
||||
tabIcon: '#929292',
|
||||
card: '#fff',
|
||||
dividerBackground: '#e2e2e2',
|
||||
ripple: "rgba(0,0,0,0.2)",
|
||||
ripple: 'rgba(0,0,0,0.2)',
|
||||
textDisabled: '#c1c1c1',
|
||||
icon: '#5d5d5d',
|
||||
subtitle: '#707070',
|
||||
success: "#5cb85c",
|
||||
warning: "#f0ad4e",
|
||||
danger: "#d9534f",
|
||||
success: '#5cb85c',
|
||||
warning: '#f0ad4e',
|
||||
danger: '#d9534f',
|
||||
cc: 'dst',
|
||||
|
||||
// Calendar/Agenda
|
||||
|
@ -106,14 +106,14 @@ export default class ThemeManager {
|
|||
agendaDayTextColor: '#636363',
|
||||
|
||||
// PROXIWASH
|
||||
proxiwashFinishedColor: "#a5dc9d",
|
||||
proxiwashReadyColor: "transparent",
|
||||
proxiwashRunningColor: "#a0ceff",
|
||||
proxiwashRunningNotStartedColor: "#c9e0ff",
|
||||
proxiwashRunningBgColor: "#c7e3ff",
|
||||
proxiwashBrokenColor: "#ffa8a2",
|
||||
proxiwashErrorColor: "#ffa8a2",
|
||||
proxiwashUnknownColor: "#b6b6b6",
|
||||
proxiwashFinishedColor: '#a5dc9d',
|
||||
proxiwashReadyColor: 'transparent',
|
||||
proxiwashRunningColor: '#a0ceff',
|
||||
proxiwashRunningNotStartedColor: '#c9e0ff',
|
||||
proxiwashRunningBgColor: '#c7e3ff',
|
||||
proxiwashBrokenColor: '#ffa8a2',
|
||||
proxiwashErrorColor: '#ffa8a2',
|
||||
proxiwashUnknownColor: '#b6b6b6',
|
||||
|
||||
// Screens
|
||||
planningColor: '#d9b10a',
|
||||
|
@ -133,12 +133,12 @@ export default class ThemeManager {
|
|||
tetrisJ: '#2a67e3',
|
||||
tetrisL: '#da742d',
|
||||
|
||||
gameGold: "#ffd610",
|
||||
gameSilver: "#7b7b7b",
|
||||
gameBronze: "#a15218",
|
||||
gameGold: '#ffd610',
|
||||
gameSilver: '#7b7b7b',
|
||||
gameBronze: '#a15218',
|
||||
|
||||
// Mascot Popup
|
||||
mascotMessageArrow: "#dedede",
|
||||
mascotMessageArrow: '#dedede',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -146,40 +146,40 @@ export default class ThemeManager {
|
|||
/**
|
||||
* Gets the dark theme
|
||||
*
|
||||
* @return {CustomTheme} Object containing theme variables
|
||||
* @return {CustomThemeType} Object containing theme variables
|
||||
* */
|
||||
static getDarkTheme(): CustomTheme {
|
||||
static getDarkTheme(): CustomThemeType {
|
||||
return {
|
||||
...DarkTheme,
|
||||
colors: {
|
||||
...DarkTheme.colors,
|
||||
primary: '#be1522',
|
||||
accent: '#be1522',
|
||||
tabBackground: "#181818",
|
||||
tabIcon: "#6d6d6d",
|
||||
card: "rgb(18,18,18)",
|
||||
tabBackground: '#181818',
|
||||
tabIcon: '#6d6d6d',
|
||||
card: 'rgb(18,18,18)',
|
||||
dividerBackground: '#222222',
|
||||
ripple: "rgba(255,255,255,0.2)",
|
||||
ripple: 'rgba(255,255,255,0.2)',
|
||||
textDisabled: '#5b5b5b',
|
||||
icon: '#b3b3b3',
|
||||
subtitle: '#aaaaaa',
|
||||
success: "#5cb85c",
|
||||
warning: "#f0ad4e",
|
||||
danger: "#d9534f",
|
||||
success: '#5cb85c',
|
||||
warning: '#f0ad4e',
|
||||
danger: '#d9534f',
|
||||
|
||||
// Calendar/Agenda
|
||||
agendaBackgroundColor: '#171717',
|
||||
agendaDayTextColor: '#6d6d6d',
|
||||
|
||||
// PROXIWASH
|
||||
proxiwashFinishedColor: "#31682c",
|
||||
proxiwashReadyColor: "transparent",
|
||||
proxiwashRunningColor: "#213c79",
|
||||
proxiwashRunningNotStartedColor: "#1e263e",
|
||||
proxiwashRunningBgColor: "#1a2033",
|
||||
proxiwashBrokenColor: "#7e2e2f",
|
||||
proxiwashErrorColor: "#7e2e2f",
|
||||
proxiwashUnknownColor: "#535353",
|
||||
proxiwashFinishedColor: '#31682c',
|
||||
proxiwashReadyColor: 'transparent',
|
||||
proxiwashRunningColor: '#213c79',
|
||||
proxiwashRunningNotStartedColor: '#1e263e',
|
||||
proxiwashRunningBgColor: '#1a2033',
|
||||
proxiwashBrokenColor: '#7e2e2f',
|
||||
proxiwashErrorColor: '#7e2e2f',
|
||||
proxiwashUnknownColor: '#535353',
|
||||
|
||||
// Screens
|
||||
planningColor: '#d99e09',
|
||||
|
@ -199,12 +199,12 @@ export default class ThemeManager {
|
|||
tetrisJ: '#0f37b9',
|
||||
tetrisL: '#b96226',
|
||||
|
||||
gameGold: "#ffd610",
|
||||
gameSilver: "#7b7b7b",
|
||||
gameBronze: "#a15218",
|
||||
gameGold: '#ffd610',
|
||||
gameSilver: '#7b7b7b',
|
||||
gameBronze: '#a15218',
|
||||
|
||||
// Mascot Popup
|
||||
mascotMessageArrow: "#323232",
|
||||
mascotMessageArrow: '#323232',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -215,9 +215,9 @@ export default class ThemeManager {
|
|||
* @returns {ThemeManager}
|
||||
*/
|
||||
static getInstance(): ThemeManager {
|
||||
return ThemeManager.instance === null ?
|
||||
ThemeManager.instance = new ThemeManager() :
|
||||
ThemeManager.instance;
|
||||
if (ThemeManager.instance == null)
|
||||
ThemeManager.instance = new ThemeManager();
|
||||
return ThemeManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,34 +228,39 @@ export default class ThemeManager {
|
|||
* @returns {boolean} Night mode state
|
||||
*/
|
||||
static getNightMode(): boolean {
|
||||
return (AsyncStorageManager.getBool(AsyncStorageManager.PREFERENCES.nightMode.key) &&
|
||||
(!AsyncStorageManager.getBool(AsyncStorageManager.PREFERENCES.nightModeFollowSystem.key)
|
||||
|| colorScheme === 'no-preference')) ||
|
||||
(AsyncStorageManager.getBool(AsyncStorageManager.PREFERENCES.nightModeFollowSystem.key)
|
||||
&& colorScheme === 'dark');
|
||||
return (
|
||||
(AsyncStorageManager.getBool(
|
||||
AsyncStorageManager.PREFERENCES.nightMode.key,
|
||||
) &&
|
||||
(!AsyncStorageManager.getBool(
|
||||
AsyncStorageManager.PREFERENCES.nightModeFollowSystem.key,
|
||||
) ||
|
||||
colorScheme === 'no-preference')) ||
|
||||
(AsyncStorageManager.getBool(
|
||||
AsyncStorageManager.PREFERENCES.nightModeFollowSystem.key,
|
||||
) &&
|
||||
colorScheme === 'dark')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current theme based on night mode and events
|
||||
*
|
||||
* @returns {CustomTheme} The current theme
|
||||
* @returns {CustomThemeType} The current theme
|
||||
*/
|
||||
static getCurrentTheme(): CustomTheme {
|
||||
static getCurrentTheme(): CustomThemeType {
|
||||
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||
return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getWhiteTheme());
|
||||
else
|
||||
return ThemeManager.getBaseTheme()
|
||||
return ThemeManager.getBaseTheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the theme based on night mode
|
||||
*
|
||||
* @return {CustomTheme} The theme
|
||||
* @return {CustomThemeType} The theme
|
||||
*/
|
||||
static getBaseTheme(): CustomTheme {
|
||||
if (ThemeManager.getNightMode())
|
||||
return ThemeManager.getDarkTheme();
|
||||
else
|
||||
static getBaseTheme(): CustomThemeType {
|
||||
if (ThemeManager.getNightMode()) return ThemeManager.getDarkTheme();
|
||||
return ThemeManager.getWhiteTheme();
|
||||
}
|
||||
|
||||
|
@ -274,9 +279,10 @@ export default class ThemeManager {
|
|||
* @param isNightMode True to enable night mode, false to disable
|
||||
*/
|
||||
setNightMode(isNightMode: boolean) {
|
||||
AsyncStorageManager.set(AsyncStorageManager.PREFERENCES.nightMode.key, isNightMode);
|
||||
if (this.updateThemeCallback != null)
|
||||
this.updateThemeCallback();
|
||||
AsyncStorageManager.set(
|
||||
AsyncStorageManager.PREFERENCES.nightMode.key,
|
||||
isNightMode,
|
||||
);
|
||||
if (this.updateThemeCallback != null) this.updateThemeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue