forked from vergnet/application-amicale
Show intro slider on first start for april fools
This commit is contained in:
parent
9e90c9d8f3
commit
c555aabd5a
5 changed files with 45 additions and 7 deletions
17
App.js
17
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<Props, State> {
|
|||
isLoading: true,
|
||||
showIntro: true,
|
||||
showUpdate: true,
|
||||
showAprilFools: false,
|
||||
currentTheme: null,
|
||||
};
|
||||
|
||||
|
@ -68,9 +71,11 @@ export default class App extends React.Component<Props, State> {
|
|||
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<Props, State> {
|
|||
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<Props, State> {
|
|||
render() {
|
||||
if (this.state.isLoading) {
|
||||
return null;
|
||||
} else if (this.state.showIntro || this.state.showUpdate) {
|
||||
return <CustomIntroSlider onDone={this.onIntroDone}
|
||||
isUpdate={this.state.showUpdate && !this.state.showIntro}/>;
|
||||
} else if (this.state.showIntro || this.state.showUpdate || this.state.showAprilFools) {
|
||||
return <CustomIntroSlider
|
||||
onDone={this.onIntroDone}
|
||||
isUpdate={this.state.showUpdate && !this.state.showIntro}
|
||||
isAprilFools={this.state.showAprilFools && !this.state.showIntro}
|
||||
/>;
|
||||
} else {
|
||||
|
||||
return (
|
||||
|
|
|
@ -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<Props> {
|
||||
|
||||
introSlides: Array<Object>;
|
||||
updateSlides: Array<Object>;
|
||||
aprilFoolsSlides: Array<Object>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -108,7 +110,16 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
|||
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<Props> {
|
|||
}
|
||||
|
||||
render() {
|
||||
let slides = this.introSlides;
|
||||
if (this.props.isUpdate)
|
||||
slides = this.updateSlides;
|
||||
else if (this.props.isAprilFools)
|
||||
slides = this.aprilFoolsSlides;
|
||||
return (
|
||||
<AppIntroSlider
|
||||
renderItem={CustomIntroSlider.getIntroRenderItem}
|
||||
slides={this.props.isUpdate ? this.updateSlides : this.introSlides}
|
||||
slides={slides}
|
||||
onDone={this.props.onDone}
|
||||
bottomButton
|
||||
showSkipButton
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
"title": "New in this update!",
|
||||
"text": "Never miss an email anymore! Acces your INSA webmail from the app using the left menu.\nPlanex has also seen some improvements!\n\nSome of your remarks where taken into account for this update, more to come.\nThanks for your feedback on the survey! "
|
||||
},
|
||||
"aprilFoolsSlide": {
|
||||
"title": "New in this update!",
|
||||
"text": "We heard you, you don't like the new design and colors, so we changed them!\nLove."
|
||||
},
|
||||
"buttons": {
|
||||
"next": "Next",
|
||||
"skip": "Skip",
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
"title": "Nouveau dans cette mise à jour !",
|
||||
"text": "Ne ratez plus jamais un email ! Accédez à vos mails INSA depuis le menu à gauche.\nPlanex a aussi été un peu amélioré !\n\nUne partie de vos remarques ont été prises en compte pour cette mise à jour, d'autres sont à venir.\nMerci pour votre retour lors du sondage !"
|
||||
},
|
||||
"aprilFoolsSlide": {
|
||||
"title": "Nouveau dans cette mise à jour !",
|
||||
"text": "Nous vous avons entendu, vous n'aimez pas le nouveau design et couleurs, alors on les as changés !\nLa bise."
|
||||
},
|
||||
"buttons": {
|
||||
"next": "Suivant",
|
||||
"skip": "Passer",
|
||||
|
|
|
@ -74,6 +74,11 @@ export default class AsyncStorageManager {
|
|||
default: '1',
|
||||
current: '',
|
||||
},
|
||||
showAprilFoolsStart: {
|
||||
key: 'showAprilFoolsStart',
|
||||
default: '1',
|
||||
current: '',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue