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 Stack from '@mui/material/Stack';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-12-26 17:15:50 +01:00
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import Typography from '@mui/material/Typography';
|
2024-11-04 18:00:35 +01:00
|
|
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
2024-12-18 01:04:02 +01:00
|
|
|
import { IReaderSettingsWithDefaultFlag, ReaderSettingsTypeProps } from '@/modules/reader/types/Reader.types.ts';
|
2024-11-04 18:00:35 +01:00
|
|
|
import { CheckboxInput } from '@/modules/core/components/inputs/CheckboxInput.tsx';
|
|
|
|
|
import { ReaderSettingExitMode } from '@/modules/reader/components/settings/behaviour/ReaderSettingExitMode.tsx';
|
|
|
|
|
import { isOffsetDoubleSpreadPagesEditable } from '@/modules/reader/utils/ReaderSettings.utils.tsx';
|
2024-11-06 13:00:36 +01:00
|
|
|
import { SliderInput } from '@/modules/core/components/inputs/SliderInput.tsx';
|
|
|
|
|
import { DEFAULT_READER_SETTINGS } from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
2024-12-27 00:30:19 +01:00
|
|
|
import { ReaderSettingAutoScroll } from '@/modules/reader/components/settings/behaviour/ReaderSettingAutoScroll.tsx';
|
2024-11-04 18:00:35 +01:00
|
|
|
|
|
|
|
|
export const ReaderBehaviourSettings = ({
|
|
|
|
|
settings,
|
|
|
|
|
updateSetting,
|
2024-12-18 01:04:02 +01:00
|
|
|
onDefault,
|
2024-11-04 18:00:35 +01:00
|
|
|
}: {
|
|
|
|
|
settings: IReaderSettingsWithDefaultFlag;
|
|
|
|
|
updateSetting: (
|
|
|
|
|
...args: OmitFirst<Parameters<typeof ReaderService.updateSetting>>
|
|
|
|
|
) => ReturnType<typeof ReaderService.updateSetting>;
|
2024-12-18 01:04:02 +01:00
|
|
|
} & ReaderSettingsTypeProps) => {
|
2024-11-04 18:00:35 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Stack sx={{ gap: 2 }}>
|
|
|
|
|
<ReaderSettingExitMode
|
|
|
|
|
exitMode={settings.exitMode}
|
|
|
|
|
setExitMode={(value) => updateSetting('exitMode', value)}
|
|
|
|
|
/>
|
|
|
|
|
<CheckboxInput
|
|
|
|
|
label={t('reader.settings.label.skip_dup_chapters')}
|
|
|
|
|
checked={settings.shouldSkipDupChapters}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldSkipDupChapters', checked)}
|
|
|
|
|
/>
|
|
|
|
|
{isOffsetDoubleSpreadPagesEditable(settings.readingMode.value) && (
|
|
|
|
|
<CheckboxInput
|
|
|
|
|
label={t('reader.settings.label.offset_double_spread')}
|
|
|
|
|
checked={settings.shouldOffsetDoubleSpreads.value}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldOffsetDoubleSpreads', checked)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2024-12-30 16:51:39 +01:00
|
|
|
<CheckboxInput
|
|
|
|
|
label={
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>{t('reader.settings.preview.reading_mode.title')}</Typography>
|
|
|
|
|
<Typography variant="body2" color="textDisabled">
|
|
|
|
|
{t('reader.settings.preview.reading_mode.description')}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
checked={settings.shouldShowReadingModePreview}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldShowReadingModePreview', checked)}
|
|
|
|
|
/>
|
|
|
|
|
<CheckboxInput
|
|
|
|
|
label={
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>{t('reader.settings.preview.tap_zones.title')}</Typography>
|
|
|
|
|
<Typography variant="body2" color="textDisabled">
|
|
|
|
|
{t('reader.settings.preview.tap_zones.description')}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
checked={settings.shouldShowTapZoneLayoutPreview}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldShowTapZoneLayoutPreview', checked)}
|
|
|
|
|
/>
|
2024-12-26 17:15:50 +01:00
|
|
|
<CheckboxInput
|
|
|
|
|
label={
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>{t('reader.settings.auto_webtoon_mode.title')}</Typography>
|
|
|
|
|
<Typography variant="body2" color="textDisabled">
|
|
|
|
|
{t('reader.settings.auto_webtoon_mode.description')}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
checked={settings.shouldUseAutoWebtoonMode}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldUseAutoWebtoonMode', checked)}
|
|
|
|
|
/>
|
2025-01-01 17:24:36 +01:00
|
|
|
<CheckboxInput
|
|
|
|
|
label={t('reader.settings.chapter_transition.warning.missing_chapter')}
|
|
|
|
|
checked={settings.shouldInformAboutMissingChapter}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldInformAboutMissingChapter', checked)}
|
|
|
|
|
/>
|
|
|
|
|
<CheckboxInput
|
|
|
|
|
label={t('reader.settings.chapter_transition.warning.scanlator_change')}
|
|
|
|
|
checked={settings.shouldInformAboutScanlatorChange}
|
|
|
|
|
onChange={(_, checked) => updateSetting('shouldInformAboutScanlatorChange', checked)}
|
|
|
|
|
/>
|
2024-12-27 00:30:19 +01:00
|
|
|
<ReaderSettingAutoScroll
|
|
|
|
|
autoScroll={settings.autoScroll}
|
|
|
|
|
setAutoScroll={(...args) => updateSetting('autoScroll', ...args)}
|
|
|
|
|
/>
|
2024-11-06 13:00:36 +01:00
|
|
|
<SliderInput
|
|
|
|
|
label={t('reader.settings.image_preload_amount')}
|
|
|
|
|
value={settings.imagePreLoadAmount}
|
2024-12-18 01:04:02 +01:00
|
|
|
onDefault={() => onDefault?.('imagePreLoadAmount')}
|
2024-11-06 13:00:36 +01:00
|
|
|
slotProps={{
|
|
|
|
|
slider: {
|
|
|
|
|
defaultValue: DEFAULT_READER_SETTINGS.imagePreLoadAmount,
|
|
|
|
|
value: settings.imagePreLoadAmount,
|
|
|
|
|
step: 1,
|
|
|
|
|
min: 1,
|
|
|
|
|
max: 20,
|
|
|
|
|
onChange: (_, value) => {
|
|
|
|
|
updateSetting('imagePreLoadAmount', value as number, false);
|
|
|
|
|
},
|
|
|
|
|
onChangeCommitted: (_, value) => {
|
|
|
|
|
updateSetting('imagePreLoadAmount', value as number, true);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-11-04 18:00:35 +01:00
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|