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 | */ |
| 18 | import { IconButton, IconButtonProps } from '@mui/material'; |
| 19 | import { styled } from '@mui/material/styles'; |
| 20 | import React, { useContext } from 'react'; |
| 21 | |
| 22 | import { CallContext } from '../contexts/CallProvider'; |
| 23 | import { ToggleIconButton, ToggleIconButtonProps } from './Button'; |
| 24 | import { |
| 25 | CallEndIcon, |
| 26 | ChatBubbleIcon, |
| 27 | ExtensionIcon, |
| 28 | FullscreenIcon, |
| 29 | GroupAddIcon, |
| 30 | MicroIcon, |
| 31 | MicroOffIcon, |
| 32 | RecordingIcon, |
| 33 | ScreenShareIcon, |
| 34 | VideoCameraIcon, |
| 35 | VideoCameraOffIcon, |
| 36 | VolumeIcon, |
| 37 | } from './SvgIcon'; |
| 38 | |
| 39 | export const CallingChatButton = (props: IconButtonProps) => { |
| 40 | return ( |
| 41 | <IconButton {...props} aria-label="chat" sx={{ color: 'white' }}> |
| 42 | <ChatBubbleIcon /> |
| 43 | </IconButton> |
| 44 | ); |
| 45 | }; |
| 46 | export const CallingEndButton = styled((props: IconButtonProps) => { |
| 47 | return ( |
| 48 | <IconButton {...props} aria-label="end call"> |
| 49 | <CallEndIcon /> |
| 50 | </IconButton> |
| 51 | ); |
| 52 | })(() => ({ |
| 53 | color: 'white', |
| 54 | backgroundColor: 'red', |
| 55 | '&:hover': { |
| 56 | backgroundColor: 'darkred', |
| 57 | }, |
| 58 | })); |
| 59 | export const CallingExtensionButton = (props: IconButtonProps) => { |
| 60 | return ( |
| 61 | <IconButton {...props} aria-label="extensions" sx={{ color: 'white' }}> |
| 62 | <ExtensionIcon /> |
| 63 | </IconButton> |
| 64 | ); |
| 65 | }; |
| 66 | export const CallingFullscreenButton = (props: IconButtonProps) => { |
| 67 | return ( |
| 68 | <IconButton {...props} aria-label="fullscreen" sx={{ color: 'white' }}> |
| 69 | <FullscreenIcon /> |
| 70 | </IconButton> |
| 71 | ); |
| 72 | }; |
| 73 | export const CallingGroupButton = (props: IconButtonProps) => { |
| 74 | return ( |
| 75 | <IconButton {...props} aria-label="group options" sx={{ color: 'white' }}> |
| 76 | <GroupAddIcon /> |
| 77 | </IconButton> |
| 78 | ); |
| 79 | }; |
| 80 | export const CallingRecordButton = (props: IconButtonProps) => { |
| 81 | return ( |
| 82 | <IconButton {...props} aria-label="recording options" sx={{ color: 'white' }}> |
| 83 | <RecordingIcon /> |
| 84 | </IconButton> |
| 85 | ); |
| 86 | }; |
| 87 | export const CallingScreenShareButton = (props: IconButtonProps) => { |
| 88 | return ( |
| 89 | <IconButton {...props} aria-label="screen share" sx={{ color: 'white' }}> |
| 90 | <ScreenShareIcon /> |
| 91 | </IconButton> |
| 92 | ); |
| 93 | }; |
| 94 | export const CallingVolumeButton = (props: IconButtonProps) => { |
| 95 | return ( |
| 96 | <IconButton {...props} aria-label="volume options" sx={{ color: 'white' }}> |
| 97 | <VolumeIcon /> |
| 98 | </IconButton> |
| 99 | ); |
| 100 | }; |
| 101 | |
| 102 | export const CallingMicButton = (props: Partial<ToggleIconButtonProps>) => { |
| 103 | const { micOn, setMicOn } = useContext(CallContext); |
| 104 | |
| 105 | return ( |
| 106 | <ToggleIconButton |
| 107 | aria-label="microphone options" |
| 108 | sx={{ color: 'white' }} |
| 109 | IconOn={MicroIcon} |
| 110 | IconOff={MicroOffIcon} |
| 111 | selected={micOn} |
| 112 | toggle={() => setMicOn((s) => !s)} |
| 113 | {...props} |
| 114 | /> |
| 115 | ); |
| 116 | }; |
| 117 | |
| 118 | export const CallingVideoCameraButton = (props: Partial<ToggleIconButtonProps>) => { |
| 119 | const { camOn, setCamOn } = useContext(CallContext); |
| 120 | |
| 121 | return ( |
| 122 | <ToggleIconButton |
| 123 | aria-label="camera options" |
| 124 | sx={{ color: 'white' }} |
| 125 | IconOn={VideoCameraIcon} |
| 126 | IconOff={VideoCameraOffIcon} |
| 127 | selected={camOn} |
| 128 | toggle={() => setCamOn((s) => !s)} |
| 129 | {...props} |
| 130 | /> |
| 131 | ); |
| 132 | }; |