blob: 79d5485189aba0ed62cff02e32cdf2216c4d6e5e [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,
simon2d3b6532022-11-08 21:01:57 -050035 PlaceAudioCallIcon,
simon1170c322022-10-31 14:51:31 -040036 RecordingIcon,
simon2d3b6532022-11-08 21:01:57 -050037 RoundCloseIcon,
simon33c06182022-11-02 17:39:31 -040038 ScreenShareArrowIcon,
39 ScreenShareRegularIcon,
40 ScreenShareScreenAreaIcon,
simon1170c322022-10-31 14:51:31 -040041 VideoCameraIcon,
42 VideoCameraOffIcon,
43 VolumeIcon,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050044 WindowIcon,
simon1170c322022-10-31 14:51:31 -040045} from './SvgIcon';
46
simon2d3b6532022-11-08 21:01:57 -050047type ColoredCallButtonColor = 'red' | 'green';
48
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050049const CallButton = styled((props: ExpandableButtonProps) => {
50 return <ExpandableButton {...props} />;
51})({
simon2d3b6532022-11-08 21:01:57 -050052 color: 'white',
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050053 '&:hover': {
54 backgroundColor: 'rgba(255, 255, 255, 0.15)',
55 },
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050056});
57
simon2d3b6532022-11-08 21:01:57 -050058const ColoredCallButton = styled(
59 ({
60 ...props
61 }: ExpandableButtonProps & {
62 buttonColor: ColoredCallButtonColor;
63 }) => {
64 return <ExpandableButton {...props} />;
65 }
66)(({ buttonColor }) => {
67 return {
68 color: 'white',
69 backgroundColor: buttonColor === 'green' ? '#183722' : '#5E070D',
70 '&:hover': {
71 backgroundColor: buttonColor === 'green' ? '#0B8271' : '#CC0022',
72 },
73 };
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050074});
75
simon33c06182022-11-02 17:39:31 -040076export const CallingChatButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050077 return <CallButton aria-label="chat" Icon={ChatBubbleIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040078};
simon33c06182022-11-02 17:39:31 -040079
80export const CallingEndButton = (props: ExpandableButtonProps) => {
simon2d3b6532022-11-08 21:01:57 -050081 return <ColoredCallButton buttonColor="red" aria-label="call end" Icon={CallEndIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040082};
simon33c06182022-11-02 17:39:31 -040083
84export const CallingExtensionButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050085 return <CallButton aria-label="extensions" Icon={ExtensionIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040086};
simon33c06182022-11-02 17:39:31 -040087
88export const CallingFullScreenButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050089 return <CallButton aria-label="full screen" Icon={FullScreenIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040090};
simon33c06182022-11-02 17:39:31 -040091
92export const CallingGroupButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050093 return <CallButton aria-label="group options" Icon={GroupAddIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040094};
simon33c06182022-11-02 17:39:31 -040095
96export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -050097 return <CallButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040098};
simon33c06182022-11-02 17:39:31 -040099
100export const CallingRecordButton = (props: ExpandableButtonProps) => {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500101 return <CallButton aria-label="recording options" Icon={RecordingIcon} {...props} />;
simon33c06182022-11-02 17:39:31 -0400102};
103
104export const CallingScreenShareButton = (props: ExpandableButtonProps) => {
simon1170c322022-10-31 14:51:31 -0400105 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500106 <CallButton
simon33c06182022-11-02 17:39:31 -0400107 aria-label="screen share"
108 Icon={ScreenShareArrowIcon}
109 expandMenuOptions={[
110 {
111 description: <Trans i18nKey="share_screen" />,
112 icon: <ScreenShareRegularIcon />,
113 },
114 {
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500115 description: <Trans i18nKey="share_window" />,
116 icon: <WindowIcon />,
117 },
118 {
simon33c06182022-11-02 17:39:31 -0400119 description: <Trans i18nKey="share_screen_area" />,
120 icon: <ScreenShareScreenAreaIcon />,
121 },
122 {
123 description: <Trans i18nKey="share_file" />,
124 icon: <FileIcon />,
125 },
126 ]}
127 {...props}
128 />
simon1170c322022-10-31 14:51:31 -0400129 );
130};
131
simon33c06182022-11-02 17:39:31 -0400132export const CallingVolumeButton = (props: ExpandableButtonProps) => {
133 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500134 <CallButton
simon33c06182022-11-02 17:39:31 -0400135 aria-label="volume options"
136 Icon={VolumeIcon}
137 expandMenuOptions={[
138 {
139 options: [
140 {
141 key: '0',
142 description: <Trans i18nKey="dummy_option_string" />,
143 },
144 ],
145 },
146 ]}
147 {...props}
148 />
149 );
150};
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500151
152export const CallingMicButton = (props: ExpandableButtonProps) => {
simonce2c0c42022-11-02 17:39:31 -0400153 const { isAudioOn, setAudioStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400154
155 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500156 <CallButton
simon1170c322022-10-31 14:51:31 -0400157 aria-label="microphone options"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500158 IconButtonComp={(props) => (
159 <ToggleIconButton
160 IconOn={MicroIcon}
161 IconOff={MicroOffIcon}
162 selected={isAudioOn}
163 toggle={() => setAudioStatus(!isAudioOn)}
164 {...props}
165 />
166 )}
simon1170c322022-10-31 14:51:31 -0400167 {...props}
168 />
169 );
170};
171
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500172export const CallingVideoCameraButton = (props: ExpandableButtonProps) => {
simonce2c0c42022-11-02 17:39:31 -0400173 const { isVideoOn, setVideoStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400174 return (
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500175 <CallButton
simon1170c322022-10-31 14:51:31 -0400176 aria-label="camera options"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500177 IconButtonComp={(props) => (
178 <ToggleIconButton
179 IconOn={VideoCameraIcon}
180 IconOff={VideoCameraOffIcon}
181 selected={isVideoOn}
182 toggle={() => setVideoStatus(!isVideoOn)}
183 {...props}
184 />
185 )}
simon1170c322022-10-31 14:51:31 -0400186 {...props}
187 />
188 );
189};
simon2d3b6532022-11-08 21:01:57 -0500190
191// Calling pending/receiving interface
192export const CallingAnswerAudioButton = (props: ExpandableButtonProps) => {
193 return <ColoredCallButton aria-label="answer audio" buttonColor="green" Icon={PlaceAudioCallIcon} {...props} />;
194};
195
196export const CallingAnswerVideoButton = (props: ExpandableButtonProps) => {
197 return <ColoredCallButton aria-label="answer video" buttonColor="green" Icon={VideoCameraIcon} {...props} />;
198};
199
200export const CallingRefuseButton = (props: ExpandableButtonProps) => {
201 return <ColoredCallButton aria-label="reject" buttonColor="red" Icon={RoundCloseIcon} {...props} />;
202};