Browse Source

Show intro slider on first start for april fools

keplyx 4 years ago
parent
commit
c555aabd5a
5 changed files with 45 additions and 7 deletions
  1. 13
    4
      App.js
  2. 19
    3
      components/CustomIntroSlider.js
  3. 4
    0
      translations/en.json
  4. 4
    0
      translations/fr.json
  5. 5
    0
      utils/AsyncStorageManager.js

+ 13
- 4
App.js View File

@@ -12,6 +12,7 @@ import {createStackNavigator} from '@react-navigation/stack';
12 12
 import DrawerNavigator from './navigation/DrawerNavigator';
13 13
 import NotificationsManager from "./utils/NotificationsManager";
14 14
 import {Provider as PaperProvider} from 'react-native-paper';
15
+import AprilFoolsManager from "./utils/AprilFoolsManager";
15 16
 
16 17
 type Props = {};
17 18
 
@@ -19,6 +20,7 @@ type State = {
19 20
     isLoading: boolean,
20 21
     showIntro: boolean,
21 22
     showUpdate: boolean,
23
+    showAprilFools: boolean,
22 24
     currentTheme: ?Object,
23 25
 };
24 26
 
@@ -30,6 +32,7 @@ export default class App extends React.Component<Props, State> {
30 32
         isLoading: true,
31 33
         showIntro: true,
32 34
         showUpdate: true,
35
+        showAprilFools: false,
33 36
         currentTheme: null,
34 37
     };
35 38
 
@@ -68,9 +71,11 @@ export default class App extends React.Component<Props, State> {
68 71
         this.setState({
69 72
             showIntro: false,
70 73
             showUpdate: false,
74
+            showAprilFools: false,
71 75
         });
72 76
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0');
73 77
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0');
78
+        AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.key, '0');
74 79
     }
75 80
 
76 81
     async componentDidMount() {
@@ -96,7 +101,8 @@ export default class App extends React.Component<Props, State> {
96 101
             isLoading: false,
97 102
             currentTheme: ThemeManager.getCurrentTheme(),
98 103
             showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1',
99
-            showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1'
104
+            showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1',
105
+            showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.current === '1',
100 106
         });
101 107
         // Status bar goes dark if set too fast
102 108
         setTimeout(this.setupStatusBar, 1000);
@@ -109,9 +115,12 @@ export default class App extends React.Component<Props, State> {
109 115
     render() {
110 116
         if (this.state.isLoading) {
111 117
             return null;
112
-        } else if (this.state.showIntro || this.state.showUpdate) {
113
-            return <CustomIntroSlider onDone={this.onIntroDone}
114
-                                      isUpdate={this.state.showUpdate && !this.state.showIntro}/>;
118
+        } else if (this.state.showIntro || this.state.showUpdate || this.state.showAprilFools) {
119
+            return <CustomIntroSlider
120
+                onDone={this.onIntroDone}
121
+                isUpdate={this.state.showUpdate && !this.state.showIntro}
122
+                isAprilFools={this.state.showAprilFools && !this.state.showIntro}
123
+            />;
115 124
         } else {
116 125
 
117 126
             return (

+ 19
- 3
components/CustomIntroSlider.js View File

@@ -39,13 +39,15 @@ const styles = StyleSheet.create({
39 39
 
40 40
 type Props = {
41 41
     onDone: Function,
42
-    isUpdate: boolean
42
+    isUpdate: boolean,
43
+    isAprilFools: boolean,
43 44
 };
44 45
 
45 46
 export default class CustomIntroSlider extends React.Component<Props> {
46 47
 
47 48
     introSlides: Array<Object>;
48 49
     updateSlides: Array<Object>;
50
+    aprilFoolsSlides: Array<Object>;
49 51
 
50 52
     constructor() {
51 53
         super();
@@ -108,7 +110,16 @@ export default class CustomIntroSlider extends React.Component<Props> {
108 110
                 icon: 'email',
109 111
                 colors: ['#e01928', '#be1522'],
110 112
             },
111
-        ]
113
+        ];
114
+        this.aprilFoolsSlides = [
115
+            {
116
+                key: '1',
117
+                title: i18n.t('intro.aprilFoolsSlide.title'),
118
+                text: i18n.t('intro.aprilFoolsSlide.text'),
119
+                icon: 'information',
120
+                colors: ['#e01928', '#be1522'],
121
+            },
122
+        ];
112 123
     }
113 124
 
114 125
 
@@ -144,10 +155,15 @@ export default class CustomIntroSlider extends React.Component<Props> {
144 155
     }
145 156
 
146 157
     render() {
158
+        let slides = this.introSlides;
159
+        if (this.props.isUpdate)
160
+            slides = this.updateSlides;
161
+        else if (this.props.isAprilFools)
162
+            slides = this.aprilFoolsSlides;
147 163
         return (
148 164
             <AppIntroSlider
149 165
                 renderItem={CustomIntroSlider.getIntroRenderItem}
150
-                slides={this.props.isUpdate ? this.updateSlides : this.introSlides}
166
+                slides={slides}
151 167
                 onDone={this.props.onDone}
152 168
                 bottomButton
153 169
                 showSkipButton

+ 4
- 0
translations/en.json View File

@@ -52,6 +52,10 @@
52 52
       "title": "New in this update!",
53 53
       "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! "
54 54
     },
55
+    "aprilFoolsSlide": {
56
+      "title": "New in this update!",
57
+      "text": "We heard you, you don't like the new design and colors, so we changed them!\nLove."
58
+    },
55 59
     "buttons": {
56 60
       "next": "Next",
57 61
       "skip": "Skip",

+ 4
- 0
translations/fr.json View File

@@ -52,6 +52,10 @@
52 52
       "title": "Nouveau dans cette mise à jour !",
53 53
       "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 !"
54 54
     },
55
+    "aprilFoolsSlide": {
56
+      "title": "Nouveau dans cette mise à jour !",
57
+      "text": "Nous vous avons entendu, vous n'aimez pas le nouveau design et couleurs, alors on les as changés !\nLa bise."
58
+    },
55 59
     "buttons": {
56 60
       "next": "Suivant",
57 61
       "skip": "Passer",

+ 5
- 0
utils/AsyncStorageManager.js View File

@@ -74,6 +74,11 @@ export default class AsyncStorageManager {
74 74
             default: '1',
75 75
             current: '',
76 76
         },
77
+        showAprilFoolsStart: {
78
+            key: 'showAprilFoolsStart',
79
+            default: '1',
80
+            current: '',
81
+        },
77 82
     };
78 83
 
79 84
     /**

Loading…
Cancel
Save