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.

ClubListItem.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import * as React from 'react';
  3. import {Avatar, Chip, List, withTheme} from 'react-native-paper';
  4. import {View} from "react-native";
  5. type Props = {
  6. onPress: Function,
  7. categoryTranslator: Function,
  8. item: Object,
  9. height: number,
  10. }
  11. class ClubListItem extends React.Component<Props> {
  12. colors: Object;
  13. hasManagers: boolean;
  14. constructor(props) {
  15. super(props);
  16. this.colors = props.theme.colors;
  17. this.hasManagers = props.item.responsibles.length > 0;
  18. }
  19. shouldComponentUpdate() {
  20. return false;
  21. }
  22. getCategoriesRender(categories: Array<number | null>) {
  23. let final = [];
  24. for (let i = 0; i < categories.length; i++) {
  25. if (categories[i] !== null){
  26. const category = this.props.categoryTranslator(categories[i]);
  27. final.push(
  28. <Chip
  29. style={{marginRight: 5, marginBottom: 5}}
  30. key={this.props.item.id + ':' + category.id}
  31. >
  32. {category.name}
  33. </Chip>
  34. );
  35. }
  36. }
  37. return <View style={{flexDirection: 'row'}}>{final}</View>;
  38. }
  39. render() {
  40. const categoriesRender = this.getCategoriesRender.bind(this, this.props.item.category);
  41. return (
  42. <List.Item
  43. title={this.props.item.name}
  44. description={categoriesRender}
  45. onPress={this.props.onPress}
  46. left={(props) => <Avatar.Image
  47. {...props}
  48. style={{backgroundColor: 'transparent'}}
  49. size={64}
  50. source={{uri: this.props.item.logo}}/>}
  51. right={(props) => <Avatar.Icon
  52. {...props}
  53. style={{
  54. marginTop: 'auto',
  55. marginBottom: 'auto',
  56. backgroundColor: 'transparent',
  57. }}
  58. size={48}
  59. icon={this.hasManagers ? "check-circle-outline" : "alert-circle-outline"}
  60. color={this.hasManagers ? this.colors.success : this.colors.primary}
  61. />}
  62. style={{
  63. height: this.props.height,
  64. justifyContent: 'center',
  65. }}
  66. />
  67. );
  68. }
  69. }
  70. export default withTheme(ClubListItem);