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.

ToolboxItem.native.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // @flow
  2. import React from 'react';
  3. import { TouchableHighlight } from 'react-native';
  4. import { Icon } from '../../base/font-icons';
  5. import AbstractToolboxItem from './AbstractToolboxItem';
  6. import type { Props } from './AbstractToolboxItem';
  7. /**
  8. * Native implementation of {@code AbstractToolboxItem}.
  9. */
  10. export default class ToolboxItem extends AbstractToolboxItem<Props> {
  11. /**
  12. * Transform the given (web) icon name into a name that works with
  13. * {@code Icon}.
  14. *
  15. * @private
  16. * @returns {string}
  17. */
  18. _getIconName() {
  19. const { iconName } = this.props;
  20. return iconName.replace('icon-', '').split(' ')[0];
  21. }
  22. /**
  23. * Handles rendering of the actual item.
  24. *
  25. * TODO: currently no handling for labels is implemented.
  26. *
  27. * @protected
  28. * @returns {ReactElement}
  29. */
  30. _renderItem() {
  31. const {
  32. accessibilityLabel,
  33. disabled,
  34. onClick,
  35. styles
  36. } = this.props;
  37. return (
  38. <TouchableHighlight
  39. accessibilityLabel = { accessibilityLabel }
  40. disabled = { disabled }
  41. onPress = { onClick }
  42. style = { styles && styles.style }
  43. underlayColor = { styles && styles.underlayColor } >
  44. <Icon
  45. name = { this._getIconName() }
  46. style = { styles && styles.iconStyle } />
  47. </TouchableHighlight>
  48. );
  49. }
  50. }