diff --git a/app.json b/app.json index a276e0e..8d5e3b8 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,7 @@ "android", "web" ], - "version": "1.0.3", + "version": "1.1.0", "orientation": "portrait", "primaryColor": "#be1522", "icon": "./assets/android.icon.png", @@ -36,7 +36,7 @@ }, "android": { "package": "fr.amicaleinsat.application", - "versionCode": 6, + "versionCode": 7, "icon": "./assets/android.icon.png", "adaptiveIcon": { "foregroundImage": "./assets/android.adaptive-icon.png", diff --git a/components/BaseContainer.js b/components/BaseContainer.js index 0480dda..7a11829 100644 --- a/components/BaseContainer.js +++ b/components/BaseContainer.js @@ -16,6 +16,7 @@ type Props = { headerRightButton: React.Node, children: React.Node, hasTabs: boolean, + hasBackButton: boolean } type State = { @@ -30,6 +31,7 @@ export default class BaseContainer extends React.Component { static defaultProps = { headerRightButton: , hasTabs: false, + hasBackButton: false, }; @@ -90,7 +92,8 @@ export default class BaseContainer extends React.Component { } rightButton={this.props.headerRightButton} - hasTabs={this.props.hasTabs}/> + hasTabs={this.props.hasTabs} + hasBackButton={this.props.hasBackButton}/> {this.props.children} diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index b190e11..0a857d3 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -260,6 +260,10 @@ export default class FetchedDataSectionList extends React.Component } @@ -277,6 +281,7 @@ export default class FetchedDataSectionList extends React.Component + hasTabs={this.hasTabs()} + hasBackButton={this.hasBackButton()} + > {this.hasTabs() ? { +export default class SelfMenuScreen extends FetchedDataSectionList { - webview: WebView; - customInjectedJS: string; + // Hard code strings as toLocaleDateString does not work on current android JS engine + daysOfWeek = []; + monthsOfYear = []; constructor() { - super(); - this.customInjectedJS = - 'document.querySelector(\'head\').innerHTML += \'\';' + - 'document.querySelector(\'head\').innerHTML += \'\';'; - if (!ThemeManager.getNightMode()) - this.customInjectedJS += 'document.querySelector(\'head\').innerHTML += \'\';'; + super(DATA_URL, 0); + 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")); + + 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")); } - getRefreshButton() { - return ( - this.refreshWebview()}> - - - ); - }; - - refreshWebview() { - this.webview.reload(); + getHeaderTranslation() { + return i18n.t("screens.menuSelf"); } - render() { - const nav = this.props.navigation; + getUpdateToastTranslations() { + return [i18n.t("homeScreen.listUpdated"), i18n.t("homeScreen.listUpdateFail")]; + } + + getKeyExtractor(item: Object) { + return item !== undefined ? item.name : undefined; + } + + hasBackButton() { + return true; + } + + createDataset(fetchedData: Object) { + let result = []; + // Prevent crash by giving a default value when fetchedData is empty (not yet available) + if (Object.keys(fetchedData).length === 0) { + result = [ + { + title: '', + data: {}, + extraData: super.state, + keyExtractor: this.getKeyExtractor + } + ]; + } + // fetched data is an array here + for (let i = 0; i < fetchedData.length; i++) { + result.push( + { + title: this.getFormattedDate(fetchedData[i].date), + data: fetchedData[i].meal[0].foodcategory, + extraData: super.state, + keyExtractor: this.getKeyExtractor + } + ); + } + return result + } + + getFormattedDate(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() - 1] + " " + date.getDate() + " " + this.monthsOfYear[date.getMonth()] + " " + date.getFullYear(); + } + + getRenderSectionHeader(title: String) { return ( - - - (this.webview = ref)} - source={{uri: RU_URL}} - style={{ - width: '100%', - height: '100%', - }} - startInLoadingState={true} - injectedJavaScript={this.customInjectedJS} - javaScriptEnabled={true} - renderLoading={() => - - - - } - /> - + +

{title}

+
); } + + getRenderItem(item: Object, section: Object, data: Object) { + return ( + + +

{item.name}

+ +
+ + {item.dishes.map((object, i) => + + {object.name !== "" ? + {object.name.toLowerCase()} + : } + )} + +
+ ); + } + } diff --git a/translations/en.json b/translations/en.json index bc782a0..e7c06da 100644 --- a/translations/en.json +++ b/translations/en.json @@ -151,5 +151,30 @@ "general": { "loading": "Loading...", "networkError": "Unable to contact servers. Make sure you are connected to Internet." + }, + "date": { + "daysOfWeek": { + "monday": "Monday", + "tuesday": "Tuesday", + "wednesday": "Wednesday", + "thursday": "Thursday", + "friday": "Friday", + "saturday": "Saturday", + "sunday": "Sunday" + }, + "monthsOfYear": { + "january": "January", + "february": "February", + "march": "March", + "april": "April", + "may": "May", + "june": "June", + "july": "July", + "august": "August", + "september": "September", + "october": "October", + "november": "November", + "december": "December" + } } } diff --git a/translations/fr.json b/translations/fr.json index 101a380..5532cf0 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -4,7 +4,7 @@ "planning": "Planning", "proxiwash": "Proxiwash", "proximo": "Proximo", - "menuSelf": "Menu Ru", + "menuSelf": "Menu du RU", "settings": "Paramètres", "about": "À Propos", "debug": "Debug" @@ -153,5 +153,30 @@ "general": { "loading": "Chargement...", "networkError": "Impossible de contacter les serveurs. Assurez vous d'être connecté à internet." + }, + "date": { + "daysOfWeek": { + "monday": "Lundi", + "tuesday": "Mardi", + "wednesday": "Mercredi", + "thursday": "Jeudi", + "friday": "Vendredi", + "saturday": "Samedi", + "sunday": "Dimanche" + }, + "monthsOfYear": { + "january": "Janvier", + "february": "Février", + "march": "Mars", + "april": "Avril", + "may": "Mai", + "june": "Juin", + "july": "Juillet", + "august": "Août", + "september": "Septembre", + "october": "Octobre", + "november": "Novembre", + "december": "Décembre" + } } }