|
@@ -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
|