您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.native.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // @flow
  2. import { hasAvailableDevices } from '../base/devices';
  3. import { TOOLBOX_ALWAYS_VISIBLE, getFeatureFlag, TOOLBOX_ENABLED } from '../base/flags';
  4. import { toState } from '../base/redux';
  5. import { isLocalVideoTrackDesktop } from '../base/tracks';
  6. const WIDTH = {
  7. FIT_9_ICONS: 560,
  8. FIT_8_ICONS: 500,
  9. FIT_7_ICONS: 440,
  10. FIT_6_ICONS: 380
  11. };
  12. /**
  13. * Returns a set of the buttons that are shown in the toolbar
  14. * but removed from the overflow menu, based on the width of the screen.
  15. *
  16. * @param {number} width - The width of the screen.
  17. * @returns {Set}
  18. */
  19. export function getMovableButtons(width: number): Set<string> {
  20. let buttons = [];
  21. switch (true) {
  22. case width >= WIDTH.FIT_9_ICONS: {
  23. buttons = [ 'togglecamera', 'chat', 'invite', 'raisehand', 'tileview' ];
  24. break;
  25. }
  26. case width >= WIDTH.FIT_8_ICONS: {
  27. buttons = [ 'chat', 'togglecamera', 'raisehand', 'tileview' ];
  28. break;
  29. }
  30. case width >= WIDTH.FIT_7_ICONS: {
  31. buttons = [ 'chat', 'togglecamera', 'raisehand' ];
  32. break;
  33. }
  34. case width >= WIDTH.FIT_6_ICONS: {
  35. buttons = [ 'chat', 'togglecamera' ];
  36. break;
  37. }
  38. default: {
  39. buttons = [ 'chat' ];
  40. }
  41. }
  42. return new Set(buttons);
  43. }
  44. /**
  45. * Returns true if the toolbox is visible.
  46. *
  47. * @param {Object | Function} stateful - A function or object that can be
  48. * resolved to Redux state by the function {@code toState}.
  49. * @returns {boolean}
  50. */
  51. export function isToolboxVisible(stateful: Object | Function) {
  52. const state = toState(stateful);
  53. const { alwaysVisible, enabled, visible } = state['features/toolbox'];
  54. const { length: participantCount } = state['features/base/participants'];
  55. const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
  56. const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
  57. return enabledFlag && enabled && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
  58. }
  59. /**
  60. * Indicates if the video mute button is disabled or not.
  61. *
  62. * @param {string} state - The state from the Redux store.
  63. * @returns {boolean}
  64. */
  65. export function isVideoMuteButtonDisabled(state: Object) {
  66. return !hasAvailableDevices(state, 'videoInput') || isLocalVideoTrackDesktop(state);
  67. }