2019-06-29 13:37:21 +02:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2019-08-26 12:49:26 +02:00
|
|
|
import {FlatList, Linking, Platform, View} from 'react-native';
|
2019-09-17 11:51:26 +02:00
|
|
|
import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail, Button} from 'native-base';
|
2019-06-27 11:08:56 +02:00
|
|
|
import CustomHeader from "../../components/CustomHeader";
|
2019-06-25 22:20:24 +02:00
|
|
|
import i18n from "i18n-js";
|
2019-06-27 11:08:56 +02:00
|
|
|
import appJson from '../../app';
|
|
|
|
import packageJson from '../../package';
|
2019-06-28 11:35:15 +02:00
|
|
|
import CustomMaterialIcon from "../../components/CustomMaterialIcon";
|
2019-08-26 12:49:26 +02:00
|
|
|
import AsyncStorageManager from "../../utils/AsyncStorageManager";
|
2019-09-17 11:51:26 +02:00
|
|
|
import Modalize from "react-native-modalize";
|
|
|
|
import ThemeManager from "../../utils/ThemeManager";
|
2019-06-25 22:20:24 +02:00
|
|
|
|
|
|
|
const links = {
|
2019-08-31 10:55:56 +02:00
|
|
|
appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148',
|
2019-08-24 19:17:21 +02:00
|
|
|
playstore: 'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application',
|
2019-08-09 11:47:44 +02:00
|
|
|
git: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/README.md',
|
2019-09-17 11:51:26 +02:00
|
|
|
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.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/issues',
|
2019-08-09 11:44:04 +02:00
|
|
|
changelog: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/Changelog.md',
|
|
|
|
license: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/LICENSE',
|
2019-09-17 11:51:26 +02:00
|
|
|
mail: "mailto:vergnet@etud.insa-toulouse.fr?" +
|
|
|
|
"subject=" +
|
|
|
|
"Application Amicale INSA Toulouse" +
|
|
|
|
"&body=" +
|
|
|
|
"Coucou !\n\n",
|
2019-06-25 22:20:24 +02:00
|
|
|
linkedin: 'https://www.linkedin.com/in/arnaud-vergnet-434ba5179/',
|
|
|
|
facebook: 'https://www.facebook.com/arnaud.vergnet',
|
|
|
|
react: 'https://facebook.github.io/react-native/',
|
|
|
|
};
|
|
|
|
|
2019-06-29 13:37:21 +02:00
|
|
|
type Props = {
|
|
|
|
navigation: Object,
|
|
|
|
};
|
|
|
|
|
2019-08-26 12:49:26 +02:00
|
|
|
type State = {
|
|
|
|
isDebugUnlocked: boolean,
|
|
|
|
};
|
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Opens a link in the device's browser
|
|
|
|
* @param link The link to open
|
|
|
|
*/
|
2019-06-28 11:35:15 +02:00
|
|
|
function openWebLink(link) {
|
|
|
|
Linking.openURL(link).catch((err) => console.error('Error opening link', err));
|
|
|
|
}
|
2019-06-25 22:20:24 +02:00
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Class defining an about screen. This screen shows the user information about the app and it's author.
|
|
|
|
*/
|
2019-08-26 12:49:26 +02:00
|
|
|
export default class AboutScreen extends React.Component<Props, State> {
|
|
|
|
|
|
|
|
debugTapCounter = 0;
|
2019-09-17 11:51:26 +02:00
|
|
|
modalRef: { current: null | Modalize };
|
2019-08-26 12:49:26 +02:00
|
|
|
|
|
|
|
state = {
|
|
|
|
isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
|
|
|
|
};
|
2019-06-25 22:20:24 +02:00
|
|
|
|
2019-09-17 11:51:26 +02:00
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
this.modalRef = React.createRef();
|
|
|
|
}
|
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Data to be displayed in the app card
|
|
|
|
*/
|
2019-06-29 13:37:21 +02:00
|
|
|
appData: Array<Object> = [
|
2019-06-28 11:35:15 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
},
|
|
|
|
{
|
2019-09-17 11:51:26 +02:00
|
|
|
onPressCallback: () => this.openBugReportModal(),
|
|
|
|
icon: 'bug',
|
|
|
|
text: i18n.t('aboutScreen.bugs'),
|
2019-08-05 15:10:20 +02:00
|
|
|
showChevron: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
onPressCallback: () => openWebLink(links.git),
|
2019-06-28 11:35:15 +02:00
|
|
|
icon: 'git',
|
2019-08-05 15:10:20 +02:00
|
|
|
text: 'Git',
|
2019-06-28 11:35:15 +02:00
|
|
|
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
|
|
|
|
},
|
2019-08-26 12:49:26 +02:00
|
|
|
{
|
|
|
|
onPressCallback: () => this.props.navigation.navigate('DebugScreen'),
|
|
|
|
icon: 'bug-check',
|
|
|
|
text: i18n.t('aboutScreen.debug'),
|
|
|
|
showChevron: true,
|
|
|
|
showOnlyDebug: true
|
|
|
|
},
|
2019-06-28 11:35:15 +02:00
|
|
|
];
|
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Data to be displayed in the author card
|
|
|
|
*/
|
2019-06-29 13:37:21 +02:00
|
|
|
authorData: Array<Object> = [
|
2019-06-28 11:35:15 +02:00
|
|
|
{
|
2019-08-26 12:49:26 +02:00
|
|
|
onPressCallback: () => this.tryUnlockDebugMode(),
|
2019-06-28 11:35:15 +02:00
|
|
|
icon: 'account-circle',
|
|
|
|
text: 'Arnaud VERGNET',
|
|
|
|
showChevron: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
onPressCallback: () => openWebLink(links.mail),
|
|
|
|
icon: 'email',
|
|
|
|
text: i18n.t('aboutScreen.mail'),
|
|
|
|
showChevron: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
onPressCallback: () => openWebLink(links.linkedin),
|
|
|
|
icon: 'linkedin',
|
|
|
|
text: 'Linkedin',
|
|
|
|
showChevron: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
onPressCallback: () => openWebLink(links.facebook),
|
|
|
|
icon: 'facebook',
|
|
|
|
text: 'Facebook',
|
|
|
|
showChevron: true
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Data to be displayed in the technologies card
|
|
|
|
*/
|
2019-06-29 13:37:21 +02:00
|
|
|
technoData: Array<Object> = [
|
2019-06-28 11:35:15 +02:00
|
|
|
{
|
|
|
|
onPressCallback: () => openWebLink(links.react),
|
|
|
|
icon: 'react',
|
|
|
|
text: i18n.t('aboutScreen.reactNative'),
|
2019-11-07 18:59:52 +01:00
|
|
|
showChevron: true
|
2019-06-28 11:35:15 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
onPressCallback: () => this.props.navigation.navigate('AboutDependenciesScreen', {data: packageJson.dependencies}),
|
|
|
|
icon: 'developer-board',
|
|
|
|
text: i18n.t('aboutScreen.libs'),
|
|
|
|
showChevron: true
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-06-29 15:43:57 +02:00
|
|
|
/**
|
|
|
|
* Get a clickable card item to be rendered inside a card.
|
|
|
|
*
|
|
|
|
* @param onPressCallback The callback to use when the item is clicked
|
|
|
|
* @param icon The icon name to use from MaterialCommunityIcons
|
|
|
|
* @param text The text to show
|
|
|
|
* @param showChevron Whether to show a chevron indicating this button will change screen
|
2019-08-26 12:49:26 +02:00
|
|
|
* @param showOnlyInDebug Should we show te current item only in debug mode?
|
2019-06-29 15:43:57 +02:00
|
|
|
* @returns {React.Node}
|
|
|
|
*/
|
2019-08-26 12:49:26 +02:00
|
|
|
getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean, showOnlyInDebug: boolean) {
|
|
|
|
let shouldShow = !showOnlyInDebug || (showOnlyInDebug && this.state.isDebugUnlocked);
|
|
|
|
if (shouldShow) {
|
|
|
|
return (
|
|
|
|
<CardItem button
|
|
|
|
onPress={onPressCallback}>
|
|
|
|
<Left>
|
|
|
|
<CustomMaterialIcon icon={icon}/>
|
|
|
|
<Text>{text}</Text>
|
|
|
|
</Left>
|
|
|
|
{showChevron ?
|
|
|
|
<Right>
|
|
|
|
<CustomMaterialIcon icon="chevron-right"
|
|
|
|
fontSize={20}/>
|
|
|
|
</Right>
|
|
|
|
:
|
|
|
|
<Right/>
|
|
|
|
}
|
|
|
|
</CardItem>)
|
|
|
|
;
|
|
|
|
} else {
|
|
|
|
return <View/>
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tryUnlockDebugMode() {
|
|
|
|
this.debugTapCounter = this.debugTapCounter + 1;
|
|
|
|
console.log(this.debugTapCounter);
|
|
|
|
if (this.debugTapCounter >= 4) {
|
|
|
|
this.unlockDebugMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unlockDebugMode() {
|
|
|
|
console.log('unlocked');
|
|
|
|
this.setState({isDebugUnlocked: true});
|
|
|
|
let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
|
|
|
|
AsyncStorageManager.getInstance().savePref(key, '1');
|
2019-06-25 22:20:24 +02:00
|
|
|
}
|
|
|
|
|
2019-09-17 11:51:26 +02:00
|
|
|
getBugReportModal() {
|
|
|
|
return (
|
|
|
|
<Modalize ref={this.modalRef}
|
|
|
|
adjustToContentHeight
|
|
|
|
modalStyle={{backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor}}>
|
|
|
|
<View style={{
|
|
|
|
flex: 1,
|
|
|
|
padding: 20
|
|
|
|
}}>
|
|
|
|
<H1>{i18n.t('aboutScreen.bugs')}</H1>
|
|
|
|
<Text>
|
|
|
|
{i18n.t('aboutScreen.bugsDescription')}
|
|
|
|
</Text>
|
|
|
|
<Button
|
|
|
|
style={{
|
|
|
|
marginTop: 20,
|
|
|
|
marginLeft: 'auto',
|
|
|
|
marginRight: 'auto',
|
|
|
|
}}
|
|
|
|
onPress={() => openWebLink(links.bugsMail)}>
|
|
|
|
<CustomMaterialIcon
|
|
|
|
icon={'email'}
|
|
|
|
color={'#fff'}/>
|
|
|
|
<Text>{i18n.t('aboutScreen.bugsMail')}</Text>
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
style={{
|
|
|
|
marginTop: 20,
|
|
|
|
marginLeft: 'auto',
|
|
|
|
marginRight: 'auto',
|
|
|
|
}}
|
|
|
|
onPress={() => openWebLink(links.bugsGit)}>
|
|
|
|
<CustomMaterialIcon
|
|
|
|
icon={'git'}
|
|
|
|
color={'#fff'}/>
|
|
|
|
<Text>{i18n.t('aboutScreen.bugsGit')}</Text>
|
|
|
|
</Button>
|
|
|
|
</View>
|
|
|
|
</Modalize>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
openBugReportModal() {
|
|
|
|
if (this.modalRef.current) {
|
|
|
|
this.modalRef.current.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-25 22:20:24 +02:00
|
|
|
render() {
|
|
|
|
const nav = this.props.navigation;
|
|
|
|
return (
|
|
|
|
<Container>
|
2019-09-17 11:51:26 +02:00
|
|
|
{this.getBugReportModal()}
|
2019-08-07 11:10:17 +02:00
|
|
|
<CustomHeader navigation={nav} title={i18n.t('screens.about')} hasBackButton={true}/>
|
2019-07-25 17:52:16 +02:00
|
|
|
<Content padder>
|
2019-06-25 22:20:24 +02:00
|
|
|
<Card>
|
|
|
|
<CardItem>
|
|
|
|
<Left>
|
2019-08-26 12:49:26 +02:00
|
|
|
<Thumbnail square source={require('../../assets/icon.png')}/>
|
2019-06-25 22:20:24 +02:00
|
|
|
<Body>
|
2019-08-27 19:25:09 +02:00
|
|
|
<H1>{appJson.expo.name}</H1>
|
2019-06-25 22:20:24 +02:00
|
|
|
<Text note>
|
2019-06-27 11:08:56 +02:00
|
|
|
v.{appJson.expo.version}
|
2019-06-25 22:20:24 +02:00
|
|
|
</Text>
|
|
|
|
</Body>
|
|
|
|
</Left>
|
|
|
|
</CardItem>
|
2019-06-28 11:35:15 +02:00
|
|
|
<FlatList
|
|
|
|
data={this.appData}
|
2019-08-26 12:49:26 +02:00
|
|
|
extraData={this.state}
|
2019-06-28 11:35:15 +02:00
|
|
|
keyExtractor={(item) => item.icon}
|
|
|
|
renderItem={({item}) =>
|
2019-08-26 12:49:26 +02:00
|
|
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
2019-06-28 11:35:15 +02:00
|
|
|
}
|
|
|
|
/>
|
2019-06-25 22:20:24 +02:00
|
|
|
</Card>
|
|
|
|
|
|
|
|
<Card>
|
|
|
|
<CardItem header>
|
|
|
|
<Text>{i18n.t('aboutScreen.author')}</Text>
|
|
|
|
</CardItem>
|
2019-06-28 11:35:15 +02:00
|
|
|
<FlatList
|
|
|
|
data={this.authorData}
|
2019-08-26 12:49:26 +02:00
|
|
|
extraData={this.state}
|
2019-06-28 11:35:15 +02:00
|
|
|
keyExtractor={(item) => item.icon}
|
|
|
|
renderItem={({item}) =>
|
2019-08-26 12:49:26 +02:00
|
|
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
2019-06-28 11:35:15 +02:00
|
|
|
}
|
|
|
|
/>
|
2019-06-25 22:20:24 +02:00
|
|
|
</Card>
|
|
|
|
|
|
|
|
<Card>
|
|
|
|
<CardItem header>
|
|
|
|
<Text>{i18n.t('aboutScreen.technologies')}</Text>
|
|
|
|
</CardItem>
|
2019-06-28 11:35:15 +02:00
|
|
|
<FlatList
|
|
|
|
data={this.technoData}
|
2019-08-26 12:49:26 +02:00
|
|
|
extraData={this.state}
|
2019-06-28 11:35:15 +02:00
|
|
|
keyExtractor={(item) => item.icon}
|
|
|
|
renderItem={({item}) =>
|
2019-08-26 12:49:26 +02:00
|
|
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
2019-06-28 11:35:15 +02:00
|
|
|
}
|
|
|
|
/>
|
2019-06-25 22:20:24 +02:00
|
|
|
</Card>
|
|
|
|
</Content>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|