2024-11-04 18:00:35 +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 Dialog from '@mui/material/Dialog';
|
|
|
|
|
import DialogContent from '@mui/material/DialogContent';
|
|
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
|
|
|
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
|
|
|
|
import { ReaderSettingsTabs } from '@/modules/reader/components/settings/ReaderSettingsTabs.tsx';
|
|
|
|
|
import { ReaderSettingTab } from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
2024-11-03 03:09:00 +01:00
|
|
|
import { useDisableAllHotkeysWhileMounted } from '@/modules/hotkeys/Hotkeys.utils.ts';
|
2024-11-04 18:00:35 +01:00
|
|
|
|
|
|
|
|
export const ReaderSettings = ({ isOpen, close }: { isOpen: boolean; close: () => void }) => {
|
|
|
|
|
const { manga } = useReaderStateMangaContext();
|
|
|
|
|
const settings = ReaderService.useSettings();
|
|
|
|
|
|
2024-11-03 03:09:00 +01:00
|
|
|
useDisableAllHotkeysWhileMounted();
|
|
|
|
|
|
2024-11-04 18:00:35 +01:00
|
|
|
const [activeTab, setActiveTab] = useState(0);
|
|
|
|
|
|
|
|
|
|
if (!manga) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isOpen) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Dialog
|
|
|
|
|
open={isOpen}
|
|
|
|
|
maxWidth="md"
|
|
|
|
|
fullWidth
|
|
|
|
|
onClose={close}
|
|
|
|
|
hideBackdrop={activeTab === ReaderSettingTab.FILTER}
|
|
|
|
|
>
|
|
|
|
|
<DialogContent sx={{ p: 0 }}>
|
|
|
|
|
<ReaderSettingsTabs
|
|
|
|
|
activeTab={activeTab}
|
|
|
|
|
setActiveTab={setActiveTab}
|
|
|
|
|
settings={settings}
|
|
|
|
|
updateSetting={(...args) => ReaderService.updateSetting(manga, ...args)}
|
|
|
|
|
deleteSetting={(...args) => ReaderService.deleteSetting(manga, ...args)}
|
|
|
|
|
/>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
};
|