blob: 2392c006eed600cc68a33f1b52dbc7cad6eb9d7c [file] [log] [blame]
simon1170c322022-10-31 14:51:31 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
simon33c06182022-11-02 17:39:31 -040018
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050019import { styled } from '@mui/material/styles';
simon1170c322022-10-31 14:51:31 -040020import React, { useContext } from 'react';
simon33c06182022-11-02 17:39:31 -040021import { Trans } from 'react-i18next';
simon1170c322022-10-31 14:51:31 -040022
simonce2c0c42022-11-02 17:39:31 -040023import { WebRTCContext } from '../contexts/WebRTCProvider';
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050024import { ExpandableButton, ExpandableButtonProps, ToggleIconButton } from './Button';
simon1170c322022-10-31 14:51:31 -040025import {
26 CallEndIcon,
27 ChatBubbleIcon,
28 ExtensionIcon,
simon33c06182022-11-02 17:39:31 -040029 FileIcon,
30 FullScreenIcon,
simon1170c322022-10-31 14:51:31 -040031 GroupAddIcon,
32 MicroIcon,
33 MicroOffIcon,
simon33c06182022-11-02 17:39:31 -040034 MoreVerticalIcon,
simon1170c322022-10-31 14:51:31 -040035 RecordingIcon,
simon33c06182022-11-02 17:39:31 -040036 ScreenShareArrowIcon,
37 ScreenShareRegularIcon,
38 ScreenShareScreenAreaIcon,
simon1170c322022-10-31 14:51:31 -040039 VideoCameraIcon,
40 VideoCameraOffIcon,
41 VolumeIcon,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050042 WindowIcon,
simon1170c322022-10-31 14:51:31 -040043} from './SvgIcon';
44
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050045const CallButton = styled((props: ExpandableButtonProps) => {
46 return <ExpandableButton {...props} />;
47})({
48 '&:hover': {
49 backgroundColor: 'rgba(255, 255, 255, 0.15)',
50 },
51 color: 'white',
52});
53
54const ColoredCallButton = styled((props: ExpandableButtonProps) => {
55 return <ExpandableButton {...props} />;
56})({
57 color: 'white',
58 backgroundColor: '#a30000',
59 '&:hover': {
60 backgroundColor: '#ff0000',
61 },
62});
63
simon33c06182022-11-02 17:39:31 -040064export const CallingChatButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050065 return <CallButton aria-label="chat" Icon={ChatBubbleIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040066};
simon33c06182022-11-02 17:39:31 -040067
68export const CallingEndButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050069 return <ColoredCallButton sx={{}} aria-label="call end" Icon={CallEndIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040070};
simon33c06182022-11-02 17:39:31 -040071
72export const CallingExtensionButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050073 return <CallButton aria-label="extensions" Icon={ExtensionIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040074};
simon33c06182022-11-02 17:39:31 -040075
76export const CallingFullScreenButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050077 return <CallButton aria-label="full screen" Icon={FullScreenIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040078};
simon33c06182022-11-02 17:39:31 -040079
80export const CallingGroupButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050081 return <CallButton aria-label="group options" Icon={GroupAddIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040082};
simon33c06182022-11-02 17:39:31 -040083
84export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050085 return <CallButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040086};
simon33c06182022-11-02 17:39:31 -040087
88export const CallingRecordButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050089 return <CallButton aria-label="recording options" Icon={RecordingIcon} {...props} />;
simon33c06182022-11-02 17:39:31 -040090};
91
92export const CallingScreenShareButton = (props: ExpandableButtonProps) => {
simon1170c322022-10-31 14:51:31 -040093 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050094 <CallButton
simon33c06182022-11-02 17:39:31 -040095 aria-label="screen share"
96 Icon={ScreenShareArrowIcon}
97 expandMenuOptions={[
98 {
99 description: <Trans i18nKey="share_screen" />,
100 icon: <ScreenShareRegularIcon />,
101 },
102 {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500103 description: <Trans i18nKey="share_window" />,
104 icon: <WindowIcon />,
105 },
106 {
simon33c06182022-11-02 17:39:31 -0400107 description: <Trans i18nKey="share_screen_area" />,
108 icon: <ScreenShareScreenAreaIcon />,
109 },
110 {
111 description: <Trans i18nKey="share_file" />,
112 icon: <FileIcon />,
113 },
114 ]}
115 {...props}
116 />
simon1170c322022-10-31 14:51:31 -0400117 );
118};
119
simon33c06182022-11-02 17:39:31 -0400120export const CallingVolumeButton = (props: ExpandableButtonProps) => {
121 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500122 <CallButton
simon33c06182022-11-02 17:39:31 -0400123 aria-label="volume options"
124 Icon={VolumeIcon}
125 expandMenuOptions={[
126 {
127 options: [
128 {
129 key: '0',
130 description: <Trans i18nKey="dummy_option_string" />,
131 },
132 ],
133 },
134 ]}
135 {...props}
136 />
137 );
138};
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500139
140export const CallingMicButton = (props: ExpandableButtonProps) => {
simonce2c0c42022-11-02 17:39:31 -0400141 const { isAudioOn, setAudioStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400142
143 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500144 <CallButton
simon1170c322022-10-31 14:51:31 -0400145 aria-label="microphone options"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500146 IconButtonComp={(props) => (
147 <ToggleIconButton
148 IconOn={MicroIcon}
149 IconOff={MicroOffIcon}
150 selected={isAudioOn}
151 toggle={() => setAudioStatus(!isAudioOn)}
152 {...props}
153 />
154 )}
simon1170c322022-10-31 14:51:31 -0400155 {...props}
156 />
157 );
158};
159
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500160export const CallingVideoCameraButton = (props: ExpandableButtonProps) => {
simonce2c0c42022-11-02 17:39:31 -0400161 const { isVideoOn, setVideoStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400162
163 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500164 <CallButton
simon1170c322022-10-31 14:51:31 -0400165 aria-label="camera options"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500166 IconButtonComp={(props) => (
167 <ToggleIconButton
168 IconOn={VideoCameraIcon}
169 IconOff={VideoCameraOffIcon}
170 selected={isVideoOn}
171 toggle={() => setVideoStatus(!isVideoOn)}
172 {...props}
173 />
174 )}
simon1170c322022-10-31 14:51:31 -0400175 {...props}
176 />
177 );
178};