Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

FilmStrip.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { ScrollView } from 'react-native';
  4. import { Container } from '../../base/react';
  5. import Thumbnail from './Thumbnail';
  6. import { styles } from './_';
  7. /**
  8. * React component for film strip.
  9. *
  10. * @extends Component
  11. */
  12. class FilmStrip extends Component {
  13. /**
  14. * FilmStrip component's property types.
  15. *
  16. * @static
  17. */
  18. static propTypes = {
  19. participants: React.PropTypes.array,
  20. visible: React.PropTypes.bool.isRequired
  21. }
  22. /**
  23. * Implements React's {@link Component#render()}.
  24. *
  25. * @inheritdoc
  26. */
  27. render() {
  28. return (
  29. <Container
  30. style = { styles.filmStrip }
  31. visible = { this.props.visible }>
  32. <ScrollView
  33. // eslint-disable-next-line react/jsx-curly-spacing
  34. contentContainerStyle = {
  35. styles.filmStripScrollViewContentContainer
  36. } // eslint-disable-line react/jsx-curly-spacing
  37. horizontal = { true }
  38. showsHorizontalScrollIndicator = { false }
  39. showsVerticalScrollIndicator = { false }>
  40. {
  41. this._sort(this.props.participants)
  42. .map(p =>
  43. <Thumbnail
  44. key = { p.id }
  45. participant = { p } />)
  46. }
  47. </ScrollView>
  48. </Container>
  49. );
  50. }
  51. /**
  52. * Sorts a specific array of <tt>Participant</tt>s in display order.
  53. *
  54. * @param {Participant[]} participants - The array of <tt>Participant</tt>s
  55. * to sort in display order.
  56. * @private
  57. * @returns {Participant[]} A new array containing the elements of the
  58. * specified <tt>participants</tt> array sorted in display order.
  59. */
  60. _sort(participants) {
  61. // XXX Array.prototype.sort() is not appropriate because (1) it operates
  62. // in place and (2) it is not necessarily stable.
  63. const sortedParticipants = [];
  64. // Group the remote participants so that the local participant does not
  65. // appear in between remote participants. Have the remote participants
  66. // from right to left with the newest added/joined to the leftmost side.
  67. for (let i = participants.length - 1; i >= 0; --i) {
  68. const p = participants[i];
  69. p.local || sortedParticipants.push(p);
  70. }
  71. // Have the local participant at the rightmost side.
  72. for (let i = participants.length - 1; i >= 0; --i) {
  73. const p = participants[i];
  74. p.local && sortedParticipants.push(p);
  75. }
  76. return sortedParticipants;
  77. }
  78. }
  79. /**
  80. * Function that maps parts of Redux state tree into component props.
  81. *
  82. * @param {Object} state - Redux state.
  83. * @returns {{
  84. * participants: Participant[],
  85. * tracks: (JitsiLocalTrack|JitsiRemoteTrack)[]
  86. * }}
  87. */
  88. function mapStateToProps(state) {
  89. return {
  90. participants: state['features/base/participants']
  91. };
  92. }
  93. export default connect(mapStateToProps)(FilmStrip);