/* * 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 IconButton from '@mui/material/IconButton'; import SettingsIcon from '@mui/icons-material/Settings'; import Stack from '@mui/material/Stack'; import AppSettingsAltIcon from '@mui/icons-material/AppSettingsAlt'; import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; import { alpha } from '@mui/material/styles'; import { bindDialog, bindTrigger, usePopupState } from 'material-ui-popup-state/hooks'; import Dialog from '@mui/material/Dialog'; import DialogContent from '@mui/material/DialogContent'; import { useTranslation } from 'react-i18next'; import Slide from '@mui/material/Slide'; import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react'; import { CustomTooltip } from '@/base/components/CustomTooltip.tsx'; import { ReaderBottomBarMobileProps } from '@/features/reader/overlay/ReaderOverlay.types.ts'; import { MobileReaderProgressBar } from '@/features/reader/overlay/progress-bar/mobile/MobileReaderProgressBar.tsx'; import { ReaderChapterList } from '@/features/reader/overlay/navigation/components/ReaderChapterList.tsx'; import { ReaderBottomBarMobileQuickSettings } from '@/features/reader/overlay/navigation/mobile/quick-settings/ReaderBottomBarMobileQuickSettings.tsx'; import { useResizeObserver } from '@/base/hooks/useResizeObserver.tsx'; import { useReaderChaptersStore, useReaderScrollbarStore } from '@/features/reader/stores/ReaderStore.ts'; const BaseReaderBottomBarMobile = ({ openSettings, isVisible, topOffset = 0, }: ReaderBottomBarMobileProps & { topOffset?: number }) => { const { t } = useTranslation(); const { currentChapter, chapters } = useReaderChaptersStore((state) => ({ currentChapter: state.chapters.currentChapter, chapters: state.chapters.chapters, })); const chapterListPopupState = usePopupState({ variant: 'dialog', popupId: 'reader-chapter-list-dialog' }); const quickSettingsPopupState = usePopupState({ variant: 'dialog', popupId: 'reader-quick-settings-dialog' }); const scrollbar = useReaderScrollbarStore((state) => state.scrollbar); const [bottomBarRefHeight, setBottomBarRefHeight] = useState(0); const bottomBarRef = useRef(null); useResizeObserver( bottomBarRef, useCallback(() => setBottomBarRefHeight(bottomBarRef.current?.clientHeight ?? 0), [bottomBarRefHeight]), ); useLayoutEffect(() => { chapterListPopupState.close(); }, [currentChapter?.id]); return ( <> alpha(theme.palette.background.paper, 0.95), pb: `max(${scrollbar.xSize}px, env(safe-area-inset-bottom))`, boxShadow: 2, pointerEvents: 'all', }} > {chapterListPopupState.isOpen && ( )} {quickSettingsPopupState.isOpen && ( )} ); }; export const ReaderBottomBarMobile = memo(BaseReaderBottomBarMobile);