From 517fea788ddcef9dcdb5975f3827c3e66ec73f40 Mon Sep 17 00:00:00 2001 From: keplyx Date: Mon, 16 Sep 2019 00:10:14 +0200 Subject: [PATCH] Added intro slide on update, changed planning event display on click --- App.js | 17 ++++++++++++----- components/CustomIntroSlider.js | 19 +++++++++++++++---- screens/PlanningScreen.js | 18 +++++++++++++----- translations/en.json | 4 ++++ translations/fr.json | 4 ++++ utils/AsyncStorageManager.js | 5 +++++ 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/App.js b/App.js index 428006c..8d67624 100644 --- a/App.js +++ b/App.js @@ -20,6 +20,7 @@ type Props = {}; type State = { isLoading: boolean, showIntro: boolean, + showUpdate: boolean, currentTheme: ?Object, }; @@ -28,6 +29,7 @@ export default class App extends React.Component { state = { isLoading: true, showIntro: true, + showUpdate: true, currentTheme: null, }; @@ -47,11 +49,15 @@ export default class App extends React.Component { } /** - * Callback when user ends the intro. Save in preferences to avaoid showing back the slides + * Callback when user ends the intro. Save in preferences to avaoid showing back the introSlides */ onIntroDone() { - this.setState({showIntro: false}); + this.setState({ + showIntro: false, + showUpdate: false, + }); AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0'); + AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate1.key, '0'); } async loadAssetsAsync() { @@ -73,7 +79,8 @@ export default class App extends React.Component { this.setState({ isLoading: false, currentTheme: ThemeManager.getCurrentTheme(), - showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1' + showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1', + showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate1.current === '1' // showIntro: true }); } @@ -91,8 +98,8 @@ export default class App extends React.Component { /> ); } - if (this.state.showIntro) { - return this.onIntroDone()}/>; + if (this.state.showIntro || this.state.showUpdate) { + return this.onIntroDone()} isUpdate={this.state.showUpdate && !this.state.showIntro}/>; } else { const AppNavigator = createAppContainerWithInitialRoute(AsyncStorageManager.getInstance().preferences.defaultStartScreen.current); return ( diff --git a/components/CustomIntroSlider.js b/components/CustomIntroSlider.js index 69eb4db..47b1c3e 100644 --- a/components/CustomIntroSlider.js +++ b/components/CustomIntroSlider.js @@ -39,15 +39,17 @@ const styles = StyleSheet.create({ type Props = { onDone: Function, + isUpdate: boolean }; export default class CustomIntroSlider extends React.Component { - slides: Array; + introSlides: Array; + updateSlides: Array; constructor() { super(); - this.slides = [ + this.introSlides = [ { key: '1', title: i18n.t('intro.slide1.title'), @@ -91,11 +93,20 @@ export default class CustomIntroSlider extends React.Component { colors: ['#37c13e', '#26852b'], }, ]; + this.updateSlides = [ + { + key: '1', + title: i18n.t('intro.updateSlide.title'), + text: i18n.t('intro.updateSlide.text'), + icon: 'calendar-range', + colors: ['#e01928', '#be1522'], + }, + ] } /** - * Render item to be used for the intro slides + * Render item to be used for the intro introSlides * @param item * @param dimensions */ @@ -125,7 +136,7 @@ export default class CustomIntroSlider extends React.Component { render() { return ( CustomIntroSlider.getIntroRenderItem(item, dimensions)} - slides={this.slides} onDone={() => this.props.onDone()} bottomButton showSkipButton/> + slides={this.props.isUpdate ? this.updateSlides : this.introSlides} onDone={() => this.props.onDone()} bottomButton showSkipButton/> ); } diff --git a/screens/PlanningScreen.js b/screens/PlanningScreen.js index 3fba0d0..9afd131 100644 --- a/screens/PlanningScreen.js +++ b/screens/PlanningScreen.js @@ -60,7 +60,7 @@ export default class PlanningScreen extends React.Component { state = { modalCurrentDisplayItem: {}, refreshing: false, - agendaItems: {} + agendaItems: {}, }; getCurrentDate() { @@ -124,7 +124,7 @@ export default class PlanningScreen extends React.Component { showItemDetails(item: Object) { this.setState({ - modalCurrentDisplayItem: item + modalCurrentDisplayItem: item, }); if (this.modalRef.current) { this.modalRef.current.open(); @@ -203,7 +203,7 @@ export default class PlanningScreen extends React.Component { _onRefresh = () => { let canRefresh; if (this.lastRefresh !== undefined) - canRefresh = (new Date().getTime() - this.lastRefresh.getTime())/1000 > this.minTimeBetweenRefresh; + canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh; else canRefresh = true; @@ -292,6 +292,12 @@ export default class PlanningScreen extends React.Component { return array[0] + ':' + array[1]; } + onModalClosed() { + this.setState({ + modalCurrentDisplayItem: {}, + }); + } + render() { const nav = this.props.navigation; return ( @@ -299,7 +305,9 @@ export default class PlanningScreen extends React.Component { + }} + adjustToContentHeight + onClosed={() => this.onModalClosed()}> {this.getModalContent()} { // initially selected day selected={this.getCurrentDate()} // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined - minDate={"2019-09-01"} + minDate={this.getCurrentDate()} // Max amount of months allowed to scroll to the past. Default = 50 pastScrollRange={1} // Max amount of months allowed to scroll to the future. Default = 50 diff --git a/translations/en.json b/translations/en.json index d2b3fc5..fa999c6 100644 --- a/translations/en.json +++ b/translations/en.json @@ -33,6 +33,10 @@ "slide6": { "title": "More to come...", "text": "New features are coming soon, do not hesitate to give us feedback to improve the app" + }, + "updateSlide": { + "title": "New in this update!", + "text": "Discover every event occurring on the campus in the new Planning screen!" } }, "settingsScreen": { diff --git a/translations/fr.json b/translations/fr.json index 864317c..ed666bc 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -33,6 +33,10 @@ "slide6": { "title": "Plus à venir...", "text": "D'autres fonctionnalités arrivent bientôt, n'hésitez pas à nous donner votre avis pour améliorer l'appli" + }, + "updateSlide": { + "title": "Nouveau dans cette mise à jour !", + "text": "Découvre tous les événements du campus dans la nouvelle section Planning !" } }, "settingsScreen": { diff --git a/utils/AsyncStorageManager.js b/utils/AsyncStorageManager.js index 7f432cb..3c7016f 100644 --- a/utils/AsyncStorageManager.js +++ b/utils/AsyncStorageManager.js @@ -29,6 +29,11 @@ export default class AsyncStorageManager { default: '1', current: '', }, + showUpdate1: { + key: 'showUpdate1', + default: '1', + current: '', + }, proxiwashNotifications: { key: 'proxiwashNotifications', default: '5',