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.

EquipmentListItem.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @flow
  2. import * as React from 'react';
  3. import {Avatar, List, withTheme} from 'react-native-paper';
  4. import type {CustomTheme} from "../../../managers/ThemeManager";
  5. import type {Device} from "../../../screens/Amicale/Equipment/EquipmentListScreen";
  6. import i18n from "i18n-js";
  7. import {
  8. getFirstEquipmentAvailability,
  9. getRelativeDateString,
  10. isEquipmentAvailable
  11. } from "../../../utils/EquipmentBooking";
  12. type Props = {
  13. onPress: () => void,
  14. item: Device,
  15. height: number,
  16. theme: CustomTheme,
  17. }
  18. class EquipmentListItem extends React.Component<Props> {
  19. shouldComponentUpdate() {
  20. return false;
  21. }
  22. render() {
  23. const colors = this.props.theme.colors;
  24. const item = this.props.item;
  25. const isAvailable = isEquipmentAvailable(item);
  26. const firstAvailability = getFirstEquipmentAvailability(item);
  27. return (
  28. <List.Item
  29. title={item.name}
  30. description={isAvailable
  31. ? i18n.t('equipmentScreen.bail', {cost: item.caution})
  32. : i18n.t('equipmentScreen.available', {date: getRelativeDateString(firstAvailability)})}
  33. onPress={this.props.onPress}
  34. left={(props) => <Avatar.Icon
  35. {...props}
  36. style={{
  37. backgroundColor: 'transparent',
  38. }}
  39. icon={isAvailable ? "check-circle-outline" : "update"}
  40. color={isAvailable ? colors.success : colors.primary}
  41. />}
  42. right={(props) => <Avatar.Icon
  43. {...props}
  44. style={{
  45. marginTop: 'auto',
  46. marginBottom: 'auto',
  47. backgroundColor: 'transparent',
  48. }}
  49. size={48}
  50. icon={"chevron-right"}
  51. />}
  52. style={{
  53. height: this.props.height,
  54. justifyContent: 'center',
  55. }}
  56. />
  57. );
  58. }
  59. }
  60. export default withTheme(EquipmentListItem);