Browse Source

Moved debug, about and feedback inside settings screen

Arnaud Vergnet 3 years ago
parent
commit
0c881f5ce9

+ 20
- 64
src/screens/About/AboutScreen.js View File

@@ -3,7 +3,6 @@
3 3
 import * as React from 'react';
4 4
 import {FlatList, Linking, Platform, View} from 'react-native';
5 5
 import i18n from "i18n-js";
6
-import AsyncStorageManager from "../../managers/AsyncStorageManager";
7 6
 import {Avatar, Card, List, Title, withTheme} from 'react-native-paper';
8 7
 import packageJson from "../../../package.json";
9 8
 
@@ -32,10 +31,6 @@ type Props = {
32 31
     navigation: Object,
33 32
 };
34 33
 
35
-type State = {
36
-    isDebugUnlocked: boolean,
37
-};
38
-
39 34
 /**
40 35
  * Opens a link in the device's browser
41 36
  * @param link The link to open
@@ -47,14 +42,8 @@ function openWebLink(link) {
47 42
 /**
48 43
  * Class defining an about screen. This screen shows the user information about the app and it's author.
49 44
  */
50
-class AboutScreen extends React.Component<Props, State> {
51
-
52
-    debugTapCounter = 0;
53
-    modalRef: Object;
45
+class AboutScreen extends React.Component<Props> {
54 46
 
55
-    state = {
56
-        isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
57
-    };
58 47
     /**
59 48
      * Data to be displayed in the app card
60 49
      */
@@ -89,20 +78,13 @@ class AboutScreen extends React.Component<Props, State> {
89 78
             text: i18n.t('aboutScreen.license'),
90 79
             showChevron: true
91 80
         },
92
-        {
93
-            onPressCallback: () => this.props.navigation.navigate('debug'),
94
-            icon: 'bug-check',
95
-            text: i18n.t('aboutScreen.debug'),
96
-            showChevron: true,
97
-            showOnlyInDebug: true
98
-        },
99 81
     ];
100 82
     /**
101 83
      * Data to be displayed in the author card
102 84
      */
103 85
     authorData: Array<Object> = [
104 86
         {
105
-            onPressCallback: () => this.tryUnlockDebugMode(),
87
+            onPressCallback: () => console.log('cc'),
106 88
             icon: 'account-circle',
107 89
             text: 'Arnaud VERGNET',
108 90
             showChevron: false
@@ -223,7 +205,6 @@ class AboutScreen extends React.Component<Props, State> {
223 205
                 <Card.Content>
224 206
                     <FlatList
225 207
                         data={this.appData}
226
-                        extraData={this.state.isDebugUnlocked}
227 208
                         keyExtractor={this.keyExtractor}
228 209
                         renderItem={this.getCardItem}
229 210
                     />
@@ -314,51 +295,26 @@ class AboutScreen extends React.Component<Props, State> {
314 295
      * @returns {*}
315 296
      */
316 297
     getCardItem = ({item}: Object) => {
317
-        let shouldShow = item === undefined
318
-            || !item.showOnlyInDebug
319
-            || (item.showOnlyInDebug && this.state.isDebugUnlocked);
320 298
         const getItemIcon = this.getItemIcon.bind(this, item);
321
-        if (shouldShow) {
322
-            if (item.showChevron) {
323
-                return (
324
-                    <List.Item
325
-                        title={item.text}
326
-                        left={getItemIcon}
327
-                        right={this.getChevronIcon}
328
-                        onPress={item.onPressCallback}
329
-                    />
330
-                );
331
-            } else {
332
-                return (
333
-                    <List.Item
334
-                        title={item.text}
335
-                        left={getItemIcon}
336
-                        onPress={item.onPressCallback}
337
-                    />
338
-                );
339
-            }
340
-        } else
341
-            return null;
342
-    };
343
-
344
-    /**
345
-     * Tries to unlock debug mode
346
-     */
347
-    tryUnlockDebugMode() {
348
-        this.debugTapCounter = this.debugTapCounter + 1;
349
-        if (this.debugTapCounter >= 4) {
350
-            this.unlockDebugMode();
299
+        if (item.showChevron) {
300
+            return (
301
+                <List.Item
302
+                    title={item.text}
303
+                    left={getItemIcon}
304
+                    right={this.getChevronIcon}
305
+                    onPress={item.onPressCallback}
306
+                />
307
+            );
308
+        } else {
309
+            return (
310
+                <List.Item
311
+                    title={item.text}
312
+                    left={getItemIcon}
313
+                    onPress={item.onPressCallback}
314
+                />
315
+            );
351 316
         }
352
-    }
353
-
354
-    /**
355
-     * Unlocks debug mode
356
-     */
357
-    unlockDebugMode() {
358
-        this.setState({isDebugUnlocked: true});
359
-        let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
360
-        AsyncStorageManager.getInstance().savePref(key, '1');
361
-    }
317
+    };
362 318
 
363 319
     /**
364 320
      * Gets a card, depending on the given item's id

+ 0
- 2
src/screens/Home/HomeScreen.js View File

@@ -174,11 +174,9 @@ class HomeScreen extends React.Component<Props, State> {
174 174
         }
175 175
 
176 176
         const onPressSettings = () => this.props.navigation.navigate("settings");
177
-        const onPressAbout = () => this.props.navigation.navigate("about");
178 177
         return <MaterialHeaderButtons>
179 178
             <Item title="log" iconName={logIcon} color={logColor} onPress={onPressLog}/>
180 179
             <Item title={i18n.t("screens.settings")} iconName={"settings"} onPress={onPressSettings}/>
181
-            <Item title={i18n.t("screens.about")} iconName={"information"} onPress={onPressAbout}/>
182 180
         </MaterialHeaderButtons>;
183 181
     };
184 182
 

+ 38
- 0
src/screens/Other/SettingsScreen.js View File

@@ -9,8 +9,10 @@ import AsyncStorageManager from "../../managers/AsyncStorageManager";
9 9
 import {Card, List, Switch, ToggleButton, withTheme} from 'react-native-paper';
10 10
 import {Appearance} from "react-native-appearance";
11 11
 import CustomSlider from "../../components/Overrides/CustomSlider";
12
+import {StackNavigationProp} from "@react-navigation/stack";
12 13
 
13 14
 type Props = {
15
+    navigation: StackNavigationProp,
14 16
     theme: CustomTheme,
15 17
 };
16 18
 
@@ -19,6 +21,7 @@ type State = {
19 21
     nightModeFollowSystem: boolean,
20 22
     notificationReminderSelected: number,
21 23
     startScreenPickerSelected: string,
24
+    isDebugUnlocked: boolean,
22 25
 };
23 26
 
24 27
 /**
@@ -41,10 +44,20 @@ class SettingsScreen extends React.Component<Props, State> {
41 44
                 Appearance.getColorScheme() !== 'no-preference',
42 45
             notificationReminderSelected: this.savedNotificationReminder,
43 46
             startScreenPickerSelected: AsyncStorageManager.getInstance().preferences.defaultStartScreen.current,
47
+            isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
44 48
         };
45 49
     }
46 50
 
47 51
     /**
52
+     * Unlocks debug mode
53
+     */
54
+    unlockDebugMode = () => {
55
+        this.setState({isDebugUnlocked: true});
56
+        let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
57
+        AsyncStorageManager.getInstance().savePref(key, '1');
58
+    }
59
+
60
+    /**
48 61
      * Saves the value for the proxiwash reminder notification time
49 62
      *
50 63
      * @param value The value to store
@@ -205,6 +218,31 @@ class SettingsScreen extends React.Component<Props, State> {
205 218
                         </View>
206 219
                     </List.Section>
207 220
                 </Card>
221
+                <Card style={{margin: 5}}>
222
+                    <Card.Title title={i18n.t('settingsScreen.information')}/>
223
+                    <List.Section>
224
+                        {this.state.isDebugUnlocked
225
+                            ? <List.Item
226
+                                title={i18n.t('screens.debug')}
227
+                                left={props => <List.Icon {...props} icon="bug-check"/>}
228
+                                onPress={() => this.props.navigation.navigate("debug")}
229
+                            />
230
+                        :null}
231
+                        <List.Item
232
+                            title={i18n.t('screens.about')}
233
+                            description={i18n.t('aboutScreen.buttonDesc')}
234
+                            left={props => <List.Icon {...props} icon="information"/>}
235
+                            onPress={() => this.props.navigation.navigate("about")}
236
+                            onLongPress={this.unlockDebugMode}
237
+                        />
238
+                        <List.Item
239
+                            title={i18n.t('feedbackScreen.homeButtonTitle')}
240
+                            description={i18n.t('feedbackScreen.homeButtonSubtitle')}
241
+                            left={props => <List.Icon {...props} icon="bug"/>}
242
+                            onPress={() => this.props.navigation.navigate("feedback")}
243
+                        />
244
+                    </List.Section>
245
+                </Card>
208 246
             </ScrollView>
209 247
         );
210 248
     }

+ 3
- 1
translations/en.json View File

@@ -91,7 +91,8 @@
91 91
     "startScreen": "Start Screen",
92 92
     "startScreenSub": "Select which screen to start the app on",
93 93
     "proxiwashNotifReminder": "Machine running reminder",
94
-    "proxiwashNotifReminderSub": "How many minutes before"
94
+    "proxiwashNotifReminderSub": "How many minutes before",
95
+    "information": "Information"
95 96
   },
96 97
   "homeScreen": {
97 98
     "listUpdated": "List updated!",
@@ -110,6 +111,7 @@
110 111
     }
111 112
   },
112 113
   "aboutScreen": {
114
+    "buttonDesc": "Information about the app and its creator",
113 115
     "appstore": "See on the Appstore",
114 116
     "playstore": "See on the Playstore",
115 117
     "changelog": "Changelog",

+ 3
- 1
translations/fr.json View File

@@ -91,7 +91,8 @@
91 91
     "startScreen": "Écran de démarrage",
92 92
     "startScreenSub": "Choisissez l'écran utilisé au démarrage",
93 93
     "proxiwashNotifReminder": "Rappel de machine en cours",
94
-    "proxiwashNotifReminderSub": "Combien de minutes avant"
94
+    "proxiwashNotifReminderSub": "Combien de minutes avant",
95
+    "information": "Informations"
95 96
   },
96 97
   "homeScreen": {
97 98
     "listUpdated": "List mise à jour!",
@@ -110,6 +111,7 @@
110 111
     }
111 112
   },
112 113
   "aboutScreen": {
114
+    "buttonDesc": "Informations sur l'appli et son créateur",
113 115
     "appstore": "Voir sur l'Appstore",
114 116
     "playstore": "Voir sur le Playstore",
115 117
     "changelog": "Historique des modifications",

Loading…
Cancel
Save