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.native.js 1.6KB

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