2017-11-03 20:14:38 +00:00
|
|
|
// @flow
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2016-10-05 14:36:59 +00:00
|
|
|
import React, { Component } from 'react';
|
2016-10-31 17:33:32 +00:00
|
|
|
import { ScrollView } from 'react-native';
|
2017-02-16 23:02:40 +00:00
|
|
|
import { connect } from 'react-redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-11-03 20:14:38 +00:00
|
|
|
import {
|
|
|
|
isNarrowAspectRatio,
|
|
|
|
makeAspectRatioAware
|
|
|
|
} from '../../base/aspect-ratio';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Container } from '../../base/react';
|
|
|
|
|
|
|
|
import Thumbnail from './Thumbnail';
|
|
|
|
import { styles } from './_';
|
|
|
|
|
|
|
|
/**
|
2017-05-24 17:01:46 +00:00
|
|
|
* Implements a React {@link Component} which represents the filmstrip on
|
|
|
|
* mobile/React Native.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2017-10-24 22:26:56 +00:00
|
|
|
class Filmstrip extends Component<*> {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2017-04-10 17:59:44 +00:00
|
|
|
* Filmstrip component's property types.
|
2016-12-01 01:52:39 +00:00
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2017-01-28 03:36:20 +00:00
|
|
|
/**
|
|
|
|
* The participants in the conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Participant[]}
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
_participants: PropTypes.array,
|
2017-03-31 17:54:58 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-10 17:59:44 +00:00
|
|
|
* The indicator which determines whether the filmstrip is visible.
|
2017-03-31 17:54:58 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
_visible: PropTypes.bool.isRequired
|
2017-06-02 02:01:50 +00:00
|
|
|
};
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
2017-05-24 17:01:46 +00:00
|
|
|
* @returns {ReactElement}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
render() {
|
2017-11-07 14:28:08 +00:00
|
|
|
const isNarrowAspectRatio_ = isNarrowAspectRatio(this);
|
2017-10-13 16:13:46 +00:00
|
|
|
const filmstripStyle
|
2017-11-07 14:28:08 +00:00
|
|
|
= isNarrowAspectRatio_
|
|
|
|
? styles.filmstripNarrow
|
|
|
|
: styles.filmstripWide;
|
2017-10-13 16:13:46 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return (
|
|
|
|
<Container
|
2017-10-13 16:13:46 +00:00
|
|
|
style = { filmstripStyle }
|
2017-11-07 14:28:08 +00:00
|
|
|
visible = { this.props._visible }>
|
2016-10-31 17:33:32 +00:00
|
|
|
<ScrollView
|
2017-11-07 14:28:08 +00:00
|
|
|
horizontal = { isNarrowAspectRatio_ }
|
2016-10-31 17:33:32 +00:00
|
|
|
showsHorizontalScrollIndicator = { false }
|
|
|
|
showsVerticalScrollIndicator = { false }>
|
|
|
|
{
|
2017-10-02 23:08:07 +00:00
|
|
|
/* eslint-disable react/jsx-wrap-multilines */
|
|
|
|
|
2017-01-28 03:36:20 +00:00
|
|
|
this._sort(this.props._participants)
|
2016-10-31 17:33:32 +00:00
|
|
|
.map(p =>
|
|
|
|
<Thumbnail
|
|
|
|
key = { p.id }
|
|
|
|
participant = { p } />)
|
2017-10-02 23:08:07 +00:00
|
|
|
|
|
|
|
/* eslint-enable react/jsx-wrap-multilines */
|
2016-10-31 17:33:32 +00:00
|
|
|
}
|
|
|
|
</ScrollView>
|
2016-10-05 14:36:59 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2016-11-04 18:13:26 +00:00
|
|
|
|
|
|
|
/**
|
2017-10-01 06:35:19 +00:00
|
|
|
* Sorts a specific array of {@code Participant}s in display order.
|
2016-11-04 18:13:26 +00:00
|
|
|
*
|
2017-10-01 06:35:19 +00:00
|
|
|
* @param {Participant[]} participants - The array of {@code Participant}s
|
2016-11-04 18:13:26 +00:00
|
|
|
* to sort in display order.
|
|
|
|
* @private
|
|
|
|
* @returns {Participant[]} A new array containing the elements of the
|
2017-10-01 06:35:19 +00:00
|
|
|
* specified {@code participants} array sorted in display order.
|
2016-11-04 18:13:26 +00:00
|
|
|
*/
|
|
|
|
_sort(participants) {
|
|
|
|
// XXX Array.prototype.sort() is not appropriate because (1) it operates
|
|
|
|
// in place and (2) it is not necessarily stable.
|
|
|
|
|
|
|
|
const sortedParticipants = [];
|
|
|
|
|
|
|
|
// Group the remote participants so that the local participant does not
|
|
|
|
// appear in between remote participants. Have the remote participants
|
|
|
|
// from right to left with the newest added/joined to the leftmost side.
|
|
|
|
for (let i = participants.length - 1; i >= 0; --i) {
|
|
|
|
const p = participants[i];
|
|
|
|
|
|
|
|
p.local || sortedParticipants.push(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Have the local participant at the rightmost side.
|
|
|
|
for (let i = participants.length - 1; i >= 0; --i) {
|
|
|
|
const p = participants[i];
|
|
|
|
|
|
|
|
p.local && sortedParticipants.push(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sortedParticipants;
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2017-01-28 23:34:57 +00:00
|
|
|
* @private
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-03-31 17:54:58 +00:00
|
|
|
* _participants: Participant[],
|
2017-02-16 23:02:40 +00:00
|
|
|
* _visible: boolean
|
2017-04-01 05:52:40 +00:00
|
|
|
* }}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state) {
|
2017-10-13 16:13:46 +00:00
|
|
|
const participants = state['features/base/participants'];
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2017-01-28 03:36:20 +00:00
|
|
|
/**
|
|
|
|
* The participants in the conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Participant[]}
|
|
|
|
*/
|
2017-10-13 16:13:46 +00:00
|
|
|
_participants: participants,
|
2017-02-16 23:02:40 +00:00
|
|
|
|
|
|
|
/**
|
2017-11-07 14:28:08 +00:00
|
|
|
* The indicator which determines whether the filmstrip is visible. The
|
|
|
|
* mobile/react-native Filmstrip is visible when there are at least 2
|
|
|
|
* participants in the conference (including the local one).
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-10-13 16:13:46 +00:00
|
|
|
_visible: participants.length > 1
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-11-03 20:14:38 +00:00
|
|
|
export default connect(_mapStateToProps)(makeAspectRatioAware(Filmstrip));
|