/* * Copyright (C) Contributors to the Suwayomi project * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React, { useState } from 'react'; import FilterListIcon from '@mui/icons-material/FilterList'; import { Drawer, FormControlLabel, IconButton, Tabs, Tab, Box, Stack, Checkbox, Radio, Switch, } from '@mui/material'; import useLibraryOptions from 'util/useLibraryOptions'; import ThreeStateCheckbox from 'components/util/ThreeStateCheckbox'; import TabPanel from 'components/util/TabPanel'; import { useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; import SortIcon from '@mui/icons-material/Sort'; function Options() { const { downloaded, setDownloaded, unread, setUnread, } = useLibraryOptions(); const [currentTab, setCurrentTab] = useState(0); const { options, setOptions } = useLibraryOptionsContext(); function setContextOptions( e: React.ChangeEvent, checked: boolean, ) { setOptions((prev) => ({ ...prev, [e.target.name]: checked })); } return ( setCurrentTab(newTab)} indicatorColor="primary" textColor="primary" > )} label="Unread" /> )} label="Downloaded" /> )} /> )} /> ); } function SortOptions() { const { sorts, setSorts, sortDesc, setSortDesc, } = useLibraryOptions(); const handleSortChange = (name: string) => (event: { target: { checked: boolean } }) => { setSorts(event.target.checked ? name : undefined); }; const handleOrderChange = () => (event: { target: { checked: boolean } }) => { setSortDesc(event.target.checked); }; return ( )} label="Asc/Desc" /> )} label="Sort by left to read" /> )} label="Sort alphbetical" /> )} label="Sort by ID" /> ); } export default function LibraryOptions() { const [filtersOpen, setFiltersOpen] = React.useState(false); const [sortsOpen, setSortsOpen] = React.useState(false); const { active } = useLibraryOptions(); return ( <> setFiltersOpen(!filtersOpen)} color={active ? 'warning' : 'default'} > setFiltersOpen(false)} PaperProps={{ style: { maxWidth: 600, padding: '1em', marginLeft: 'auto', marginRight: 'auto', }, }} > setSortsOpen(!filtersOpen)} color={active ? 'warning' : 'default'} > setSortsOpen(false)} PaperProps={{ style: { maxWidth: 600, padding: '1em', marginLeft: 'auto', marginRight: 'auto', }, }} > ); }