Browse Source

Improved documentation and fixed debug mode

Arnaud Vergnet 4 years ago
parent
commit
03549957a8

+ 6
- 0
screens/About/AboutDependenciesScreen.js View File

@@ -10,6 +10,12 @@ type listItem = {
10 10
     version: string
11 11
 };
12 12
 
13
+/**
14
+ * Generates the dependencies list from the raw json
15
+ *
16
+ * @param object The raw json
17
+ * @return {Array<listItem>}
18
+ */
13 19
 function generateListFromObject(object: { [string]: string }): Array<listItem> {
14 20
     let list = [];
15 21
     let keys = Object.keys(object);

+ 73
- 4
screens/About/AboutScreen.js View File

@@ -105,7 +105,7 @@ class AboutScreen extends React.Component<Props, State> {
105 105
             icon: 'bug-check',
106 106
             text: i18n.t('aboutScreen.debug'),
107 107
             showChevron: true,
108
-            showOnlyDebug: true
108
+            showOnlyInDebug: true
109 109
         },
110 110
     ];
111 111
     /**
@@ -171,6 +171,9 @@ class AboutScreen extends React.Component<Props, State> {
171 171
             showChevron: true
172 172
         },
173 173
     ];
174
+    /**
175
+     * Order of information cards
176
+     */
174 177
     dataOrder: Array<Object> = [
175 178
         {
176 179
             id: 'app',
@@ -201,6 +204,11 @@ class AboutScreen extends React.Component<Props, State> {
201 204
         this.colors = props.theme.colors;
202 205
     }
203 206
 
207
+    /**
208
+     * Gets the app icon
209
+     * @param props
210
+     * @return {*}
211
+     */
204 212
     getAppIcon(props) {
205 213
         return (
206 214
             <Avatar.Image
@@ -211,10 +219,21 @@ class AboutScreen extends React.Component<Props, State> {
211 219
         );
212 220
     }
213 221
 
214
-    keyExtractor(item: Object) {
222
+    /**
223
+     * Extracts a key from the given item
224
+     *
225
+     * @param item The item to extract the key from
226
+     * @return {string} The extracted key
227
+     */
228
+    keyExtractor(item: Object): string {
215 229
         return item.icon;
216 230
     }
217 231
 
232
+    /**
233
+     * Gets the app card showing information and links about the app.
234
+     *
235
+     * @return {*}
236
+     */
218 237
     getAppCard() {
219 238
         return (
220 239
             <Card style={{marginBottom: 10}}>
@@ -235,6 +254,11 @@ class AboutScreen extends React.Component<Props, State> {
235 254
         );
236 255
     }
237 256
 
257
+    /**
258
+     * Gets the team card showing information and links about the team
259
+     *
260
+     * @return {*}
261
+     */
238 262
     getTeamCard() {
239 263
         return (
240 264
             <Card style={{marginBottom: 10}}>
@@ -263,6 +287,11 @@ class AboutScreen extends React.Component<Props, State> {
263 287
         );
264 288
     }
265 289
 
290
+    /**
291
+     * Gets the techno card showing information and links about the technologies used in the app
292
+     *
293
+     * @return {*}
294
+     */
266 295
     getTechnoCard() {
267 296
         return (
268 297
             <Card style={{marginBottom: 10}}>
@@ -280,12 +309,25 @@ class AboutScreen extends React.Component<Props, State> {
280 309
         );
281 310
     }
282 311
 
312
+    /**
313
+     * Gets a chevron icon
314
+     *
315
+     * @param props
316
+     * @return {*}
317
+     */
283 318
     getChevronIcon(props: Object) {
284 319
         return (
285 320
             <List.Icon {...props} icon={'chevron-right'}/>
286 321
         );
287 322
     }
288 323
 
324
+    /**
325
+     * Gets a custom list item icon
326
+     *
327
+     * @param item The item to show the icon for
328
+     * @param props
329
+     * @return {*}
330
+     */
289 331
     getItemIcon(item: Object, props: Object) {
290 332
         return (
291 333
             <List.Icon {...props} icon={item.icon}/>
@@ -295,10 +337,12 @@ class AboutScreen extends React.Component<Props, State> {
295 337
     /**
296 338
      * Get a clickable card item to be rendered inside a card.
297 339
      *
298
-     * @returns {React.Node}
340
+     * @returns {*}
299 341
      */
300 342
     getCardItem({item}: Object) {
301
-        let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked);
343
+        let shouldShow = item === undefined
344
+            || !item.showOnlyInDebug
345
+            || (item.showOnlyInDebug && this.state.isDebugUnlocked);
302 346
         const getItemIcon = this.getItemIcon.bind(this, item);
303 347
         if (shouldShow) {
304 348
             if (item.showChevron) {
@@ -323,6 +367,9 @@ class AboutScreen extends React.Component<Props, State> {
323 367
             return null;
324 368
     }
325 369
 
370
+    /**
371
+     * Tries to unlock debug mode
372
+     */
326 373
     tryUnlockDebugMode() {
327 374
         this.debugTapCounter = this.debugTapCounter + 1;
328 375
         if (this.debugTapCounter >= 4) {
@@ -330,12 +377,20 @@ class AboutScreen extends React.Component<Props, State> {
330 377
         }
331 378
     }
332 379
 
380
+    /**
381
+     * Unlocks debug mode
382
+     */
333 383
     unlockDebugMode() {
334 384
         this.setState({isDebugUnlocked: true});
335 385
         let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
336 386
         AsyncStorageManager.getInstance().savePref(key, '1');
337 387
     }
338 388
 
389
+    /**
390
+     * Gets the bug report modal's content
391
+     *
392
+     * @return {*}
393
+     */
339 394
     getBugReportModal() {
340 395
         return (
341 396
             <View style={{
@@ -376,12 +431,21 @@ class AboutScreen extends React.Component<Props, State> {
376 431
         );
377 432
     }
378 433
 
434
+    /**
435
+     * opens the bug report modal
436
+     */
379 437
     openBugReportModal() {
380 438
         if (this.modalRef) {
381 439
             this.modalRef.open();
382 440
         }
383 441
     }
384 442
 
443
+    /**
444
+     * Gets a card, depending on the given item's id
445
+     *
446
+     * @param item The item to show
447
+     * @return {*}
448
+     */
385 449
     getMainCard({item}: Object) {
386 450
         switch (item.id) {
387 451
             case 'app':
@@ -394,6 +458,11 @@ class AboutScreen extends React.Component<Props, State> {
394 458
         return <View/>;
395 459
     }
396 460
 
461
+    /**
462
+     * Callback used when receiving the modal ref
463
+     *
464
+     * @param ref
465
+     */
397 466
     onModalRef(ref: Object) {
398 467
         this.modalRef = ref;
399 468
     }

+ 31
- 1
screens/About/DebugScreen.js View File

@@ -16,7 +16,8 @@ type State = {
16 16
 }
17 17
 
18 18
 /**
19
- * Class defining the Debug screen. This screen allows the user to get detailed information on the app/device.
19
+ * Class defining the Debug screen.
20
+ * This screen allows the user to get and modify information on the app/device.
20 21
  */
21 22
 class DebugScreen extends React.Component<Props, State> {
22 23
 
@@ -37,6 +38,15 @@ class DebugScreen extends React.Component<Props, State> {
37 38
         this.colors = props.theme.colors;
38 39
     }
39 40
 
41
+    /**
42
+     * Gets a clickable list item
43
+     *
44
+     * @param onPressCallback The function to call when clicking on the item
45
+     * @param icon The item's icon
46
+     * @param title The item's title
47
+     * @param subtitle The item's subtitle
48
+     * @return {*}
49
+     */
40 50
     static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
41 51
         if (icon !== undefined) {
42 52
             return (
@@ -58,6 +68,10 @@ class DebugScreen extends React.Component<Props, State> {
58 68
         }
59 69
     }
60 70
 
71
+    /**
72
+     * Show the
73
+     * @param item
74
+     */
61 75
     showEditModal(item: Object) {
62 76
         this.setState({
63 77
             modalCurrentDisplayItem: item
@@ -67,6 +81,11 @@ class DebugScreen extends React.Component<Props, State> {
67 81
         }
68 82
     }
69 83
 
84
+    /**
85
+     * Gets the edit modal content
86
+     *
87
+     * @return {*}
88
+     */
70 89
     getModalContent() {
71 90
         return (
72 91
             <View style={{
@@ -104,6 +123,12 @@ class DebugScreen extends React.Component<Props, State> {
104 123
         );
105 124
     }
106 125
 
126
+    /**
127
+     * Saves the new value of the given preference
128
+     *
129
+     * @param key The pref key
130
+     * @param value The pref value
131
+     */
107 132
     saveNewPrefs(key: string, value: string) {
108 133
         this.setState((prevState) => {
109 134
             let currentPreferences = {...prevState.currentPreferences};
@@ -113,6 +138,11 @@ class DebugScreen extends React.Component<Props, State> {
113 138
         AsyncStorageManager.getInstance().savePref(key, value);
114 139
     }
115 140
 
141
+    /**
142
+     * Callback used when receiving the modal ref
143
+     *
144
+     * @param ref
145
+     */
116 146
     onModalRef(ref: Object) {
117 147
         this.modalRef = ref;
118 148
     }

Loading…
Cancel
Save