Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AboutScreen.js 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // @flow
  2. import * as React from 'react';
  3. import {Alert, FlatList, Linking, Platform} from 'react-native';
  4. import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail} from 'native-base';
  5. import CustomHeader from "../../components/CustomHeader";
  6. import i18n from "i18n-js";
  7. import appJson from '../../app';
  8. import packageJson from '../../package';
  9. import CustomMaterialIcon from "../../components/CustomMaterialIcon";
  10. const links = {
  11. appstore: 'https://qwant.com',
  12. playstore: 'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application',
  13. expo: 'https://expo.io/@amicaleinsat/application-amicale',
  14. git: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/README.md',
  15. bugs: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/issues',
  16. changelog: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/Changelog.md',
  17. license: 'https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/LICENSE',
  18. mail: "mailto:vergnet@etud.insa-toulouse.fr?subject=Application Amicale INSA Toulouse&body=",
  19. linkedin: 'https://www.linkedin.com/in/arnaud-vergnet-434ba5179/',
  20. facebook: 'https://www.facebook.com/arnaud.vergnet',
  21. react: 'https://facebook.github.io/react-native/',
  22. };
  23. type Props = {
  24. navigation: Object,
  25. };
  26. /**
  27. * Opens a link in the device's browser
  28. * @param link The link to open
  29. */
  30. function openWebLink(link) {
  31. Linking.openURL(link).catch((err) => console.error('Error opening link', err));
  32. }
  33. /**
  34. * Class defining an about screen. This screen shows the user information about the app and it's author.
  35. */
  36. export default class AboutScreen extends React.Component<Props> {
  37. /**
  38. * Data to be displayed in the app card
  39. */
  40. appData: Array<Object> = [
  41. {
  42. onPressCallback: () => openWebLink(Platform.OS === "ios" ? links.appstore : links.playstore),
  43. icon: Platform.OS === "ios" ? 'apple' : 'google-play',
  44. text: Platform.OS === "ios" ? i18n.t('aboutScreen.appstore') : i18n.t('aboutScreen.playstore'),
  45. showChevron: true
  46. },
  47. {
  48. onPressCallback: () => openWebLink(links.expo),
  49. icon: 'worker',
  50. text: i18n.t('aboutScreen.expoBeta'),
  51. showChevron: true
  52. },
  53. {
  54. onPressCallback: () => openWebLink(links.git),
  55. icon: 'git',
  56. text: 'Git',
  57. showChevron: true
  58. },
  59. {
  60. onPressCallback: () => openWebLink(links.bugs),
  61. icon: 'bug',
  62. text: i18n.t('aboutScreen.bugs'),
  63. showChevron: true
  64. },
  65. {
  66. onPressCallback: () => openWebLink(links.changelog),
  67. icon: 'refresh',
  68. text: i18n.t('aboutScreen.changelog'),
  69. showChevron: true
  70. },
  71. {
  72. onPressCallback: () => openWebLink(links.license),
  73. icon: 'file-document',
  74. text: i18n.t('aboutScreen.license'),
  75. showChevron: true
  76. },
  77. ];
  78. /**
  79. * Data to be displayed in the author card
  80. */
  81. authorData: Array<Object> = [
  82. {
  83. onPressCallback: () => Alert.alert('Coucou', 'Whaou'),
  84. icon: 'account-circle',
  85. text: 'Arnaud VERGNET',
  86. showChevron: false
  87. },
  88. {
  89. onPressCallback: () => openWebLink(links.mail),
  90. icon: 'email',
  91. text: i18n.t('aboutScreen.mail'),
  92. showChevron: true
  93. },
  94. {
  95. onPressCallback: () => openWebLink(links.linkedin),
  96. icon: 'linkedin',
  97. text: 'Linkedin',
  98. showChevron: true
  99. },
  100. {
  101. onPressCallback: () => openWebLink(links.facebook),
  102. icon: 'facebook',
  103. text: 'Facebook',
  104. showChevron: true
  105. },
  106. ];
  107. /**
  108. * Data to be displayed in the technologies card
  109. */
  110. technoData: Array<Object> = [
  111. {
  112. onPressCallback: () => openWebLink(links.react),
  113. icon: 'react',
  114. text: i18n.t('aboutScreen.reactNative'),
  115. showChevron: false
  116. },
  117. {
  118. onPressCallback: () => this.props.navigation.navigate('AboutDependenciesScreen', {data: packageJson.dependencies}),
  119. icon: 'developer-board',
  120. text: i18n.t('aboutScreen.libs'),
  121. showChevron: true
  122. },
  123. ];
  124. /**
  125. * Get a clickable card item to be rendered inside a card.
  126. *
  127. * @param onPressCallback The callback to use when the item is clicked
  128. * @param icon The icon name to use from MaterialCommunityIcons
  129. * @param text The text to show
  130. * @param showChevron Whether to show a chevron indicating this button will change screen
  131. * @returns {React.Node}
  132. */
  133. static getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean) {
  134. return (
  135. <CardItem button
  136. onPress={onPressCallback}>
  137. <Left>
  138. <CustomMaterialIcon icon={icon}/>
  139. <Text>{text}</Text>
  140. </Left>
  141. {showChevron ?
  142. <Right>
  143. <CustomMaterialIcon icon="chevron-right"
  144. fontSize={20}/>
  145. </Right>
  146. :
  147. <Right/>
  148. }
  149. </CardItem>)
  150. ;
  151. }
  152. render() {
  153. const nav = this.props.navigation;
  154. return (
  155. <Container>
  156. <CustomHeader navigation={nav} title={i18n.t('screens.about')} hasBackButton={true}/>
  157. <Content padder>
  158. <Card>
  159. <CardItem>
  160. <Left>
  161. <Thumbnail square source={require('../../assets/amicale.png')}/>
  162. <Body>
  163. <H1>Amicale INSA Toulouse</H1>
  164. <Text note>
  165. v.{appJson.expo.version}
  166. </Text>
  167. </Body>
  168. </Left>
  169. </CardItem>
  170. <FlatList
  171. data={this.appData}
  172. keyExtractor={(item) => item.icon}
  173. renderItem={({item}) =>
  174. AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
  175. }
  176. />
  177. </Card>
  178. <Card>
  179. <CardItem header>
  180. <Text>{i18n.t('aboutScreen.author')}</Text>
  181. </CardItem>
  182. <FlatList
  183. data={this.authorData}
  184. keyExtractor={(item) => item.icon}
  185. renderItem={({item}) =>
  186. AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
  187. }
  188. />
  189. </Card>
  190. <Card>
  191. <CardItem header>
  192. <Text>{i18n.t('aboutScreen.technologies')}</Text>
  193. </CardItem>
  194. <FlatList
  195. data={this.technoData}
  196. keyExtractor={(item) => item.icon}
  197. renderItem={({item}) =>
  198. AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
  199. }
  200. />
  201. </Card>
  202. </Content>
  203. </Container>
  204. );
  205. }
  206. }