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.

CustomOptionButton.tsx 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react';
  2. import { Image } from 'react-native';
  3. import { SvgCssUri } from 'react-native-svg';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../../base/i18n/functions';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import styles from './styles';
  8. interface IProps extends AbstractButtonProps {
  9. icon: any;
  10. id?: string;
  11. text: string;
  12. }
  13. /**
  14. * Component that renders a custom button.
  15. *
  16. * @returns {Component}
  17. */
  18. class CustomOptionButton extends AbstractButton<IProps> {
  19. iconSrc = this.props.icon;
  20. id = this.props.id;
  21. text = this.props.text;
  22. /**
  23. * Custom icon component.
  24. *
  25. * @returns {React.Component}
  26. */
  27. icon = () => {
  28. let iconComponent;
  29. if (!this.iconSrc) {
  30. return null;
  31. }
  32. if (this.iconSrc?.includes('svg')) {
  33. iconComponent
  34. = (
  35. <SvgCssUri
  36. style = { styles.iconImageStyles }
  37. uri = { this.iconSrc } />);
  38. } else {
  39. iconComponent
  40. = (
  41. <Image
  42. source = {{ uri: this.iconSrc }}
  43. style = { styles.iconImageStyles }
  44. tintColor = { 'white' } />);
  45. }
  46. return iconComponent;
  47. };
  48. label = this.text;
  49. }
  50. export default translate(connect()(CustomOptionButton));