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.

DashboardEditItem.tsx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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} from 'react-native';
  21. import {List, useTheme} from 'react-native-paper';
  22. import type {ServiceItemType} from '../../../managers/ServicesManager';
  23. type PropsType = {
  24. item: ServiceItemType;
  25. isActive: boolean;
  26. height: number;
  27. onPress: () => void;
  28. };
  29. function DashboardEditItem(props: PropsType) {
  30. const theme = useTheme();
  31. const {item, onPress, height, isActive} = props;
  32. return (
  33. <List.Item
  34. title={item.title}
  35. description={item.subtitle}
  36. onPress={isActive ? undefined : onPress}
  37. left={() => (
  38. <Image
  39. source={
  40. typeof item.image === 'string' ? {uri: item.image} : item.image
  41. }
  42. style={{
  43. width: 40,
  44. height: 40,
  45. }}
  46. />
  47. )}
  48. right={(iconProps) =>
  49. isActive ? (
  50. <List.Icon
  51. style={iconProps.style}
  52. icon="check"
  53. color={theme.colors.success}
  54. />
  55. ) : null
  56. }
  57. style={{
  58. height,
  59. justifyContent: 'center',
  60. paddingLeft: 30,
  61. backgroundColor: isActive
  62. ? theme.colors.proxiwashFinishedColor
  63. : 'transparent',
  64. }}
  65. />
  66. );
  67. }
  68. const areEqual = (prevProps: PropsType, nextProps: PropsType): boolean => {
  69. return nextProps.isActive !== prevProps.isActive;
  70. };
  71. export default React.memo(DashboardEditItem, areEqual);