/* * 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 MoreHoriz from '@mui/icons-material/MoreHoriz'; import { Fab, Menu, Box } from '@mui/material'; import React, { useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import type { IChapterWithMeta } from '@/components/manga/ChapterList'; import { SelectionFABActionItem } from '@/components/manga/SelectionFABActionItem'; import { DEFAULT_FAB_STYLE } from '@/components/util/StyledFab'; export type SelectionAction = 'download' | 'delete' | 'bookmark' | 'unbookmark' | 'mark_as_read' | 'mark_as_unread'; interface SelectionFABProps { selectedChapters: IChapterWithMeta[]; onAction: (action: SelectionAction, chapters: IChapterWithMeta[]) => void; } export const SelectionFAB: React.FC = (props) => { const { t } = useTranslation(); const { selectedChapters, onAction } = props; const count = selectedChapters.length; const anchorEl = useRef(); const [open, setOpen] = useState(false); const handleClose = () => setOpen(false); const handleAction = (action: SelectionAction, chapters: IChapterWithMeta[]) => { onAction(action, chapters); handleClose(); }; return ( setOpen(true)}> {`${count} ${t('chapter.title', { count })}`} !c.isDownloaded && dc === undefined, )} onClick={handleAction} title={t('chapter.action.download.add.button.selected')} /> chapter.isDownloaded)} onClick={handleAction} title={t('chapter.action.download.delete.button.selected')} /> !chapter.isBookmarked)} onClick={handleAction} title={t('chapter.action.bookmark.add.button.selected')} /> chapter.isBookmarked)} onClick={handleAction} title={t('chapter.action.bookmark.remove.button.selected')} /> !chapter.isRead)} onClick={handleAction} title={t('chapter.action.mark_as_read.add.button.selected')} /> chapter.isRead)} onClick={handleAction} title={t('chapter.action.mark_as_read.remove.button.selected')} /> ); };