您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ToolbarButton.native.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 'disabled' in this.props && (props.disabled = this.props.disabled);
  36. 'onClick' in this.props && (props.onPress = this._onClick);
  37. 'style' in this.props && (props.style = this.props.style);
  38. 'underlayColor' in this.props
  39. && (props.underlayColor = this.props.underlayColor);
  40. return React.createElement(TouchableHighlight, props, children);
  41. }
  42. // eslint-disable-next-line valid-jsdoc
  43. /**
  44. * @inheritdoc
  45. */
  46. _renderIcon() {
  47. return super._renderIcon(Icon);
  48. }
  49. }
  50. export default connect()(ToolbarButton);