@100mslive/react-native-room-kit
Version:
100ms Room Kit provides simple & easy to use UI components to build Live Streaming & Video Conferencing experiences in your apps.
43 lines • 1.53 kB
JavaScript
import * as React from 'react';
import { useSelector } from 'react-redux';
import { RotateCameraIcon } from '../Icons';
import { useCanPublishVideo, useHMSActions } from '../hooks-sdk';
import { PressableIcon } from './PressableIcon';
import { useHMSRoomStyle } from '../hooks-util';
import { TestIds } from '../utils/constants';
export const HMSManageCameraRotation = ({
style
}) => {
const canPublishVideo = useCanPublishVideo();
if (!canPublishVideo) {
return null;
}
return /*#__PURE__*/React.createElement(RotateCameraButton, {
style: style
});
};
const RotateCameraButton = ({
style
}) => {
const hmsActions = useHMSActions();
// TODO: set initial `isLocalVideoMuted` state value as per initial track setting
const isLocalVideoMuted = useSelector(state => state.hmsStates.isLocalVideoMuted);
const handleVideoMuteTogglePress = async () => {
if (isLocalVideoMuted) {
return;
}
await hmsActions.switchCamera();
};
const cameraIconStyles = useHMSRoomStyle(theme => ({
tintColor: isLocalVideoMuted ? theme.palette.on_surface_low : theme.palette.on_surface_high
}), [isLocalVideoMuted]);
return /*#__PURE__*/React.createElement(PressableIcon, {
testID: isLocalVideoMuted ? TestIds.switch_camera_disabled : TestIds.switch_camera,
onPress: handleVideoMuteTogglePress,
disabled: isLocalVideoMuted,
style: style
}, /*#__PURE__*/React.createElement(RotateCameraIcon, {
style: cameraIconStyles
}));
};
//# sourceMappingURL=HMSManageCameraRotation.js.map