2021-06-03 02:31:20 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-11-06 00:36:03 +08:00
|
|
|
import Styled from './styles';
|
2021-06-03 02:31:20 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
switchButtonShrink: {
|
|
|
|
id: 'app.switchButton.shrinkLabel',
|
|
|
|
description: 'shrink label',
|
|
|
|
},
|
|
|
|
switchButtonExpand: {
|
|
|
|
id: 'app.switchButton.expandLabel',
|
|
|
|
description: 'expand label',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
2021-11-06 00:36:03 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2021-06-03 02:31:20 +08:00
|
|
|
dark: PropTypes.bool,
|
|
|
|
bottom: PropTypes.bool,
|
|
|
|
handleSwitch: PropTypes.func,
|
|
|
|
switched: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2024-06-11 21:05:08 +08:00
|
|
|
const SwitchButtonComponent = ({
|
|
|
|
intl,
|
|
|
|
dark = false,
|
|
|
|
bottom = false,
|
|
|
|
handleSwitch = () => {},
|
|
|
|
switched = false,
|
|
|
|
}) => {
|
2021-06-03 02:31:20 +08:00
|
|
|
const formattedLabel = intl.formatMessage(switched
|
|
|
|
? intlMessages.switchButtonShrink
|
|
|
|
: intlMessages.switchButtonExpand);
|
|
|
|
|
|
|
|
return (
|
2021-11-06 00:36:03 +08:00
|
|
|
<Styled.SwitchButtonWrapper dark={dark} bottom={bottom}>
|
|
|
|
<Styled.SwitchButton
|
2021-06-03 02:31:20 +08:00
|
|
|
color="default"
|
|
|
|
icon={switched ? 'screenshare-close-fullscreen' : 'screenshare-fullscreen'}
|
|
|
|
size="sm"
|
|
|
|
onClick={handleSwitch}
|
|
|
|
label={formattedLabel}
|
|
|
|
hideLabel
|
|
|
|
data-test="switchButton"
|
|
|
|
/>
|
2021-11-06 00:36:03 +08:00
|
|
|
</Styled.SwitchButtonWrapper>
|
2021-06-03 02:31:20 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
SwitchButtonComponent.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default injectIntl(SwitchButtonComponent);
|