|
| 1 | +/* |
| 2 | +Copyright 2022 New Vector Ltd |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import React, { ChangeEvent, useState } from "react"; |
| 18 | +import { CallFeed } from "matrix-js-sdk/src/webrtc/callFeed"; |
| 19 | + |
| 20 | +import selectInputStyles from "../input/SelectInput.module.css"; |
| 21 | +import { FieldRow } from "../input/Input"; |
| 22 | +import { Modal } from "../Modal"; |
| 23 | +import styles from "./VideoTileSettingsModal.module.css"; |
| 24 | + |
| 25 | +interface LocalVolumeProps { |
| 26 | + feed: CallFeed; |
| 27 | +} |
| 28 | + |
| 29 | +const LocalVolume: React.FC<LocalVolumeProps> = ({ |
| 30 | + feed, |
| 31 | +}: LocalVolumeProps) => { |
| 32 | + const [localVolume, setLocalVolume] = useState<number>(feed.getLocalVolume()); |
| 33 | + |
| 34 | + const onLocalVolumeChanged = (event: ChangeEvent<HTMLInputElement>) => { |
| 35 | + const value: number = +event.target.value; |
| 36 | + setLocalVolume(value); |
| 37 | + feed.setLocalVolume(value); |
| 38 | + }; |
| 39 | + |
| 40 | + return ( |
| 41 | + <> |
| 42 | + <h4 className={selectInputStyles.label}> Local Volume </h4> |
| 43 | + <FieldRow> |
| 44 | + <span className={styles.localVolumePercentage}> |
| 45 | + {`${Math.round(localVolume * 100)}%`} |
| 46 | + </span> |
| 47 | + <input |
| 48 | + className={styles.localVolumeSlider} |
| 49 | + type="range" |
| 50 | + min="0" |
| 51 | + max="1" |
| 52 | + step="0.01" |
| 53 | + value={localVolume} |
| 54 | + onChange={onLocalVolumeChanged} |
| 55 | + /> |
| 56 | + </FieldRow> |
| 57 | + </> |
| 58 | + ); |
| 59 | +}; |
| 60 | + |
| 61 | +// TODO: Extend ModalProps |
| 62 | +interface Props { |
| 63 | + feed: CallFeed; |
| 64 | +} |
| 65 | + |
| 66 | +export const VideoTileSettingsModal = ({ feed, ...rest }: Props) => { |
| 67 | + return ( |
| 68 | + <Modal title="Feed settings" isDismissable mobileFullScreen {...rest}> |
| 69 | + <div className={styles.content}> |
| 70 | + <LocalVolume feed={feed} /> |
| 71 | + </div> |
| 72 | + </Modal> |
| 73 | + ); |
| 74 | +}; |
0 commit comments