Browse Source

Improved update management

keplyx 4 years ago
parent
commit
2c99d2bb62
7 changed files with 39 additions and 11 deletions
  1. 4
    3
      App.js
  2. 4
    3
      components/CustomIntroSlider.js
  3. 25
    0
      constants/Update.js
  4. 2
    1
      package.json
  5. 1
    1
      translations/en.json
  6. 1
    1
      translations/fr.json
  7. 2
    2
      utils/AsyncStorageManager.js

+ 4
- 3
App.js View File

@@ -13,6 +13,7 @@ import DrawerNavigator from './navigation/DrawerNavigator';
13 13
 import NotificationsManager from "./utils/NotificationsManager";
14 14
 import {Provider as PaperProvider} from 'react-native-paper';
15 15
 import AprilFoolsManager from "./utils/AprilFoolsManager";
16
+import Update from "./constants/Update";
16 17
 
17 18
 type Props = {};
18 19
 
@@ -77,7 +78,7 @@ export default class App extends React.Component<Props, State> {
77 78
             showAprilFools: false,
78 79
         });
79 80
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0');
80
-        AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0');
81
+        AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.updateNumber.key, Update.number.toString());
81 82
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.key, '0');
82 83
     }
83 84
 
@@ -89,7 +90,7 @@ export default class App extends React.Component<Props, State> {
89 90
         // Wait for custom fonts to be loaded before showing the app
90 91
         await AsyncStorageManager.getInstance().loadPreferences();
91 92
         ThemeManager.getInstance().setUpdateThemeCallback(this.onUpdateTheme);
92
-        // await NotificationsManager.initExpoToken();
93
+        await NotificationsManager.initExpoToken();
93 94
         this.onLoadFinished();
94 95
     }
95 96
 
@@ -100,7 +101,7 @@ export default class App extends React.Component<Props, State> {
100 101
             isLoading: false,
101 102
             currentTheme: ThemeManager.getCurrentTheme(),
102 103
             showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1',
103
-            showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1',
104
+            showUpdate: AsyncStorageManager.getInstance().preferences.updateNumber.current !== Update.number.toString(),
104 105
             showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.current === '1',
105 106
         });
106 107
         // Status bar goes dark if set too fast

+ 4
- 3
components/CustomIntroSlider.js View File

@@ -7,6 +7,7 @@ import {MaterialCommunityIcons} from "@expo/vector-icons";
7 7
 import {Text} from "react-native-paper";
8 8
 import i18n from 'i18n-js';
9 9
 import AppIntroSlider from "react-native-app-intro-slider";
10
+import Update from "../constants/Update";
10 11
 
11 12
 // Content to be used int the intro slides
12 13
 
@@ -105,9 +106,9 @@ export default class CustomIntroSlider extends React.Component<Props> {
105 106
         this.updateSlides = [
106 107
             {
107 108
                 key: '1',
108
-                title: i18n.t('intro.updateSlide.title'),
109
-                text: i18n.t('intro.updateSlide.text'),
110
-                icon: 'email',
109
+                title: Update.getInstance().title,
110
+                text: Update.getInstance().description,
111
+                icon: Update.icon,
111 112
                 colors: ['#e01928', '#be1522'],
112 113
             },
113 114
         ];

+ 25
- 0
constants/Update.js View File

@@ -0,0 +1,25 @@
1
+import i18n from "i18n-js";
2
+
3
+export default class Update {
4
+
5
+    static number = 5;
6
+    static icon = 'surround-sound-2-0';
7
+
8
+    static instance: Update | null = null;
9
+
10
+    constructor() {
11
+        this.title = i18n.t('intro.updateSlide.title');
12
+        this.description = i18n.t('intro.updateSlide.text');
13
+    }
14
+
15
+    /**
16
+     * Get this class instance or create one if none is found
17
+     * @returns {Update}
18
+     */
19
+    static getInstance(): Update {
20
+        return Update.instance === null ?
21
+            Update.instance = new Update() :
22
+            Update.instance;
23
+    }
24
+
25
+};

+ 2
- 1
package.json View File

@@ -34,7 +34,8 @@
34 34
     "react-native-safe-area-context": "0.6.0",
35 35
     "react-native-screens": "2.0.0-alpha.12",
36 36
     "react-native-webview": "7.4.3",
37
-    "react-native-appearance": "~0.3.1"
37
+    "react-native-appearance": "~0.3.1",
38
+    "expo-linear-gradient": "~8.0.0"
38 39
   },
39 40
   "devDependencies": {
40 41
     "babel-preset-expo": "^8.0.0"

+ 1
- 1
translations/en.json View File

@@ -50,7 +50,7 @@
50 50
     },
51 51
     "updateSlide": {
52 52
       "title": "New in this update!",
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! "
53
+      "text": "The app got a new UI ! Faster, prettier and more modern, we hope you'll love it!"
54 54
     },
55 55
     "aprilFoolsSlide": {
56 56
       "title": "New in this update!",

+ 1
- 1
translations/fr.json View File

@@ -50,7 +50,7 @@
50 50
     },
51 51
     "updateSlide": {
52 52
       "title": "Nouveau dans cette mise à jour !",
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 !"
53
+      "text": "L'appli fait peau neuve ! Avec une interface plus rapide, plus jolie et moderne, nous espérons que vous allez l'apprécier !"
54 54
     },
55 55
     "aprilFoolsSlide": {
56 56
       "title": "Nouveau dans cette mise à jour !",

+ 2
- 2
utils/AsyncStorageManager.js View File

@@ -29,8 +29,8 @@ export default class AsyncStorageManager {
29 29
             default: '1',
30 30
             current: '',
31 31
         },
32
-        showUpdate5: {
33
-            key: 'showUpdate5',
32
+        updateNumber: {
33
+            key: 'updateNumber',
34 34
             default: '1',
35 35
             current: '',
36 36
         },

Loading…
Cancel
Save