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.

Captions.native.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @flow
  2. import React from 'react';
  3. import { Container, Text } from '../../base/react';
  4. import { connect } from '../../base/redux';
  5. import {
  6. _abstractMapStateToProps,
  7. AbstractCaptions,
  8. type AbstractCaptionsProps
  9. } from './AbstractCaptions';
  10. import styles from './styles';
  11. /**
  12. * The type of the React {@code Component} props of {@link Captions}.
  13. */
  14. type Props = AbstractCaptionsProps & {
  15. onPress: Function
  16. };
  17. /**
  18. * React {@code Component} which can display speech-to-text results from
  19. * Jigasi as subtitles.
  20. */
  21. class Captions
  22. extends AbstractCaptions<Props> {
  23. /**
  24. * Renders the transcription text.
  25. *
  26. * @param {string} id - The ID of the transcript message from which the
  27. * {@code text} has been created.
  28. * @param {string} text - Subtitles text formatted with the participant's
  29. * name.
  30. * @protected
  31. * @returns {React$Element} - The React element which displays the text.
  32. */
  33. _renderParagraph(id: string, text: string): React$Element<*> {
  34. return (
  35. <Text
  36. key = { id }
  37. onPress = { this.props.onPress }
  38. style = { styles.subtitle } >
  39. { text }
  40. </Text>
  41. );
  42. }
  43. /**
  44. * Renders the subtitles container.
  45. *
  46. * @param {Array<React$Element>} paragraphs - An array of elements created
  47. * for each subtitle using the {@link _renderParagraph} method.
  48. * @protected
  49. * @returns {React$Element} - The subtitles container.
  50. */
  51. _renderSubtitlesContainer(
  52. paragraphs: Array<React$Element<*>>): React$Element<*> {
  53. return (
  54. <Container style = { styles.subtitlesContainer } >
  55. { paragraphs }
  56. </Container>
  57. );
  58. }
  59. }
  60. export default connect(_abstractMapStateToProps)(Captions);