All files / src/app/student-page/page/assignments/take-assignment/components QuestionSettings.jsx

0% Statements 0/22
0% Branches 0/10
0% Functions 0/11
0% Lines 0/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183                                                                                                                                                                                                                                                                                                                                                                             
import React, { useState } from "react";
import Menu from "@mui/material/Menu";
import SettingsIcon from "@mui/icons-material/Settings";
import { Button, Collapse, List, ListItem, ListItemButton, ListItemText, Typography } from "@mui/material";
import ExpandLess from "@mui/icons-material/ExpandLess";
import ExpandMore from "@mui/icons-material/ExpandMore";
import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";
import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
import { useDispatch, useSelector } from "react-redux";
import ThemeSettings from "./ThemeSettings";
import VoiceSpeed from "./VoiceSpeed";
import VoiceVolume from "./VoiceVolume";
 
// store actions
import {
    _updateLayout,
    _updateShowMyAnswers,
    _increaseTextSize,
    _decreaseTextSize,
} from "@/store/slices/student/StudentQuestionPage";
 
const QuestionSettings = () => {
    const dispatch = useDispatch();
 
    const { myAnswers, settings } = useSelector((state) => state.StudentQuestionPage);
    const [anchorEl, setAnchorEl] = useState(null);
    const [openLayout, setOpenLayout] = useState(false);
    const [openTheme, setOpenTheme] = useState(false);
    const [openVoice, setOpenVoice] = useState(false);
 
    const handleClick = (event) => {
        setAnchorEl(event.currentTarget);
    };
 
    const handleClose = () => {
        setAnchorEl(null);
    };
 
    const handleZoomIn = () => {
        dispatch(_increaseTextSize());
    };
 
    const handleZoomOut = () => {
        dispatch(_decreaseTextSize());
    };
 
    return (
        <React.Fragment>
            <Button color="primary" onClick={handleClick} variant="outlined" size="small" endIcon={<SettingsIcon />}>
                Settings
            </Button>
            <Menu anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={handleClose}>
                <List dense sx={{ width: 250 }}>
                    <ListItem
                        secondaryAction={
                            <Button
                                size="small"
                                variant="text"
                                edge="end"
                                onClick={() => {
                                    dispatch(_updateShowMyAnswers());
                                }}
                            >
                                {myAnswers.isShow ? "Hide" : "Show"}
                            </Button>
                        }
                    >
                        <ListItemText primary="My Answers" />
                    </ListItem>
                    {/* <ListItem
                        secondaryAction={
                            <React.Fragment>
                                <Button
                                    size="small"
                                    variant="text"
                                    edge="end"
                                    endIcon={<AddCircleOutlineIcon />}
                                    onClick={handleZoomIn}
                                >
                                    In
                                </Button>
                                <Button
                                    size="small"
                                    variant="text"
                                    edge="end"
                                    endIcon={<RemoveCircleOutlineIcon />}
                                    onClick={handleZoomOut}
                                >
                                    Out
                                </Button>
                            </React.Fragment>
                        }
                    >
                        <ListItemText primary="Zoom" />
                    </ListItem>
                    <ListItemButton
                        onClick={() => {
                            setOpenTheme(!openTheme);
                        }}
                    >
                        <ListItemText primary="Theme" />
                        {openTheme ? <ExpandLess /> : <ExpandMore />}
                    </ListItemButton>
                    <Collapse in={openTheme} timeout="auto" unmountOnExit>
                        <ListItem sx={{ pl: 2 }}>
                            <ThemeSettings />
                        </ListItem>
                    </Collapse> */}
                    <ListItemButton
                        onClick={() => {
                            setOpenLayout(!openLayout);
                        }}
                    >
                        <ListItemText primary="Layout" />
                        {openLayout ? <ExpandLess /> : <ExpandMore />}
                    </ListItemButton>
                    <Collapse in={openLayout} timeout="auto" unmountOnExit>
                        <ListItem
                            sx={{ pl: 4 }}
                            secondaryAction={
                                <Typography color="green" variant="caption">
                                    {settings.layout === "1" && "Active"}
                                </Typography>
                            }
                        >
                            <Button
                                color="primary"
                                variant="text"
                                size="small"
                                sx={{ textAlign: "start" }}
                                onClick={() => {
                                    dispatch(_updateLayout("1"));
                                }}
                            >
                                List
                            </Button>
                        </ListItem>
                        <ListItem
                            sx={{ pl: 4 }}
                            secondaryAction={
                                <Typography color="green" variant="caption">
                                    {settings.layout === "2" && "Active"}
                                </Typography>
                            }
                        >
                            <Button
                                color="primary"
                                variant="text"
                                size="small"
                                onClick={() => {
                                    dispatch(_updateLayout("2"));
                                }}
                            >
                                Paginated
                            </Button>
                        </ListItem>
                    </Collapse>
                    <ListItemButton
                        onClick={() => {
                            setOpenVoice(!openVoice);
                        }}
                    >
                        <ListItemText primary="Voice" />
                        {openVoice ? <ExpandLess /> : <ExpandMore />}
                    </ListItemButton>
                    <Collapse in={openVoice} timeout="auto" unmountOnExit>
                        <ListItem sx={{ pl: 4 }}>
                            <VoiceSpeed />
                        </ListItem>
                    </Collapse>
                    <Collapse in={openVoice} timeout="auto" unmountOnExit>
                        <ListItem sx={{ pl: 4 }}>
                            <VoiceVolume />
                        </ListItem>
                    </Collapse>
                </List>
            </Menu>
        </React.Fragment>
    );
};
 
export default QuestionSettings;