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.

PreviewEventDashboardItem.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // @flow
  2. import * as React from 'react';
  3. import {StyleSheet} from "react-native";
  4. import i18n from "i18n-js";
  5. import {Avatar, Button, Card} from 'react-native-paper';
  6. import {getFormattedEventTime, isDescriptionEmpty} from "../../utils/Planning";
  7. import CustomHTML from "../Overrides/CustomHTML";
  8. type Props = {
  9. event: Object,
  10. clickAction: Function,
  11. }
  12. /**
  13. * Component used to display an event preview if an event is available
  14. */
  15. class PreviewEventDashboardItem extends React.Component<Props> {
  16. render() {
  17. const props = this.props;
  18. const isEmpty = props.event === undefined
  19. ? true
  20. : isDescriptionEmpty(props.event['description']);
  21. if (props.event !== undefined && props.event !== null) {
  22. const hasImage = props.event['logo'] !== '' && props.event['logo'] !== null;
  23. const getImage = () => <Avatar.Image
  24. source={{uri: props.event['logo']}}
  25. size={50}
  26. style={styles.avatar}/>;
  27. return (
  28. <Card
  29. style={styles.card}
  30. onPress={props.clickAction}
  31. elevation={3}
  32. >
  33. {hasImage ?
  34. <Card.Title
  35. title={props.event['title']}
  36. subtitle={getFormattedEventTime(props.event['date_begin'], props.event['date_end'])}
  37. left={getImage}
  38. /> :
  39. <Card.Title
  40. title={props.event['title']}
  41. subtitle={getFormattedEventTime(props.event['date_begin'], props.event['date_end'])}
  42. />}
  43. {!isEmpty ?
  44. <Card.Content style={styles.content}>
  45. <CustomHTML html={props.event['description']}/>
  46. </Card.Content> : null}
  47. <Card.Actions style={styles.actions}>
  48. <Button
  49. icon={'chevron-right'}
  50. >
  51. {i18n.t("homeScreen.dashboard.seeMore")}
  52. </Button>
  53. </Card.Actions>
  54. </Card>
  55. );
  56. } else
  57. return null;
  58. }
  59. }
  60. const styles = StyleSheet.create({
  61. card: {
  62. marginBottom: 10
  63. },
  64. content: {
  65. maxHeight: 150,
  66. overflow: 'hidden',
  67. },
  68. actions: {
  69. marginLeft: 'auto',
  70. marginTop: 'auto',
  71. flexDirection: 'row'
  72. },
  73. avatar: {
  74. backgroundColor: 'transparent'
  75. }
  76. });
  77. export default PreviewEventDashboardItem;