You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OpenCarmodeButton.tsx 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* eslint-disable lines-around-comment */
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import { CAR_MODE_ENABLED } from '../../../base/flags/constants';
  5. import { getFeatureFlag } from '../../../base/flags/functions';
  6. import { translate } from '../../../base/i18n/functions';
  7. import { IconCar } from '../../../base/icons/svg';
  8. // @ts-ignore
  9. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  10. import { navigate }
  11. // @ts-ignore
  12. from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  13. // @ts-ignore
  14. import { screen } from '../../../mobile/navigation/routes';
  15. /* eslint-enable lines-around-comment */
  16. /**
  17. * Implements an {@link AbstractButton} to open the carmode.
  18. */
  19. class OpenCarmodeButton extends AbstractButton<AbstractButtonProps, any, any> {
  20. accessibilityLabel = 'toolbar.accessibilityLabel.carmode';
  21. icon = IconCar;
  22. label = 'carmode.labels.buttonLabel';
  23. /**
  24. * Handles clicking / pressing the button, and opens the carmode mode.
  25. *
  26. * @private
  27. * @returns {void}
  28. */
  29. _handleClick() {
  30. return navigate(screen.conference.carmode);
  31. }
  32. }
  33. /**
  34. * Maps part of the Redux state to the props of this component.
  35. *
  36. * @param {IReduxState} state - The Redux state.
  37. * @param {AbstractButtonProps} ownProps - The properties explicitly passed to the component instance.
  38. * @private
  39. * @returns {Object}
  40. */
  41. function _mapStateToProps(state: IReduxState, ownProps: AbstractButtonProps): Object {
  42. const enabled = getFeatureFlag(state, CAR_MODE_ENABLED, true);
  43. const { visible = enabled } = ownProps;
  44. return {
  45. visible
  46. };
  47. }
  48. // @ts-ignore
  49. export default translate(connect(_mapStateToProps)(OpenCarmodeButton));