Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
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.

ImageListItem.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import { Text, TouchableRipple } from 'react-native-paper';
  21. import { Image, StyleSheet, View } from 'react-native';
  22. import GENERAL_STYLES from '../../../constants/Styles';
  23. import { ServiceItemType } from '../../../utils/Services';
  24. type PropsType = {
  25. item: ServiceItemType;
  26. width: number;
  27. };
  28. const styles = StyleSheet.create({
  29. ripple: {
  30. margin: 5,
  31. },
  32. text: {
  33. ...GENERAL_STYLES.centerHorizontal,
  34. marginTop: 5,
  35. textAlign: 'center',
  36. },
  37. });
  38. function ImageListItem(props: PropsType) {
  39. const { item } = props;
  40. const source =
  41. typeof item.image === 'number' ? item.image : { uri: item.image };
  42. return (
  43. <TouchableRipple
  44. style={{
  45. width: props.width,
  46. height: props.width + 40,
  47. ...styles.ripple,
  48. }}
  49. onPress={item.onPress}
  50. >
  51. <View>
  52. <Image
  53. style={{
  54. width: props.width - 20,
  55. height: props.width - 20,
  56. ...GENERAL_STYLES.centerHorizontal,
  57. }}
  58. source={source}
  59. />
  60. <Text style={styles.text}>{item.title}</Text>
  61. </View>
  62. </TouchableRipple>
  63. );
  64. }
  65. export default React.memo(ImageListItem, () => true);