import React, { useCallback } from 'react'; import { selectIsLocalScreenShared, selectIsLocalVideoEnabled, useHMSActions, useHMSStore } from '@100mslive/react-sdk'; import { GalleryIcon, PersonRectangleIcon, SidebarIcon } from '@100mslive/react-icons'; import { Box, Flex, Slider, Text } from '../../..'; import SwitchWithLabel from './SwitchWithLabel'; // @ts-ignore: No implicit Any import { useSetUiSettings } from '../AppData/useUISettings'; import { settingOverflow } from './common'; import { UI_SETTINGS } from '../../common/constants'; export const LayoutMode = { SIDEBAR: 'Sidebar', GALLERY: 'Gallery', SPOTLIGHT: 'Spotlight', }; export type LayoutModeKeys = keyof typeof LayoutMode; export const LayoutModeIconMapping = { [LayoutMode.GALLERY]: , [LayoutMode.SIDEBAR]: , [LayoutMode.SPOTLIGHT]: , }; export const LayoutSettings = () => { const hmsActions = useHMSActions(); const isLocalVideoEnabled = useHMSStore(selectIsLocalVideoEnabled); const isLocalScreenShared = useHMSStore(selectIsLocalScreenShared); const [{ isAudioOnly, maxTileCount, mirrorLocalVideo }, setUISettings] = useSetUiSettings(); const toggleIsAudioOnly = useCallback( async (isAudioOnlyModeOn?: boolean) => { if (isAudioOnlyModeOn) { // turn off video and screen share if user switches to audio only mode isLocalVideoEnabled && (await hmsActions.setLocalVideoEnabled(false)); isLocalScreenShared && (await hmsActions.setScreenShareEnabled(false)); } setUISettings({ [UI_SETTINGS.isAudioOnly]: isAudioOnlyModeOn }); }, [hmsActions, isLocalVideoEnabled, isLocalScreenShared, setUISettings], ); return ( Tiles In View({maxTileCount}) { setUISettings({ [UI_SETTINGS.maxTileCount]: e[0] }); }} css={{ w: '70%' }} /> { setUISettings({ [UI_SETTINGS.mirrorLocalVideo]: value, }); }} /> ); };