2022-11-09 18:09:15 +01:00
|
|
|
/*
|
|
|
|
|
* 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 FilterList from '@mui/icons-material/FilterList';
|
2022-11-26 13:51:56 +01:00
|
|
|
import { IconButton } from '@mui/material';
|
2022-11-09 18:09:15 +01:00
|
|
|
import * as React from 'react';
|
2023-02-05 16:15:20 +01:00
|
|
|
import ChapterOptions from 'components/manga/ChapterOptions';
|
|
|
|
|
import { isFilterActive } from 'components/manga/util';
|
2023-02-24 16:40:37 +01:00
|
|
|
import { ChapterListOptions, ChapterOptionsReducerAction } from 'typings';
|
2022-11-09 18:09:15 +01:00
|
|
|
|
|
|
|
|
interface IProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
options: ChapterListOptions;
|
|
|
|
|
optionsDispatch: React.Dispatch<ChapterOptionsReducerAction>;
|
2022-11-09 18:09:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ChaptersToolbarMenu = ({ options, optionsDispatch }: IProps) => {
|
|
|
|
|
const [open, setOpen] = React.useState(false);
|
|
|
|
|
const isFiltered = isFilterActive(options);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<IconButton onClick={() => setOpen(true)}>
|
2022-11-26 13:51:56 +01:00
|
|
|
<FilterList color={isFiltered ? 'warning' : undefined} />
|
2022-11-09 18:09:15 +01:00
|
|
|
</IconButton>
|
|
|
|
|
<ChapterOptions
|
|
|
|
|
open={open}
|
|
|
|
|
onClose={() => setOpen(false)}
|
|
|
|
|
options={options}
|
|
|
|
|
optionsDispatch={optionsDispatch}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ChaptersToolbarMenu;
|