Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

IconButton.tsx 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. onPress = { onPress }
  51. rippleColor = { rippleColor }
  52. style = { [
  53. iconButtonContainerStyles,
  54. style
  55. ] }>
  56. <Icon
  57. color = { color }
  58. size = { 20 || size }
  59. src = { src } />
  60. </TouchableRipple>
  61. );
  62. };
  63. export default IconButton;