blob: 8c1660de2d93bfb976a711921fd62d4158eb3eb0 [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
simon1170c322022-10-31 14:51:31 -040019import React, { useContext } from 'react';
simon33c06182022-11-02 17:39:31 -040020import { Trans } from 'react-i18next';
simon1170c322022-10-31 14:51:31 -040021
simonce2c0c42022-11-02 17:39:31 -040022import { WebRTCContext } from '../contexts/WebRTCProvider';
simon33c06182022-11-02 17:39:31 -040023import { ExpandableButton, ExpandableButtonProps, ToggleIconButton, ToggleIconButtonProps } from './Button';
simon1170c322022-10-31 14:51:31 -040024import {
25 CallEndIcon,
26 ChatBubbleIcon,
27 ExtensionIcon,
simon33c06182022-11-02 17:39:31 -040028 FileIcon,
29 FullScreenIcon,
simon1170c322022-10-31 14:51:31 -040030 GroupAddIcon,
31 MicroIcon,
32 MicroOffIcon,
simon33c06182022-11-02 17:39:31 -040033 MoreVerticalIcon,
simon1170c322022-10-31 14:51:31 -040034 RecordingIcon,
simon33c06182022-11-02 17:39:31 -040035 ScreenShareArrowIcon,
36 ScreenShareRegularIcon,
37 ScreenShareScreenAreaIcon,
simon1170c322022-10-31 14:51:31 -040038 VideoCameraIcon,
39 VideoCameraOffIcon,
40 VolumeIcon,
41} from './SvgIcon';
42
simon33c06182022-11-02 17:39:31 -040043export const CallingChatButton = (props: ExpandableButtonProps) => {
44 return <ExpandableButton aria-label="chat" Icon={ChatBubbleIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040045};
simon33c06182022-11-02 17:39:31 -040046
47export const CallingEndButton = (props: ExpandableButtonProps) => {
48 return <ExpandableButton aria-label="call end" Icon={CallEndIcon} sx={{ backgroundColor: 'red' }} {...props} />;
simon1170c322022-10-31 14:51:31 -040049};
simon33c06182022-11-02 17:39:31 -040050
51export const CallingExtensionButton = (props: ExpandableButtonProps) => {
52 return <ExpandableButton aria-label="extensions" Icon={ExtensionIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040053};
simon33c06182022-11-02 17:39:31 -040054
55export const CallingFullScreenButton = (props: ExpandableButtonProps) => {
56 return <ExpandableButton aria-label="full screen" Icon={FullScreenIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040057};
simon33c06182022-11-02 17:39:31 -040058
59export const CallingGroupButton = (props: ExpandableButtonProps) => {
60 return <ExpandableButton aria-label="group options" Icon={GroupAddIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040061};
simon33c06182022-11-02 17:39:31 -040062
63export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => {
64 return <ExpandableButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />;
simon1170c322022-10-31 14:51:31 -040065};
simon33c06182022-11-02 17:39:31 -040066
67export const CallingRecordButton = (props: ExpandableButtonProps) => {
68 return <ExpandableButton aria-label="recording options" Icon={RecordingIcon} {...props} />;
69};
70
71export const CallingScreenShareButton = (props: ExpandableButtonProps) => {
simon1170c322022-10-31 14:51:31 -040072 return (
simon33c06182022-11-02 17:39:31 -040073 <ExpandableButton
74 aria-label="screen share"
75 Icon={ScreenShareArrowIcon}
76 expandMenuOptions={[
77 {
78 description: <Trans i18nKey="share_screen" />,
79 icon: <ScreenShareRegularIcon />,
80 },
81 {
82 description: <Trans i18nKey="share_screen_area" />,
83 icon: <ScreenShareScreenAreaIcon />,
84 },
85 {
86 description: <Trans i18nKey="share_file" />,
87 icon: <FileIcon />,
88 },
89 ]}
90 {...props}
91 />
simon1170c322022-10-31 14:51:31 -040092 );
93};
94
simon33c06182022-11-02 17:39:31 -040095export const CallingVolumeButton = (props: ExpandableButtonProps) => {
96 return (
97 <ExpandableButton
98 aria-label="volume options"
99 Icon={VolumeIcon}
100 expandMenuOptions={[
101 {
102 options: [
103 {
104 key: '0',
105 description: <Trans i18nKey="dummy_option_string" />,
106 },
107 ],
108 },
109 ]}
110 {...props}
111 />
112 );
113};
simon1170c322022-10-31 14:51:31 -0400114export const CallingMicButton = (props: Partial<ToggleIconButtonProps>) => {
simonce2c0c42022-11-02 17:39:31 -0400115 const { isAudioOn, setAudioStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400116
117 return (
118 <ToggleIconButton
119 aria-label="microphone options"
120 sx={{ color: 'white' }}
121 IconOn={MicroIcon}
122 IconOff={MicroOffIcon}
simonce2c0c42022-11-02 17:39:31 -0400123 selected={isAudioOn}
124 toggle={() => setAudioStatus(!isAudioOn)}
simon1170c322022-10-31 14:51:31 -0400125 {...props}
126 />
127 );
128};
129
130export const CallingVideoCameraButton = (props: Partial<ToggleIconButtonProps>) => {
simonce2c0c42022-11-02 17:39:31 -0400131 const { isVideoOn, setVideoStatus } = useContext(WebRTCContext);
simon1170c322022-10-31 14:51:31 -0400132
133 return (
134 <ToggleIconButton
135 aria-label="camera options"
136 sx={{ color: 'white' }}
137 IconOn={VideoCameraIcon}
138 IconOff={VideoCameraOffIcon}
simonce2c0c42022-11-02 17:39:31 -0400139 selected={isVideoOn}
140 toggle={() => setVideoStatus(!isVideoOn)}
simon1170c322022-10-31 14:51:31 -0400141 {...props}
142 />
143 );
144};