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

ToolbarButton.native.js 1.7KB

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