Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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. * Implements React's {@link Component#render()}.
  15. *
  16. * @inheritdoc
  17. */
  18. render() {
  19. return (
  20. <Container
  21. style = { styles.filmStrip }
  22. visible = { this.props.visible }>
  23. <ScrollView
  24. // eslint-disable-next-line react/jsx-curly-spacing
  25. contentContainerStyle = {
  26. styles.filmStripScrollViewContentContainer
  27. } // eslint-disable-line react/jsx-curly-spacing
  28. horizontal = { true }
  29. showsHorizontalScrollIndicator = { false }
  30. showsVerticalScrollIndicator = { false }>
  31. {
  32. this._sort(this.props.participants)
  33. .map(p =>
  34. <Thumbnail
  35. key = { p.id }
  36. participant = { p } />)
  37. }
  38. </ScrollView>
  39. </Container>
  40. );
  41. }
  42. /**
  43. * Sorts a specific array of <tt>Participant</tt>s in display order.
  44. *
  45. * @param {Participant[]} participants - The array of <tt>Participant</tt>s
  46. * to sort in display order.
  47. * @private
  48. * @returns {Participant[]} A new array containing the elements of the
  49. * specified <tt>participants</tt> array sorted in display order.
  50. */
  51. _sort(participants) {
  52. // XXX Array.prototype.sort() is not appropriate because (1) it operates
  53. // in place and (2) it is not necessarily stable.
  54. const sortedParticipants = [];
  55. // Group the remote participants so that the local participant does not
  56. // appear in between remote participants. Have the remote participants
  57. // from right to left with the newest added/joined to the leftmost side.
  58. for (let i = participants.length - 1; i >= 0; --i) {
  59. const p = participants[i];
  60. p.local || sortedParticipants.push(p);
  61. }
  62. // Have the local participant at the rightmost side.
  63. for (let i = participants.length - 1; i >= 0; --i) {
  64. const p = participants[i];
  65. p.local && sortedParticipants.push(p);
  66. }
  67. return sortedParticipants;
  68. }
  69. }
  70. /**
  71. * FilmStrip component's property types.
  72. *
  73. * @static
  74. */
  75. FilmStrip.propTypes = {
  76. participants: React.PropTypes.array,
  77. visible: React.PropTypes.bool.isRequired
  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);