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 | |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 19 | import { IconButton, IconButtonProps, PaletteColor } from '@mui/material'; |
| 20 | import { styled, Theme } from '@mui/material/styles'; |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 21 | import { ChangeEvent, useContext, useMemo } from 'react'; |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 22 | import { useTranslation } from 'react-i18next'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 23 | |
Charlie | 9c8779e | 2022-11-29 20:10:56 -0500 | [diff] [blame] | 24 | import { CallContext, CallStatus } from '../contexts/CallProvider'; |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 25 | import { |
| 26 | ExpandableButton, |
| 27 | ExpandableButtonProps, |
| 28 | ExpandMenuRadioOption, |
| 29 | ShapedButtonProps, |
| 30 | ToggleIconButton, |
| 31 | } from './Button'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 32 | import { |
| 33 | CallEndIcon, |
| 34 | ChatBubbleIcon, |
| 35 | ExtensionIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 36 | FileIcon, |
| 37 | FullScreenIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 38 | GroupAddIcon, |
| 39 | MicroIcon, |
| 40 | MicroOffIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 41 | MoreVerticalIcon, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 42 | PlaceAudioCallIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 43 | RecordingIcon, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 44 | RoundCloseIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 45 | ScreenShareArrowIcon, |
| 46 | ScreenShareRegularIcon, |
| 47 | ScreenShareScreenAreaIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 48 | VideoCameraIcon, |
| 49 | VideoCameraOffIcon, |
| 50 | VolumeIcon, |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 51 | WindowIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 52 | } from './SvgIcon'; |
| 53 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 54 | const CallButton = styled((props: ExpandableButtonProps) => { |
| 55 | return <ExpandableButton {...props} />; |
| 56 | })({ |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 57 | color: 'white', |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 58 | '&:hover': { |
| 59 | backgroundColor: 'rgba(255, 255, 255, 0.15)', |
| 60 | }, |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 61 | }); |
| 62 | |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 63 | const ColoredCallButton = styled( |
| 64 | ({ |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 65 | paletteColor, |
| 66 | Icon, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 67 | ...props |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 68 | }: ShapedButtonProps & { |
| 69 | paletteColor?: PaletteColor | ((theme: Theme) => PaletteColor); |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 70 | }) => { |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 71 | return ( |
| 72 | <IconButton {...props} disableRipple={true}> |
| 73 | <Icon fontSize="inherit" /> |
| 74 | </IconButton> |
| 75 | ); |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 76 | } |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 77 | )(({ theme, paletteColor = theme.palette.primary }) => { |
| 78 | if (typeof paletteColor === 'function') { |
| 79 | paletteColor = paletteColor(theme); |
| 80 | } |
| 81 | |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 82 | return { |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 83 | color: paletteColor.contrastText, |
| 84 | backgroundColor: paletteColor.dark, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 85 | '&:hover': { |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 86 | backgroundColor: paletteColor.main, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 87 | }, |
Charlie | 4b90415 | 2022-11-29 21:03:53 -0500 | [diff] [blame] | 88 | '&:disabled': { |
| 89 | backgroundColor: theme.palette.action.disabled, |
| 90 | }, |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 91 | }; |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 92 | }); |
| 93 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 94 | export const CallingChatButton = (props: ExpandableButtonProps) => { |
simon | f9d78f2 | 2022-11-25 15:47:15 -0500 | [diff] [blame] | 95 | const { setIsChatShown } = useContext(CallContext); |
| 96 | return ( |
| 97 | <CallButton |
| 98 | aria-label="chat" |
| 99 | Icon={ChatBubbleIcon} |
| 100 | onClick={() => { |
| 101 | setIsChatShown((v) => !v); |
| 102 | }} |
| 103 | {...props} |
| 104 | /> |
| 105 | ); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 106 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 107 | |
| 108 | export const CallingEndButton = (props: ExpandableButtonProps) => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 109 | const { endCall } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 110 | return ( |
| 111 | <ColoredCallButton |
| 112 | paletteColor={(theme) => theme.palette.error} |
| 113 | onClick={() => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 114 | endCall(); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 115 | }} |
| 116 | aria-label="call end" |
| 117 | Icon={CallEndIcon} |
| 118 | {...props} |
| 119 | /> |
| 120 | ); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 121 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 122 | |
| 123 | export const CallingExtensionButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 124 | return <CallButton aria-label="extensions" Icon={ExtensionIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 125 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 126 | |
| 127 | export const CallingFullScreenButton = (props: ExpandableButtonProps) => { |
simon | 2a5cf14 | 2022-11-25 15:47:35 -0500 | [diff] [blame] | 128 | const { setIsFullscreen } = useContext(CallContext); |
| 129 | return ( |
| 130 | <CallButton |
| 131 | aria-label="full screen" |
| 132 | Icon={FullScreenIcon} |
| 133 | onClick={() => { |
| 134 | setIsFullscreen((v) => !v); |
| 135 | }} |
| 136 | {...props} |
| 137 | /> |
| 138 | ); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 139 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 140 | |
| 141 | export const CallingGroupButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 142 | return <CallButton aria-label="group options" Icon={GroupAddIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 143 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 144 | |
| 145 | export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 146 | return <CallButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 147 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 148 | |
| 149 | export const CallingRecordButton = (props: ExpandableButtonProps) => { |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 150 | return <CallButton aria-label="recording options" Icon={RecordingIcon} {...props} />; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | export const CallingScreenShareButton = (props: ExpandableButtonProps) => { |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 154 | const { t } = useTranslation(); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 155 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 156 | <CallButton |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 157 | aria-label="screen share" |
simon | 571240f | 2022-11-29 23:59:27 -0500 | [diff] [blame] | 158 | expandMenuOnClick |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 159 | Icon={ScreenShareArrowIcon} |
| 160 | expandMenuOptions={[ |
| 161 | { |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 162 | description: t('share_screen'), |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 163 | icon: <ScreenShareRegularIcon />, |
| 164 | }, |
| 165 | { |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 166 | description: t('share_window'), |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 167 | icon: <WindowIcon />, |
| 168 | }, |
| 169 | { |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 170 | description: t('share_screen_area'), |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 171 | icon: <ScreenShareScreenAreaIcon />, |
| 172 | }, |
| 173 | { |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 174 | description: t('share_file'), |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 175 | icon: <FileIcon />, |
| 176 | }, |
| 177 | ]} |
| 178 | {...props} |
| 179 | /> |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 180 | ); |
| 181 | }; |
| 182 | |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 183 | const useMediaDeviceExpandMenuOptions = (kind: MediaDeviceKind): ExpandMenuRadioOption[] | undefined => { |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 184 | const { currentMediaDeviceIds, mediaDevices } = useContext(CallContext); |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 185 | |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 186 | const options = useMemo( |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 187 | () => |
| 188 | mediaDevices[kind].map((device) => ({ |
| 189 | key: device.deviceId, |
| 190 | description: device.label, |
| 191 | })), |
| 192 | [mediaDevices, kind] |
| 193 | ); |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 194 | |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 195 | const currentDevice = currentMediaDeviceIds[kind]; |
| 196 | |
| 197 | if (options.length === 0) { |
| 198 | return undefined; |
| 199 | } |
| 200 | return [ |
| 201 | { |
| 202 | options, |
| 203 | value: currentDevice.id ?? '', |
| 204 | onChange: (e: ChangeEvent<HTMLInputElement>) => { |
| 205 | currentDevice.setId(e.target.value); |
| 206 | }, |
| 207 | }, |
| 208 | ]; |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 209 | }; |
| 210 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 211 | export const CallingVolumeButton = (props: ExpandableButtonProps) => { |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 212 | const options = useMediaDeviceExpandMenuOptions('audiooutput'); |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 213 | |
| 214 | return ( |
| 215 | <CallButton |
| 216 | aria-label="volume options" |
simon | 571240f | 2022-11-29 23:59:27 -0500 | [diff] [blame] | 217 | expandMenuOnClick |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 218 | Icon={VolumeIcon} |
simon | 571240f | 2022-11-29 23:59:27 -0500 | [diff] [blame] | 219 | expandMenuOptions={options} |
simon | 492e840 | 2022-11-29 16:48:37 -0500 | [diff] [blame] | 220 | {...props} |
| 221 | /> |
| 222 | ); |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 223 | }; |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 224 | |
| 225 | export const CallingMicButton = (props: ExpandableButtonProps) => { |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 226 | const options = useMediaDeviceExpandMenuOptions('audioinput'); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 227 | |
| 228 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 229 | <CallButton |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 230 | aria-label="microphone options" |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 231 | expandMenuOptions={options} |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 232 | IconButtonComp={ToggleAudioCameraIconButton} |
| 233 | {...props} |
| 234 | /> |
| 235 | ); |
| 236 | }; |
| 237 | |
| 238 | const ToggleAudioCameraIconButton = (props: IconButtonProps) => { |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 239 | const { isAudioOn, setIsAudioOn } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 240 | return ( |
| 241 | <ToggleIconButton |
| 242 | IconOn={MicroIcon} |
| 243 | IconOff={MicroOffIcon} |
| 244 | selected={isAudioOn} |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 245 | toggle={() => setIsAudioOn((v) => !v)} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 246 | {...props} |
| 247 | /> |
| 248 | ); |
| 249 | }; |
| 250 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 251 | export const CallingVideoCameraButton = (props: ExpandableButtonProps) => { |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 252 | const options = useMediaDeviceExpandMenuOptions('videoinput'); |
| 253 | |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 254 | return ( |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 255 | <CallButton |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 256 | aria-label="camera options" |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 257 | expandMenuOptions={options} |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 258 | IconButtonComp={ToggleVideoCameraIconButton} |
| 259 | {...props} |
| 260 | /> |
| 261 | ); |
| 262 | }; |
| 263 | |
| 264 | const ToggleVideoCameraIconButton = (props: IconButtonProps) => { |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 265 | const { isVideoOn, setIsVideoOn } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 266 | return ( |
| 267 | <ToggleIconButton |
| 268 | IconOn={VideoCameraIcon} |
| 269 | IconOff={VideoCameraOffIcon} |
| 270 | selected={isVideoOn} |
simon | 9076a9a | 2022-11-29 17:13:01 -0500 | [diff] [blame] | 271 | toggle={() => setIsVideoOn((v) => !v)} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 272 | {...props} |
| 273 | /> |
| 274 | ); |
| 275 | }; |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 276 | |
| 277 | // Calling pending/receiving interface |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 278 | export const CallingCancelButton = (props: IconButtonProps) => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 279 | const { endCall } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 280 | |
| 281 | return ( |
| 282 | <ColoredCallButton |
| 283 | aria-label="cancel call" |
| 284 | onClick={() => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 285 | endCall(); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 286 | }} |
| 287 | Icon={CallEndIcon} |
| 288 | paletteColor={(theme) => theme.palette.error} |
| 289 | {...props} |
| 290 | /> |
| 291 | ); |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 292 | }; |
| 293 | |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 294 | export const CallingAnswerAudioButton = (props: IconButtonProps) => { |
Charlie | 9c8779e | 2022-11-29 20:10:56 -0500 | [diff] [blame] | 295 | const { acceptCall, callStatus } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 296 | |
| 297 | return ( |
| 298 | <ColoredCallButton |
Charlie | 9c8779e | 2022-11-29 20:10:56 -0500 | [diff] [blame] | 299 | disabled={callStatus === CallStatus.Loading || callStatus === CallStatus.Connecting} |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 300 | aria-label="answer call audio" |
| 301 | onClick={() => { |
MichelleSS | 5516420 | 2022-11-25 18:36:14 -0500 | [diff] [blame] | 302 | acceptCall(false); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 303 | }} |
| 304 | Icon={PlaceAudioCallIcon} |
| 305 | paletteColor={(theme) => theme.palette.success} |
| 306 | {...props} |
| 307 | /> |
| 308 | ); |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 309 | }; |
| 310 | |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 311 | export const CallingAnswerVideoButton = (props: IconButtonProps) => { |
Charlie | 9c8779e | 2022-11-29 20:10:56 -0500 | [diff] [blame] | 312 | const { acceptCall, callStatus } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 313 | return ( |
| 314 | <ColoredCallButton |
Charlie | 9c8779e | 2022-11-29 20:10:56 -0500 | [diff] [blame] | 315 | disabled={callStatus === CallStatus.Connecting || callStatus === CallStatus.Loading} |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 316 | aria-label="answer call video" |
| 317 | onClick={() => { |
MichelleSS | 5516420 | 2022-11-25 18:36:14 -0500 | [diff] [blame] | 318 | acceptCall(true); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 319 | }} |
| 320 | paletteColor={(theme) => theme.palette.success} |
| 321 | Icon={VideoCameraIcon} |
| 322 | {...props} |
| 323 | /> |
| 324 | ); |
| 325 | }; |
| 326 | |
| 327 | export const CallingRefuseButton = (props: IconButtonProps) => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 328 | const { endCall } = useContext(CallContext); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 329 | return ( |
| 330 | <ColoredCallButton |
| 331 | aria-label="refuse call" |
| 332 | onClick={() => { |
simon | accd802 | 2022-11-24 15:04:53 -0500 | [diff] [blame] | 333 | endCall(); |
simon | f929a36 | 2022-11-18 16:53:45 -0500 | [diff] [blame] | 334 | }} |
| 335 | paletteColor={(theme) => theme.palette.error} |
| 336 | Icon={RoundCloseIcon} |
| 337 | {...props} |
| 338 | /> |
| 339 | ); |
simon | 2d3b653 | 2022-11-08 21:01:57 -0500 | [diff] [blame] | 340 | }; |