import { Checkbox, FormControlLabel, FormGroup } from '@material-ui/core'; import { stringify } from 'postcss'; import React, { useMemo, useState, useEffect, Fragment } from 'react'; import { useHMSTheme } from '../../hooks/HMSThemeProvider'; import { hmsUiClassParserGenerator } from '../../utils/classes'; import { MessageModal } from '../MessageModal'; import { Slider } from '../Slider/Slider'; import { UiSettingsSection } from './UiSettingsSection'; export interface UiSettingsClasses { sliderContainer?: string; slider?: string; divider?: string; notificationContainer?: string; checkBoxLabel?: string; } const defaultClasses = { sliderContainer: 'w-full', slider: 'rounded-lg w-full p-2 flex items-center ', divider: 'bg-gray-600 dark:bg-gray-200 h-px w-full my-4', notificationContainer: 'w-full p-2', checkBoxLabel: 'text-lg space-x-1.5 flex items-center', }; export type uiViewModeTypes = 'activeSpeaker' | 'grid'; export interface UiSettingsProps { classes?: UiSettingsClasses; sliderProps: { onTileCountChange: (value: number) => void; maxTileCount: number; }; notificationProps: { onNotificationChange: (value: { type: string; isSubscribed: boolean; }) => void; subscribedNotifications: { [key: string]: boolean }; }; layoutProps: { onViewModeChange: (value: uiViewModeTypes) => void; uiViewMode: uiViewModeTypes; }; showModal?: boolean; onModalClose?: () => void; } export const UiSettings = ({ classes, sliderProps, notificationProps, layoutProps, showModal, onModalClose = () => {}, }: UiSettingsProps) => { const { tw } = useHMSTheme(); const styler = useMemo( () => hmsUiClassParserGenerator({ tw, classes, defaultClasses, tag: 'hmsui-ui-settings', }), [], ); const [open, setOpen] = useState(false); useEffect(() => { if (showModal === undefined) { return; } setOpen(showModal); }, [showModal]); const handleClose = () => { setOpen(false); onModalClose(); }; const handleSliderChange = (event: any, newValue: number | number[]) => { //TODO make this generic if (typeof newValue === 'number') { sliderProps.onTileCountChange(newValue); } }; const handleNotificationChange = ( event: React.ChangeEvent, type: string, ) => { notificationProps.onNotificationChange({ type, isSubscribed: event.target.checked, }); }; const handleViewModeChange = (value: uiViewModeTypes) => { layoutProps.onViewModeChange(value); }; const label = { inputProps: { 'aria-label': 'Checkbox demo' } }; return (
} /> } /> } /> } /> ); };