// @flow import * as React from 'react'; import {FlatList, Linking, Platform, View} from 'react-native'; import {Body, Button, Card, CardItem, Container, H1, Left, Right, Text, Thumbnail} from 'native-base'; import CustomHeader from "../../components/CustomHeader"; import i18n from "i18n-js"; import appJson from '../../app'; import packageJson from '../../package'; import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import AsyncStorageManager from "../../utils/AsyncStorageManager"; import {Modalize} from "react-native-modalize"; import ThemeManager from "../../utils/ThemeManager"; const links = { appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148', playstore: 'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application', git: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/README.md', bugsMail: 'mailto:vergnet@etud.insa-toulouse.fr?' + 'subject=' + '[BUG] Application Amicale INSA Toulouse' + '&body=' + 'Coucou Arnaud ça bug c\'est nul,\n\n' + 'Informations sur ton système si tu sais (iOS ou Android, modèle du tel, version):\n\n\n' + 'Nature du problème :\n\n\n' + 'Étapes pour reproduire ce pb :\n\n\n\n' + 'Stp corrige le pb, bien cordialement.', bugsGit: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/issues', changelog: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/Changelog.md', license: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/LICENSE', authorMail: "mailto:vergnet@etud.insa-toulouse.fr?" + "subject=" + "Application Amicale INSA Toulouse" + "&body=" + "Coucou !\n\n", authorLinkedin: 'https://www.linkedin.com/in/arnaud-vergnet-434ba5179/', yohanMail: "mailto:ysimard@etud.insa-toulouse.fr?" + "subject=" + "Application Amicale INSA Toulouse" + "&body=" + "Coucou !\n\n", yohanLinkedin: 'https://www.linkedin.com/in/yohan-simard', react: 'https://facebook.github.io/react-native/', }; type Props = { navigation: Object, }; type State = { isDebugUnlocked: boolean, }; /** * Opens a link in the device's browser * @param link The link to open */ function openWebLink(link) { Linking.openURL(link).catch((err) => console.error('Error opening link', err)); } /** * Class defining an about screen. This screen shows the user information about the app and it's author. */ export default class AboutScreen extends React.Component { debugTapCounter = 0; modalRef: { current: null | Modalize }; state = { isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1' }; /** * Data to be displayed in the app card */ appData: Array = [ { onPressCallback: () => openWebLink(Platform.OS === "ios" ? links.appstore : links.playstore), icon: Platform.OS === "ios" ? 'apple' : 'google-play', text: Platform.OS === "ios" ? i18n.t('aboutScreen.appstore') : i18n.t('aboutScreen.playstore'), showChevron: true }, { onPressCallback: () => this.openBugReportModal(), icon: 'bug', text: i18n.t('aboutScreen.bugs'), showChevron: true }, { onPressCallback: () => openWebLink(links.git), icon: 'git', text: 'Git', showChevron: true }, { onPressCallback: () => openWebLink(links.changelog), icon: 'refresh', text: i18n.t('aboutScreen.changelog'), showChevron: true }, { onPressCallback: () => openWebLink(links.license), icon: 'file-document', text: i18n.t('aboutScreen.license'), showChevron: true }, { onPressCallback: () => this.props.navigation.navigate('DebugScreen'), icon: 'bug-check', text: i18n.t('aboutScreen.debug'), showChevron: true, showOnlyDebug: true }, ]; /** * Data to be displayed in the author card */ authorData: Array = [ { onPressCallback: () => this.tryUnlockDebugMode(), icon: 'account-circle', text: 'Arnaud VERGNET', showChevron: false }, { onPressCallback: () => openWebLink(links.authorMail), icon: 'email', text: i18n.t('aboutScreen.authorMail'), showChevron: true }, { onPressCallback: () => openWebLink(links.authorLinkedin), icon: 'linkedin', text: 'Linkedin', showChevron: true }, ]; /** * Data to be displayed in the additional developer card */ additionalDevData: Array = [ { onPressCallback: () => console.log('Meme this'), icon: 'account', text: 'Yohan SIMARD', showChevron: false }, { onPressCallback: () => openWebLink(links.yohanMail), icon: 'email', text: i18n.t('aboutScreen.authorMail'), showChevron: true }, { onPressCallback: () => openWebLink(links.yohanLinkedin), icon: 'linkedin', text: 'Linkedin', showChevron: true }, ]; /** * Data to be displayed in the technologies card */ technoData: Array = [ { onPressCallback: () => openWebLink(links.react), icon: 'react', text: i18n.t('aboutScreen.reactNative'), showChevron: true }, { onPressCallback: () => this.props.navigation.navigate('AboutDependenciesScreen', {data: packageJson.dependencies}), icon: 'developer-board', text: i18n.t('aboutScreen.libs'), showChevron: true }, ]; dataOrder: Array = [ { id: 'app', }, { id: 'team', }, { id: 'techno', }, ]; getCardItem: Function; getMainCard: Function; constructor(props: any) { super(props); this.modalRef = React.createRef(); this.getCardItem = this.getCardItem.bind(this); this.getMainCard = this.getMainCard.bind(this); } getAppCard() { return (

{appJson.expo.name}

v.{appJson.expo.version}
item.icon} listKey={"app"} renderItem={this.getCardItem} />
); } getTeamCard() { return (

{i18n.t('aboutScreen.team')}

{i18n.t('aboutScreen.author')} item.icon} listKey={"team1"} renderItem={this.getCardItem} /> {i18n.t('aboutScreen.additionalDev')} item.icon} listKey={"team2"} renderItem={this.getCardItem} />
); } getTechnoCard() { return ( {i18n.t('aboutScreen.technologies')} item.icon} listKey={"techno"} renderItem={this.getCardItem} /> ); } /** * Get a clickable card item to be rendered inside a card. * * @returns {React.Node} */ getCardItem({item}: Object) { let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked); if (shouldShow) { return ( {item.text} {item.showChevron ? : } ) ; } else { return } } tryUnlockDebugMode() { this.debugTapCounter = this.debugTapCounter + 1; if (this.debugTapCounter >= 4) { this.unlockDebugMode(); } } unlockDebugMode() { this.setState({isDebugUnlocked: true}); let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key; AsyncStorageManager.getInstance().savePref(key, '1'); } getBugReportModal() { const onPressMail = openWebLink.bind(this, links.bugsMail); const onPressGit = openWebLink.bind(this, links.bugsGit); return (

{i18n.t('aboutScreen.bugs')}

{i18n.t('aboutScreen.bugsDescription')}
); } openBugReportModal() { if (this.modalRef.current) { this.modalRef.current.open(); } } getMainCard({item}: Object) { switch (item.id) { case 'app': return this.getAppCard(); case 'team': return this.getTeamCard(); case 'techno': return this.getTechnoCard(); } return ; } render() { const nav = this.props.navigation; return ( {this.getBugReportModal()} item.id} renderItem={this.getMainCard} /> ); } }