Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ForwardButton.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Text, TouchableOpacity } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { ColorSchemeRegistry } from '../../../color-scheme';
  6. import { translate } from '../../../i18n';
  7. /**
  8. * The type of the React {@code Component} props of {@link ForwardButton}
  9. */
  10. type Props = {
  11. /**
  12. * True if the nutton should be disabled.
  13. */
  14. disabled: boolean;
  15. /**
  16. * The i18n label key of the button.
  17. */
  18. labelKey: string,
  19. /**
  20. * The action to be performed when the button is pressed.
  21. */
  22. onPress: Function,
  23. /**
  24. * An external style object passed to the component.
  25. */
  26. style?: Object,
  27. /**
  28. * The function to be used to translate i18n labels.
  29. */
  30. t: Function,
  31. /**
  32. * The color schemed style of the Header component.
  33. */
  34. _headerStyles: Object
  35. };
  36. /**
  37. * A component rendering a forward/next/action button.
  38. */
  39. class ForwardButton extends Component<Props> {
  40. /**
  41. * Implements React's {@link Component#render()}, renders the button.
  42. *
  43. * @inheritdoc
  44. * @returns {ReactElement}
  45. */
  46. render() {
  47. const { _headerStyles } = this.props;
  48. return (
  49. <TouchableOpacity
  50. accessibilityLabel = { 'Forward' }
  51. disabled = { this.props.disabled }
  52. onPress = { this.props.onPress } >
  53. <Text
  54. style = { [
  55. _headerStyles.headerButtonText,
  56. this.props.disabled && _headerStyles.disabledButtonText,
  57. this.props.style
  58. ] }>
  59. { this.props.t(this.props.labelKey) }
  60. </Text>
  61. </TouchableOpacity>
  62. );
  63. }
  64. }
  65. /**
  66. * Maps part of the Redux state to the props of the component.
  67. *
  68. * @param {Object} state - The Redux state.
  69. * @returns {{
  70. * _headerStyles: Object
  71. * }}
  72. */
  73. function _mapStateToProps(state) {
  74. return {
  75. _headerStyles: ColorSchemeRegistry.get(state, 'Header')
  76. };
  77. }
  78. export default translate(connect(_mapStateToProps)(ForwardButton));