Browse Source

Added intro slide on update, changed planning event display on click

keplyx 4 years ago
parent
commit
517fea788d
6 changed files with 53 additions and 14 deletions
  1. 12
    5
      App.js
  2. 15
    4
      components/CustomIntroSlider.js
  3. 13
    5
      screens/PlanningScreen.js
  4. 4
    0
      translations/en.json
  5. 4
    0
      translations/fr.json
  6. 5
    0
      utils/AsyncStorageManager.js

+ 12
- 5
App.js View File

@@ -20,6 +20,7 @@ type Props = {};
20 20
 type State = {
21 21
     isLoading: boolean,
22 22
     showIntro: boolean,
23
+    showUpdate: boolean,
23 24
     currentTheme: ?Object,
24 25
 };
25 26
 
@@ -28,6 +29,7 @@ export default class App extends React.Component<Props, State> {
28 29
     state = {
29 30
         isLoading: true,
30 31
         showIntro: true,
32
+        showUpdate: true,
31 33
         currentTheme: null,
32 34
     };
33 35
 
@@ -47,11 +49,15 @@ export default class App extends React.Component<Props, State> {
47 49
     }
48 50
 
49 51
     /**
50
-     * Callback when user ends the intro. Save in preferences to avaoid showing back the slides
52
+     * Callback when user ends the intro. Save in preferences to avaoid showing back the introSlides
51 53
      */
52 54
     onIntroDone() {
53
-        this.setState({showIntro: false});
55
+        this.setState({
56
+            showIntro: false,
57
+            showUpdate: false,
58
+        });
54 59
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0');
60
+        AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate1.key, '0');
55 61
     }
56 62
 
57 63
     async loadAssetsAsync() {
@@ -73,7 +79,8 @@ export default class App extends React.Component<Props, State> {
73 79
         this.setState({
74 80
             isLoading: false,
75 81
             currentTheme: ThemeManager.getCurrentTheme(),
76
-            showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1'
82
+            showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1',
83
+            showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate1.current === '1'
77 84
             // showIntro: true
78 85
         });
79 86
     }
@@ -91,8 +98,8 @@ export default class App extends React.Component<Props, State> {
91 98
                 />
92 99
             );
93 100
         }
94
-        if (this.state.showIntro) {
95
-            return <CustomIntroSlider onDone={() => this.onIntroDone()}/>;
101
+        if (this.state.showIntro || this.state.showUpdate) {
102
+            return <CustomIntroSlider onDone={() => this.onIntroDone()} isUpdate={this.state.showUpdate && !this.state.showIntro}/>;
96 103
         } else {
97 104
             const AppNavigator = createAppContainerWithInitialRoute(AsyncStorageManager.getInstance().preferences.defaultStartScreen.current);
98 105
             return (

+ 15
- 4
components/CustomIntroSlider.js View File

@@ -39,15 +39,17 @@ const styles = StyleSheet.create({
39 39
 
40 40
 type Props = {
41 41
     onDone: Function,
42
+    isUpdate: boolean
42 43
 };
43 44
 
44 45
 export default class CustomIntroSlider extends React.Component<Props> {
45 46
 
46
-    slides: Array<Object>;
47
+    introSlides: Array<Object>;
48
+    updateSlides: Array<Object>;
47 49
 
48 50
     constructor() {
49 51
         super();
50
-        this.slides = [
52
+        this.introSlides = [
51 53
             {
52 54
                 key: '1',
53 55
                 title: i18n.t('intro.slide1.title'),
@@ -91,11 +93,20 @@ export default class CustomIntroSlider extends React.Component<Props> {
91 93
                 colors: ['#37c13e', '#26852b'],
92 94
             },
93 95
         ];
96
+        this.updateSlides = [
97
+            {
98
+                key: '1',
99
+                title: i18n.t('intro.updateSlide.title'),
100
+                text: i18n.t('intro.updateSlide.text'),
101
+                icon: 'calendar-range',
102
+                colors: ['#e01928', '#be1522'],
103
+            },
104
+        ]
94 105
     }
95 106
 
96 107
 
97 108
     /**
98
-     * Render item to be used for the intro slides
109
+     * Render item to be used for the intro introSlides
99 110
      * @param item
100 111
      * @param dimensions
101 112
      */
@@ -125,7 +136,7 @@ export default class CustomIntroSlider extends React.Component<Props> {
125 136
     render() {
126 137
         return (
127 138
             <AppIntroSlider renderItem={({item, dimensions}) => CustomIntroSlider.getIntroRenderItem(item, dimensions)}
128
-                            slides={this.slides} onDone={() => this.props.onDone()} bottomButton showSkipButton/>
139
+                            slides={this.props.isUpdate ? this.updateSlides : this.introSlides} onDone={() => this.props.onDone()} bottomButton showSkipButton/>
129 140
         );
130 141
     }
131 142
 

+ 13
- 5
screens/PlanningScreen.js View File

@@ -60,7 +60,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
60 60
     state = {
61 61
         modalCurrentDisplayItem: {},
62 62
         refreshing: false,
63
-        agendaItems: {}
63
+        agendaItems: {},
64 64
     };
65 65
 
66 66
     getCurrentDate() {
@@ -124,7 +124,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
124 124
 
125 125
     showItemDetails(item: Object) {
126 126
         this.setState({
127
-            modalCurrentDisplayItem: item
127
+            modalCurrentDisplayItem: item,
128 128
         });
129 129
         if (this.modalRef.current) {
130 130
             this.modalRef.current.open();
@@ -203,7 +203,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
203 203
     _onRefresh = () => {
204 204
         let canRefresh;
205 205
         if (this.lastRefresh !== undefined)
206
-            canRefresh = (new Date().getTime() - this.lastRefresh.getTime())/1000 > this.minTimeBetweenRefresh;
206
+            canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh;
207 207
         else
208 208
             canRefresh = true;
209 209
 
@@ -292,6 +292,12 @@ export default class PlanningScreen extends React.Component<Props, State> {
292 292
         return array[0] + ':' + array[1];
293 293
     }
294 294
 
295
+    onModalClosed() {
296
+        this.setState({
297
+            modalCurrentDisplayItem: {},
298
+        });
299
+    }
300
+
295 301
     render() {
296 302
         const nav = this.props.navigation;
297 303
         return (
@@ -299,7 +305,9 @@ export default class PlanningScreen extends React.Component<Props, State> {
299 305
                 <Modalize ref={this.modalRef}
300 306
                           modalStyle={{
301 307
                               backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor,
302
-                          }}>
308
+                          }}
309
+                          adjustToContentHeight
310
+                          onClosed={() => this.onModalClosed()}>
303 311
                     {this.getModalContent()}
304 312
                 </Modalize>
305 313
                 <Agenda
@@ -310,7 +318,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
310 318
                     // initially selected day
311 319
                     selected={this.getCurrentDate()}
312 320
                     // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
313
-                    minDate={"2019-09-01"}
321
+                    minDate={this.getCurrentDate()}
314 322
                     // Max amount of months allowed to scroll to the past. Default = 50
315 323
                     pastScrollRange={1}
316 324
                     // Max amount of months allowed to scroll to the future. Default = 50

+ 4
- 0
translations/en.json View File

@@ -33,6 +33,10 @@
33 33
     "slide6": {
34 34
       "title": "More to come...",
35 35
       "text": "New features are coming soon, do not hesitate to give us feedback to improve the app"
36
+    },
37
+    "updateSlide": {
38
+      "title": "New in this update!",
39
+      "text": "Discover every event occurring on the campus in the new Planning screen!"
36 40
     }
37 41
   },
38 42
   "settingsScreen": {

+ 4
- 0
translations/fr.json View File

@@ -33,6 +33,10 @@
33 33
     "slide6": {
34 34
       "title": "Plus à venir...",
35 35
       "text": "D'autres fonctionnalités arrivent bientôt, n'hésitez pas à nous donner votre avis pour améliorer l'appli"
36
+    },
37
+    "updateSlide": {
38
+      "title": "Nouveau dans cette mise à jour !",
39
+      "text": "Découvre tous les événements du campus dans la nouvelle section Planning !"
36 40
     }
37 41
   },
38 42
   "settingsScreen": {

+ 5
- 0
utils/AsyncStorageManager.js View File

@@ -29,6 +29,11 @@ export default class AsyncStorageManager {
29 29
             default: '1',
30 30
             current: '',
31 31
         },
32
+        showUpdate1: {
33
+            key: 'showUpdate1',
34
+            default: '1',
35
+            current: '',
36
+        },
32 37
         proxiwashNotifications: {
33 38
             key: 'proxiwashNotifications',
34 39
             default: '5',

Loading…
Cancel
Save