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.

DashboardEditItem.tsx 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import { Image, StyleSheet } from 'react-native';
  21. import { List, useTheme } from 'react-native-paper';
  22. import { ServiceItemType } from '../../../utils/Services';
  23. type PropsType = {
  24. item: ServiceItemType;
  25. isActive: boolean;
  26. height: number;
  27. onPress: () => void;
  28. };
  29. const styles = StyleSheet.create({
  30. image: {
  31. width: 40,
  32. height: 40,
  33. },
  34. item: {
  35. justifyContent: 'center',
  36. paddingLeft: 30,
  37. },
  38. });
  39. function DashboardEditItem(props: PropsType) {
  40. const theme = useTheme();
  41. const { item, onPress, height, isActive } = props;
  42. const backgroundColor = isActive
  43. ? theme.colors.proxiwashFinishedColor
  44. : 'transparent';
  45. return (
  46. <List.Item
  47. title={item.title}
  48. description={item.subtitle}
  49. onPress={isActive ? undefined : onPress}
  50. left={() => (
  51. <Image
  52. source={
  53. typeof item.image === 'string' ? { uri: item.image } : item.image
  54. }
  55. style={styles.image}
  56. />
  57. )}
  58. right={(iconProps) =>
  59. isActive ? (
  60. <List.Icon
  61. style={iconProps.style}
  62. icon="check"
  63. color={theme.colors.success}
  64. />
  65. ) : null
  66. }
  67. style={{
  68. ...styles.image,
  69. height: height,
  70. backgroundColor: backgroundColor,
  71. }}
  72. />
  73. );
  74. }
  75. const areEqual = (prevProps: PropsType, nextProps: PropsType): boolean => {
  76. return nextProps.isActive === prevProps.isActive;
  77. };
  78. export default React.memo(DashboardEditItem, areEqual);