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.

PreviewEventDashboardItem.js 2.7KB

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