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.

ProxiwashSectionHeader.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import * as React from 'react';
  2. import {Avatar, Text, withTheme} from 'react-native-paper';
  3. import {StyleSheet, View} from "react-native";
  4. import i18n from "i18n-js";
  5. type Props = {
  6. title: string,
  7. isDryer: boolean,
  8. nbAvailable: number,
  9. }
  10. /**
  11. * Component used to display a proxiwash item, showing machine progression and state
  12. */
  13. class ProxiwashListItem extends React.Component<Props> {
  14. constructor(props) {
  15. super(props);
  16. }
  17. shouldComponentUpdate(nextProps: Props) {
  18. return (nextProps.theme.dark !== this.props.theme.dark)
  19. || (nextProps.nbAvailable !== this.props.nbAvailable)
  20. }
  21. render() {
  22. const props = this.props;
  23. const subtitle = props.nbAvailable + ' ' + (
  24. (props.nbAvailable <= 1)
  25. ? i18n.t('screens.proxiwash.numAvailable')
  26. : i18n.t('screens.proxiwash.numAvailablePlural'));
  27. const iconColor = props.nbAvailable > 0
  28. ? this.props.theme.colors.success
  29. : this.props.theme.colors.primary;
  30. return (
  31. <View style={styles.container}>
  32. <Avatar.Icon
  33. icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}
  34. color={iconColor}
  35. style={styles.icon}
  36. />
  37. <View style={{justifyContent: 'center'}}>
  38. <Text style={styles.text}>
  39. {props.title}
  40. </Text>
  41. <Text style={{color: this.props.theme.colors.subtitle}}>
  42. {subtitle}
  43. </Text>
  44. </View>
  45. </View>
  46. );
  47. }
  48. }
  49. const styles = StyleSheet.create({
  50. container: {
  51. flexDirection: 'row',
  52. marginLeft: 5,
  53. marginRight: 5,
  54. marginBottom: 10,
  55. marginTop: 20,
  56. },
  57. icon: {
  58. backgroundColor: 'transparent'
  59. },
  60. text: {
  61. fontSize: 20,
  62. fontWeight: 'bold',
  63. }
  64. });
  65. export default withTheme(ProxiwashListItem);