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 1.8KB

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