simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 18 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 19 | import { styled } from '@mui/material/styles'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 20 | import React, { useContext } from 'react'; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 21 | import { Trans } from 'react-i18next'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 22 | |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 23 | import { WebRTCContext } from '../contexts/WebRTCProvider'; |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 24 | import { ExpandableButton, ExpandableButtonProps, ToggleIconButton } from './Button'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 25 | import { |
| 26 | CallEndIcon, |
| 27 | ChatBubbleIcon, |
| 28 | ExtensionIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 29 | FileIcon, |
| 30 | FullScreenIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 31 | GroupAddIcon, |
| 32 | MicroIcon, |
| 33 | MicroOffIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 34 | MoreVerticalIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 35 | RecordingIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 36 | ScreenShareArrowIcon, |
| 37 | ScreenShareRegularIcon, |
| 38 | ScreenShareScreenAreaIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 39 | VideoCameraIcon, |
| 40 | VideoCameraOffIcon, |
| 41 | VolumeIcon, |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 42 | WindowIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 43 | } from './SvgIcon'; |
| 44 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 45 | const 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 | |
| 54 | const ColoredCallButton = styled((props: ExpandableButtonProps) => { |
| 55 | return <ExpandableButton {...props} />; |
| 56 | })({ |
| 57 | color: 'white', |
| 58 | backgroundColor: '#a30000', |
| 59 | '&:hover': { |
| 60 | backgroundColor: '#ff0000', |
| 61 | }, |
| 62 | }); |
| 63 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 64 | export const CallingChatButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 65 | return <CallButton aria-label="chat" Icon={ChatBubbleIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 66 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 67 | |
| 68 | export const CallingEndButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 69 | return <ColoredCallButton sx={{}} aria-label="call end" Icon={CallEndIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 70 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 71 | |
| 72 | export const CallingExtensionButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 73 | return <CallButton aria-label="extensions" Icon={ExtensionIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 74 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 75 | |
| 76 | export const CallingFullScreenButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 77 | return <CallButton aria-label="full screen" Icon={FullScreenIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 78 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 79 | |
| 80 | export const CallingGroupButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 81 | return <CallButton aria-label="group options" Icon={GroupAddIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 82 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 83 | |
| 84 | export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 85 | return <CallButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 86 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 87 | |
| 88 | export const CallingRecordButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 89 | return <CallButton aria-label="recording options" Icon={RecordingIcon} {...props} />; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | export const CallingScreenShareButton = (props: ExpandableButtonProps) => { |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 93 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 94 | <CallButton |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 95 | aria-label="screen share" |
| 96 | Icon={ScreenShareArrowIcon} |
| 97 | expandMenuOptions={[ |
| 98 | { |
| 99 | description: <Trans i18nKey="share_screen" />, |
| 100 | icon: <ScreenShareRegularIcon />, |
| 101 | }, |
| 102 | { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 103 | description: <Trans i18nKey="share_window" />, |
| 104 | icon: <WindowIcon />, |
| 105 | }, |
| 106 | { |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 107 | 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 | /> |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 117 | ); |
| 118 | }; |
| 119 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 120 | export const CallingVolumeButton = (props: ExpandableButtonProps) => { |
| 121 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 122 | <CallButton |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 123 | 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 Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 139 | |
| 140 | export const CallingMicButton = (props: ExpandableButtonProps) => { |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 141 | const { isAudioOn, setAudioStatus } = useContext(WebRTCContext); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 142 | |
| 143 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 144 | <CallButton |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 145 | aria-label="microphone options" |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 146 | IconButtonComp={(props) => ( |
| 147 | <ToggleIconButton |
| 148 | IconOn={MicroIcon} |
| 149 | IconOff={MicroOffIcon} |
| 150 | selected={isAudioOn} |
| 151 | toggle={() => setAudioStatus(!isAudioOn)} |
| 152 | {...props} |
| 153 | /> |
| 154 | )} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 155 | {...props} |
| 156 | /> |
| 157 | ); |
| 158 | }; |
| 159 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 160 | export const CallingVideoCameraButton = (props: ExpandableButtonProps) => { |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 161 | const { isVideoOn, setVideoStatus } = useContext(WebRTCContext); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 162 | |
| 163 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 164 | <CallButton |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 165 | aria-label="camera options" |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 166 | IconButtonComp={(props) => ( |
| 167 | <ToggleIconButton |
| 168 | IconOn={VideoCameraIcon} |
| 169 | IconOff={VideoCameraOffIcon} |
| 170 | selected={isVideoOn} |
| 171 | toggle={() => setVideoStatus(!isVideoOn)} |
| 172 | {...props} |
| 173 | /> |
| 174 | )} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 175 | {...props} |
| 176 | /> |
| 177 | ); |
| 178 | }; |