diff --git a/src/screens/About/AboutScreen.js b/src/screens/About/AboutScreen.js index 4054f64..27effd1 100644 --- a/src/screens/About/AboutScreen.js +++ b/src/screens/About/AboutScreen.js @@ -3,7 +3,6 @@ import * as React from 'react'; import {FlatList, Linking, Platform, View} from 'react-native'; import i18n from "i18n-js"; -import AsyncStorageManager from "../../managers/AsyncStorageManager"; import {Avatar, Card, List, Title, withTheme} from 'react-native-paper'; import packageJson from "../../../package.json"; @@ -32,10 +31,6 @@ type Props = { navigation: Object, }; -type State = { - isDebugUnlocked: boolean, -}; - /** * Opens a link in the device's browser * @param link The link to open @@ -47,14 +42,8 @@ function openWebLink(link) { /** * Class defining an about screen. This screen shows the user information about the app and it's author. */ -class AboutScreen extends React.Component { +class AboutScreen extends React.Component { - debugTapCounter = 0; - modalRef: Object; - - state = { - isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1' - }; /** * Data to be displayed in the app card */ @@ -89,20 +78,13 @@ class AboutScreen extends React.Component { text: i18n.t('aboutScreen.license'), showChevron: true }, - { - onPressCallback: () => this.props.navigation.navigate('debug'), - icon: 'bug-check', - text: i18n.t('aboutScreen.debug'), - showChevron: true, - showOnlyInDebug: true - }, ]; /** * Data to be displayed in the author card */ authorData: Array = [ { - onPressCallback: () => this.tryUnlockDebugMode(), + onPressCallback: () => console.log('cc'), icon: 'account-circle', text: 'Arnaud VERGNET', showChevron: false @@ -223,7 +205,6 @@ class AboutScreen extends React.Component { @@ -314,51 +295,26 @@ class AboutScreen extends React.Component { * @returns {*} */ getCardItem = ({item}: Object) => { - let shouldShow = item === undefined - || !item.showOnlyInDebug - || (item.showOnlyInDebug && this.state.isDebugUnlocked); const getItemIcon = this.getItemIcon.bind(this, item); - if (shouldShow) { - if (item.showChevron) { - return ( - - ); - } else { - return ( - - ); - } - } else - return null; - }; - - /** - * Tries to unlock debug mode - */ - tryUnlockDebugMode() { - this.debugTapCounter = this.debugTapCounter + 1; - if (this.debugTapCounter >= 4) { - this.unlockDebugMode(); + if (item.showChevron) { + return ( + + ); + } else { + return ( + + ); } - } - - /** - * Unlocks debug mode - */ - unlockDebugMode() { - this.setState({isDebugUnlocked: true}); - let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key; - AsyncStorageManager.getInstance().savePref(key, '1'); - } + }; /** * Gets a card, depending on the given item's id diff --git a/src/screens/Home/HomeScreen.js b/src/screens/Home/HomeScreen.js index e6cbb13..769d97a 100644 --- a/src/screens/Home/HomeScreen.js +++ b/src/screens/Home/HomeScreen.js @@ -174,11 +174,9 @@ class HomeScreen extends React.Component { } const onPressSettings = () => this.props.navigation.navigate("settings"); - const onPressAbout = () => this.props.navigation.navigate("about"); return - ; }; diff --git a/src/screens/Other/SettingsScreen.js b/src/screens/Other/SettingsScreen.js index 7362d4d..6d5bdd0 100644 --- a/src/screens/Other/SettingsScreen.js +++ b/src/screens/Other/SettingsScreen.js @@ -9,8 +9,10 @@ import AsyncStorageManager from "../../managers/AsyncStorageManager"; import {Card, List, Switch, ToggleButton, withTheme} from 'react-native-paper'; import {Appearance} from "react-native-appearance"; import CustomSlider from "../../components/Overrides/CustomSlider"; +import {StackNavigationProp} from "@react-navigation/stack"; type Props = { + navigation: StackNavigationProp, theme: CustomTheme, }; @@ -19,6 +21,7 @@ type State = { nightModeFollowSystem: boolean, notificationReminderSelected: number, startScreenPickerSelected: string, + isDebugUnlocked: boolean, }; /** @@ -41,9 +44,19 @@ class SettingsScreen extends React.Component { Appearance.getColorScheme() !== 'no-preference', notificationReminderSelected: this.savedNotificationReminder, startScreenPickerSelected: AsyncStorageManager.getInstance().preferences.defaultStartScreen.current, + isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1' }; } + /** + * Unlocks debug mode + */ + unlockDebugMode = () => { + this.setState({isDebugUnlocked: true}); + let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key; + AsyncStorageManager.getInstance().savePref(key, '1'); + } + /** * Saves the value for the proxiwash reminder notification time * @@ -205,6 +218,31 @@ class SettingsScreen extends React.Component { + + + + {this.state.isDebugUnlocked + ? } + onPress={() => this.props.navigation.navigate("debug")} + /> + :null} + } + onPress={() => this.props.navigation.navigate("about")} + onLongPress={this.unlockDebugMode} + /> + } + onPress={() => this.props.navigation.navigate("feedback")} + /> + + ); } diff --git a/translations/en.json b/translations/en.json index cdbff0e..71edb8e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -91,7 +91,8 @@ "startScreen": "Start Screen", "startScreenSub": "Select which screen to start the app on", "proxiwashNotifReminder": "Machine running reminder", - "proxiwashNotifReminderSub": "How many minutes before" + "proxiwashNotifReminderSub": "How many minutes before", + "information": "Information" }, "homeScreen": { "listUpdated": "List updated!", @@ -110,6 +111,7 @@ } }, "aboutScreen": { + "buttonDesc": "Information about the app and its creator", "appstore": "See on the Appstore", "playstore": "See on the Playstore", "changelog": "Changelog", diff --git a/translations/fr.json b/translations/fr.json index 43f4ab2..1c6a08d 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -91,7 +91,8 @@ "startScreen": "Écran de démarrage", "startScreenSub": "Choisissez l'écran utilisé au démarrage", "proxiwashNotifReminder": "Rappel de machine en cours", - "proxiwashNotifReminderSub": "Combien de minutes avant" + "proxiwashNotifReminderSub": "Combien de minutes avant", + "information": "Informations" }, "homeScreen": { "listUpdated": "List mise à jour!", @@ -110,6 +111,7 @@ } }, "aboutScreen": { + "buttonDesc": "Informations sur l'appli et son créateur", "appstore": "Voir sur l'Appstore", "playstore": "Voir sur le Playstore", "changelog": "Historique des modifications",