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.

ToolbarButton.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import PropTypes from 'prop-types';
  2. import React from 'react';
  3. import { TouchableHighlight } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { Icon } from '../../../base/font-icons';
  6. import AbstractToolbarButton from '../AbstractToolbarButton';
  7. /**
  8. * Represents a button in {@link Toolbar} on React Native.
  9. *
  10. * @extends AbstractToolbarButton
  11. */
  12. class ToolbarButton extends AbstractToolbarButton {
  13. /**
  14. * {@code ToolbarButton} component's property types.
  15. *
  16. * @static
  17. */
  18. static propTypes = {
  19. ...AbstractToolbarButton.propTypes,
  20. /**
  21. * Indicates whether this {@code ToolbarButton} is disabled.
  22. */
  23. disabled: PropTypes.bool
  24. };
  25. /**
  26. * Renders the button of this {@code ToolbarButton}.
  27. *
  28. * @param {Object} children - The children, if any, to be rendered inside
  29. * the button. Presumably, contains the icon of this {@code ToolbarButton}.
  30. * @protected
  31. * @returns {ReactElement} The button of this {@code ToolbarButton}.
  32. */
  33. _renderButton(children) {
  34. const props = {};
  35. 'accessibilityLabel' in this.props
  36. && (props.accessibilityLabel = this.props.accessibilityLabel);
  37. 'disabled' in this.props && (props.disabled = this.props.disabled);
  38. 'onClick' in this.props && (props.onPress = this._onClick);
  39. 'style' in this.props && (props.style = this.props.style);
  40. 'underlayColor' in this.props
  41. && (props.underlayColor = this.props.underlayColor);
  42. return React.createElement(TouchableHighlight, props, children);
  43. }
  44. /**
  45. * Renders the icon of this {@code ToolbarButton}.
  46. *
  47. * @inheritdoc
  48. */
  49. _renderIcon() {
  50. return super._renderIcon(Icon);
  51. }
  52. }
  53. export default connect()(ToolbarButton);