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
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2022-11-09 18:09:15 +01:00
|
|
|
|
|
|
|
|
import FilterList from '@mui/icons-material/FilterList';
|
2023-11-05 17:22:29 +01:00
|
|
|
import { IconButton, Tooltip } from '@mui/material';
|
2022-11-09 18:09:15 +01:00
|
|
|
import * as React from 'react';
|
2023-11-05 17:22:29 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { ChapterListOptions, ChapterOptionsReducerAction } from '@/typings';
|
2023-10-28 00:32:02 +02:00
|
|
|
import { ChapterOptions } from '@/components/manga/ChapterOptions';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { isFilterActive } from '@/components/manga/util';
|
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
|
|
|
}
|
|
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const ChaptersToolbarMenu = ({ options, optionsDispatch }: IProps) => {
|
2023-11-05 17:22:29 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2022-11-09 18:09:15 +01:00
|
|
|
const [open, setOpen] = React.useState(false);
|
|
|
|
|
const isFiltered = isFilterActive(options);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-11-05 17:22:29 +01:00
|
|
|
<Tooltip title={t('settings.title')}>
|
|
|
|
|
<IconButton onClick={() => setOpen(true)}>
|
|
|
|
|
<FilterList color={isFiltered ? 'warning' : undefined} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Tooltip>
|
2022-11-09 18:09:15 +01:00
|
|
|
<ChapterOptions
|
|
|
|
|
open={open}
|
|
|
|
|
onClose={() => setOpen(false)}
|
|
|
|
|
options={options}
|
|
|
|
|
optionsDispatch={optionsDispatch}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|