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.

IconButton.tsx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React from 'react';
  2. import { TouchableRipple } from 'react-native-paper';
  3. import Icon from '../../../icons/components/Icon';
  4. // eslint-disable-next-line lines-around-comment
  5. // @ts-ignore
  6. import styles from '../../../react/components/native/styles';
  7. import { IIconButtonProps } from '../../../react/types';
  8. import { BUTTON_TYPES } from '../../constants.native';
  9. import BaseTheme from '../BaseTheme.native';
  10. const IconButton: React.FC<IIconButtonProps> = ({
  11. accessibilityLabel,
  12. color: iconColor,
  13. disabled,
  14. onPress,
  15. size,
  16. src,
  17. style,
  18. tapColor,
  19. type
  20. }: IIconButtonProps) => {
  21. const { PRIMARY, SECONDARY, TERTIARY } = BUTTON_TYPES;
  22. let color;
  23. let rippleColor;
  24. let iconButtonContainerStyles;
  25. if (type === PRIMARY) {
  26. color = BaseTheme.palette.icon01;
  27. iconButtonContainerStyles = styles.iconButtonContainerPrimary;
  28. rippleColor = BaseTheme.palette.action01;
  29. } else if (type === SECONDARY) {
  30. color = BaseTheme.palette.icon04;
  31. iconButtonContainerStyles = styles.iconButtonContainerSecondary;
  32. rippleColor = BaseTheme.palette.action02;
  33. } else if (type === TERTIARY) {
  34. color = iconColor;
  35. iconButtonContainerStyles = styles.iconButtonContainer;
  36. rippleColor = BaseTheme.palette.action03;
  37. } else {
  38. color = iconColor;
  39. rippleColor = tapColor;
  40. }
  41. if (disabled) {
  42. color = BaseTheme.palette.icon03;
  43. iconButtonContainerStyles = styles.iconButtonContainerDisabled;
  44. rippleColor = 'transparent';
  45. }
  46. return (
  47. <TouchableRipple
  48. accessibilityLabel = { accessibilityLabel }
  49. disabled = { disabled }
  50. // @ts-ignore
  51. onPress = { onPress }
  52. rippleColor = { rippleColor }
  53. style = { [
  54. iconButtonContainerStyles,
  55. style
  56. ] }>
  57. <Icon
  58. color = { color }
  59. size = { 20 || size }
  60. src = { src } />
  61. </TouchableRipple>
  62. );
  63. };
  64. export default IconButton;