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 | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 19 | import React, { useContext } from 'react'; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 20 | import { Trans } from 'react-i18next'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 21 | |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 22 | import { WebRTCContext } from '../contexts/WebRTCProvider'; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 23 | import { ExpandableButton, ExpandableButtonProps, ToggleIconButton, ToggleIconButtonProps } from './Button'; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 24 | import { |
| 25 | CallEndIcon, |
| 26 | ChatBubbleIcon, |
| 27 | ExtensionIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 28 | FileIcon, |
| 29 | FullScreenIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 30 | GroupAddIcon, |
| 31 | MicroIcon, |
| 32 | MicroOffIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 33 | MoreVerticalIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 34 | RecordingIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 35 | ScreenShareArrowIcon, |
| 36 | ScreenShareRegularIcon, |
| 37 | ScreenShareScreenAreaIcon, |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 38 | VideoCameraIcon, |
| 39 | VideoCameraOffIcon, |
| 40 | VolumeIcon, |
| 41 | } from './SvgIcon'; |
| 42 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 43 | export const CallingChatButton = (props: ExpandableButtonProps) => { |
| 44 | return <ExpandableButton aria-label="chat" Icon={ChatBubbleIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 45 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 46 | |
| 47 | export const CallingEndButton = (props: ExpandableButtonProps) => { |
| 48 | return <ExpandableButton aria-label="call end" Icon={CallEndIcon} sx={{ backgroundColor: 'red' }} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 49 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 50 | |
| 51 | export const CallingExtensionButton = (props: ExpandableButtonProps) => { |
| 52 | return <ExpandableButton aria-label="extensions" Icon={ExtensionIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 53 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 54 | |
| 55 | export const CallingFullScreenButton = (props: ExpandableButtonProps) => { |
| 56 | return <ExpandableButton aria-label="full screen" Icon={FullScreenIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 57 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 58 | |
| 59 | export const CallingGroupButton = (props: ExpandableButtonProps) => { |
| 60 | return <ExpandableButton aria-label="group options" Icon={GroupAddIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 61 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 62 | |
| 63 | export const CallingMoreVerticalButton = (props: ExpandableButtonProps) => { |
| 64 | return <ExpandableButton aria-label="more vertical" Icon={MoreVerticalIcon} {...props} />; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 65 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 66 | |
| 67 | export const CallingRecordButton = (props: ExpandableButtonProps) => { |
| 68 | return <ExpandableButton aria-label="recording options" Icon={RecordingIcon} {...props} />; |
| 69 | }; |
| 70 | |
| 71 | export const CallingScreenShareButton = (props: ExpandableButtonProps) => { |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 72 | return ( |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 73 | <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 | /> |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 92 | ); |
| 93 | }; |
| 94 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 95 | export 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 | }; |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 114 | export const CallingMicButton = (props: Partial<ToggleIconButtonProps>) => { |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 115 | const { isAudioOn, setAudioStatus } = useContext(WebRTCContext); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 116 | |
| 117 | return ( |
| 118 | <ToggleIconButton |
| 119 | aria-label="microphone options" |
| 120 | sx={{ color: 'white' }} |
| 121 | IconOn={MicroIcon} |
| 122 | IconOff={MicroOffIcon} |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 123 | selected={isAudioOn} |
| 124 | toggle={() => setAudioStatus(!isAudioOn)} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 125 | {...props} |
| 126 | /> |
| 127 | ); |
| 128 | }; |
| 129 | |
| 130 | export const CallingVideoCameraButton = (props: Partial<ToggleIconButtonProps>) => { |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 131 | const { isVideoOn, setVideoStatus } = useContext(WebRTCContext); |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 132 | |
| 133 | return ( |
| 134 | <ToggleIconButton |
| 135 | aria-label="camera options" |
| 136 | sx={{ color: 'white' }} |
| 137 | IconOn={VideoCameraIcon} |
| 138 | IconOff={VideoCameraOffIcon} |
simon | ce2c0c4 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 139 | selected={isVideoOn} |
| 140 | toggle={() => setVideoStatus(!isVideoOn)} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 141 | {...props} |
| 142 | /> |
| 143 | ); |
| 144 | }; |