From c555aabd5a93526efeb9e6a471b800c8b53a7207 Mon Sep 17 00:00:00 2001 From: keplyx Date: Sun, 8 Mar 2020 13:21:14 +0100 Subject: [PATCH] Show intro slider on first start for april fools --- App.js | 17 +++++++++++++---- components/CustomIntroSlider.js | 22 +++++++++++++++++++--- translations/en.json | 4 ++++ translations/fr.json | 4 ++++ utils/AsyncStorageManager.js | 5 +++++ 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/App.js b/App.js index c491d35..0e2e740 100644 --- a/App.js +++ b/App.js @@ -12,6 +12,7 @@ import {createStackNavigator} from '@react-navigation/stack'; import DrawerNavigator from './navigation/DrawerNavigator'; import NotificationsManager from "./utils/NotificationsManager"; import {Provider as PaperProvider} from 'react-native-paper'; +import AprilFoolsManager from "./utils/AprilFoolsManager"; type Props = {}; @@ -19,6 +20,7 @@ type State = { isLoading: boolean, showIntro: boolean, showUpdate: boolean, + showAprilFools: boolean, currentTheme: ?Object, }; @@ -30,6 +32,7 @@ export default class App extends React.Component { isLoading: true, showIntro: true, showUpdate: true, + showAprilFools: false, currentTheme: null, }; @@ -68,9 +71,11 @@ export default class App extends React.Component { this.setState({ showIntro: false, showUpdate: false, + showAprilFools: false, }); AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0'); AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0'); + AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.key, '0'); } async componentDidMount() { @@ -96,7 +101,8 @@ export default class App extends React.Component { isLoading: false, currentTheme: ThemeManager.getCurrentTheme(), showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1', - showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1' + showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1', + showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.current === '1', }); // Status bar goes dark if set too fast setTimeout(this.setupStatusBar, 1000); @@ -109,9 +115,12 @@ export default class App extends React.Component { render() { if (this.state.isLoading) { return null; - } else if (this.state.showIntro || this.state.showUpdate) { - return ; + } else if (this.state.showIntro || this.state.showUpdate || this.state.showAprilFools) { + return ; } else { return ( diff --git a/components/CustomIntroSlider.js b/components/CustomIntroSlider.js index bde99f9..9ca2e50 100644 --- a/components/CustomIntroSlider.js +++ b/components/CustomIntroSlider.js @@ -39,13 +39,15 @@ const styles = StyleSheet.create({ type Props = { onDone: Function, - isUpdate: boolean + isUpdate: boolean, + isAprilFools: boolean, }; export default class CustomIntroSlider extends React.Component { introSlides: Array; updateSlides: Array; + aprilFoolsSlides: Array; constructor() { super(); @@ -108,7 +110,16 @@ export default class CustomIntroSlider extends React.Component { icon: 'email', colors: ['#e01928', '#be1522'], }, - ] + ]; + this.aprilFoolsSlides = [ + { + key: '1', + title: i18n.t('intro.aprilFoolsSlide.title'), + text: i18n.t('intro.aprilFoolsSlide.text'), + icon: 'information', + colors: ['#e01928', '#be1522'], + }, + ]; } @@ -144,10 +155,15 @@ export default class CustomIntroSlider extends React.Component { } render() { + let slides = this.introSlides; + if (this.props.isUpdate) + slides = this.updateSlides; + else if (this.props.isAprilFools) + slides = this.aprilFoolsSlides; return (