From 837e55ae0e945a5a12de29f75511445755fe359a Mon Sep 17 00:00:00 2001 From: robo <30987265+Robonau@users.noreply.github.com> Date: Sat, 5 Mar 2022 21:56:19 +0000 Subject: [PATCH] move sorts to copy tachiyomi is now in a tab along with filter ad display same as tachiyomi --- src/components/library/LibraryOptions.tsx | 217 +++++++++++----------- 1 file changed, 106 insertions(+), 111 deletions(-) diff --git a/src/components/library/LibraryOptions.tsx b/src/components/library/LibraryOptions.tsx index 332f02f2ea..bca0fcce82 100644 --- a/src/components/library/LibraryOptions.tsx +++ b/src/components/library/LibraryOptions.tsx @@ -8,7 +8,6 @@ import React, { useState } from 'react'; import FilterListIcon from '@mui/icons-material/FilterList'; -import SortIcon from '@mui/icons-material/Sort'; import { Drawer, FormControlLabel, @@ -30,11 +29,80 @@ import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; import TabPanel from 'components/util/TabPanel'; import { useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; -function Options() { +function filtersTab(currentTab: number) { const { downloaded, setDownloaded, unread, setUnread, } = useLibraryOptions(); - const [currentTab, setCurrentTab] = useState(0); + return ( + + + + )} + label="Unread" + /> + + )} + label="Downloaded" + /> + + + ); +} + +function sortsTab(currentTab: number) { + const { + sorts, setSorts, sortDesc, setSortDesc, + } = useLibraryOptions(); + + const handleChange = (event: + React.MouseEvent, index: string) => { + if (sorts === index) { + setSortDesc(!sortDesc); + } else { setSortDesc(false); } + setSorts(index); + }; + + return ( + <> + + + { + ['sortToRead', 'sortAlph', 'sortID'].map((e) => { + let icon; + if (sorts === e) { + icon = !sortDesc ? () + : (); + } + icon = icon === undefined && sortDesc === undefined && e === 'sortID' ? () : icon; + return ( + + handleChange(event, e)}> + {icon} + + + + ); + }) + } + + + + ); +} + +function dispalyTab(currentTab: number) { const { options, setOptions } = useLibraryOptionsContext(); function setContextOptions( @@ -43,6 +111,36 @@ function Options() { ) { setOptions((prev) => ({ ...prev, [e.target.name]: checked })); } + return ( + + + + )} + /> + + )} + /> + + + ); +} + +function Options() { + const [currentTab, setCurrentTab] = useState(0); return ( @@ -55,100 +153,18 @@ function Options() { textColor="primary" > - + + - - - - )} - label="Unread" - /> - - )} - label="Downloaded" - /> - - - - - - )} - /> - - )} - /> - - + {filtersTab(currentTab)} + {sortsTab(currentTab)} + {dispalyTab(currentTab)} ); } -function SortOptions() { - const { - sorts, setSorts, sortDesc, setSortDesc, - } = useLibraryOptions(); - - const handleChange = (event: - React.MouseEvent, index: string) => { - if (sorts === index) { - setSortDesc(!sortDesc); - } else { setSortDesc(false); } - setSorts(index); - }; - - return ( - <> - { - ['sortToRead', 'sortAlph', 'sortID'].map((e) => { - let icon; - if (sorts === e) { - icon = !sortDesc ? () - : (); - } - icon = icon === undefined && sortDesc === undefined && e === 'sortID' ? () : icon; - return ( - - handleChange(event, e)}> - {icon} - - - - ); - }) - } - - ); -} - export default function LibraryOptions() { const [filtersOpen, setFiltersOpen] = React.useState(false); - const [sortsOpen, setSortsOpen] = React.useState(false); const { active } = useLibraryOptions(); return ( <> @@ -171,27 +187,6 @@ export default function LibraryOptions() { > - - setSortsOpen(!filtersOpen)} - color={active ? 'warning' : 'default'} - > - - - - setSortsOpen(false)} - PaperProps={{ - style: { - maxWidth: 600, padding: '1em', marginLeft: 'auto', marginRight: 'auto', - }, - }} - > - - - ); }