2018-02-12 17:42:38 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
import { getParticipantCountWithFake } from '../base/participants';
|
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
import { SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
|
2021-08-20 23:32:38 +00:00
|
|
|
import { SQUARE_TILE_ASPECT_RATIO, TILE_MARGIN } from './constants';
|
|
|
|
import { getColumnCount } from './functions.native';
|
2017-05-23 18:58:07 +00:00
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
export * from './actions.any';
|
2020-07-15 20:30:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the dimensions of the tile view grid. The action is only partially implemented on native as not all
|
|
|
|
* of the values are currently used. Check the description of {@link SET_TILE_VIEW_DIMENSIONS} for the full set
|
|
|
|
* of properties.
|
|
|
|
*
|
2021-08-20 23:32:38 +00:00
|
|
|
* @returns {Function}
|
2020-07-15 20:30:44 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
export function setTileViewDimensions() {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const participantCount = getParticipantCountWithFake(state);
|
|
|
|
const { clientHeight: height, clientWidth: width } = state['features/base/responsive-ui'];
|
|
|
|
const columns = getColumnCount(state);
|
|
|
|
const heightToUse = height - (TILE_MARGIN * 2);
|
|
|
|
const widthToUse = width - (TILE_MARGIN * 2);
|
|
|
|
let tileWidth;
|
|
|
|
|
|
|
|
// If there is going to be at least two rows, ensure that at least two
|
|
|
|
// rows display fully on screen.
|
|
|
|
if (participantCount / columns > 1) {
|
|
|
|
tileWidth = Math.min(widthToUse / columns, heightToUse / 2);
|
|
|
|
} else {
|
|
|
|
tileWidth = Math.min(widthToUse / columns, heightToUse);
|
2020-07-15 20:30:44 +00:00
|
|
|
}
|
2021-08-20 23:32:38 +00:00
|
|
|
|
|
|
|
const tileHeight = Math.floor(tileWidth / SQUARE_TILE_ASPECT_RATIO);
|
|
|
|
|
|
|
|
tileWidth = Math.floor(tileWidth);
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_TILE_VIEW_DIMENSIONS,
|
|
|
|
dimensions: {
|
|
|
|
columns,
|
|
|
|
thumbnailSize: {
|
|
|
|
height: tileHeight,
|
|
|
|
width: tileWidth
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-07-15 20:30:44 +00:00
|
|
|
};
|
|
|
|
}
|