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