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.

ProxiwashListItem.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import * as React from 'react';
  2. import {Avatar, Card, Text, withTheme} from 'react-native-paper';
  3. import {StyleSheet, View} from "react-native";
  4. import ProxiwashConstants from "../../constants/ProxiwashConstants";
  5. /**
  6. * Component used to display a proxiwash item, showing machine progression and state
  7. *
  8. * @param props Props to pass to the component
  9. * @return {*}
  10. */
  11. function ProxiwashListItem(props) {
  12. const {colors} = props.theme;
  13. let stateColors = {};
  14. stateColors[ProxiwashConstants.machineStates.TERMINE] = colors.proxiwashFinishedColor;
  15. stateColors[ProxiwashConstants.machineStates.DISPONIBLE] = colors.proxiwashReadyColor;
  16. stateColors[ProxiwashConstants.machineStates["EN COURS"]] = colors.proxiwashRunningColor;
  17. stateColors[ProxiwashConstants.machineStates.HS] = colors.proxiwashBrokenColor;
  18. stateColors[ProxiwashConstants.machineStates.ERREUR] = colors.proxiwashErrorColor;
  19. const icon = (
  20. props.isWatched ?
  21. <Avatar.Icon
  22. icon={'bell-ring'}
  23. size={45}
  24. color={colors.primary}
  25. style={styles.icon}
  26. /> :
  27. <Avatar.Icon
  28. icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}
  29. color={colors.text}
  30. size={40}
  31. style={styles.icon}
  32. />
  33. );
  34. return (
  35. <Card
  36. style={{
  37. margin: 5,
  38. height: props.height,
  39. justifyContent: 'center',
  40. }}
  41. onPress={props.onPress}
  42. >
  43. {ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates["EN COURS"] ?
  44. <Card style={{
  45. ...styles.backgroundCard,
  46. backgroundColor: colors.proxiwashRunningBgColor,
  47. }}/> : null
  48. }
  49. <Card style={{
  50. ...styles.progressionCard,
  51. width: props.progress,
  52. backgroundColor: stateColors[ProxiwashConstants.machineStates[props.state]],
  53. }}/>
  54. <Card.Title
  55. title={props.title}
  56. titleStyle={{fontSize: 17}}
  57. subtitle={props.description}
  58. style={styles.title}
  59. left={() => icon}
  60. right={() => (
  61. <View style={{flexDirection: 'row'}}>
  62. <View style={{justifyContent: 'center'}}>
  63. <Text style={
  64. ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates.TERMINE ?
  65. {fontWeight: 'bold',} : {}}
  66. >
  67. {props.statusText}
  68. </Text>
  69. </View>
  70. <Avatar.Icon
  71. icon={props.statusIcon}
  72. color={colors.text}
  73. size={30}
  74. style={styles.icon}
  75. />
  76. </View>)}
  77. />
  78. </Card>
  79. );
  80. }
  81. const styles = StyleSheet.create({
  82. icon: {
  83. backgroundColor: 'transparent'
  84. },
  85. backgroundCard: {
  86. height: '100%',
  87. position: 'absolute',
  88. left: 0,
  89. width: '100%',
  90. elevation: 0,
  91. },
  92. progressionCard: {
  93. height: '100%',
  94. position: 'absolute',
  95. left: 0,
  96. elevation: 0,
  97. },
  98. title: {
  99. backgroundColor: 'transparent',
  100. }
  101. });
  102. export default withTheme(ProxiwashListItem);