Files
suwayomi-material-you-webui/src/features/reader/overlay/navigation/mobile/quick-settings/ReaderBottomBarMobileQuickSettings.tsx

78 lines
3.4 KiB
TypeScript
Raw Normal View History

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';
2024-12-22 00:41:56 +01:00
import { memo } from 'react';
2024-12-27 00:30:19 +01:00
import { useTranslation } from 'react-i18next';
2025-08-16 02:02:13 +02:00
import { ReaderSettingReadingMode } from '@/features/reader/settings/layout/components/ReaderSettingReadingMode.tsx';
import { ReaderSettingReadingDirection } from '@/features/reader/settings/layout/components/ReaderSettingReadingDirection.tsx';
2025-08-15 22:02:58 +02:00
import { ReaderService } from '@/features/reader/services/ReaderService.ts';
import { useReaderStateMangaContext } from '@/features/reader/contexts/state/ReaderStateMangaContext.tsx';
2025-08-16 02:02:13 +02:00
import { DefaultSettingFootnote } from '@/features/reader/settings/components/DefaultSettingFootnote.tsx';
2024-12-27 00:30:19 +01:00
import {
IReaderSettingsWithDefaultFlag,
TReaderAutoScrollContext,
TReaderStateMangaContext,
2025-08-16 02:02:13 +02:00
} from '@/features/reader/Reader.types.ts';
2025-08-15 22:02:58 +02:00
import { withPropsFrom } from '@/features/core/hoc/withPropsFrom.tsx';
import { FALLBACK_MANGA } from '@/features/manga/Manga.constants.ts';
2025-08-16 02:02:13 +02:00
import { ReaderSettingAutoScroll } from '@/features/reader/auto-scroll/settings/ReaderSettingAutoScroll.tsx';
2025-08-15 22:02:58 +02:00
import { CheckboxInput } from '@/features/core/components/inputs/CheckboxInput.tsx';
import { useReaderAutoScrollContext } from '@/features/reader/auto-scroll/ReaderAutoScrollContext.tsx';
2024-11-04 18:00:35 +01:00
2024-12-21 03:46:55 +01:00
const BaseReaderBottomBarMobileQuickSettings = ({
manga,
readingMode,
readingDirection,
2024-12-27 00:30:19 +01:00
autoScroll,
isActive,
toggleActive,
2024-12-21 03:46:55 +01:00
}: Pick<TReaderStateMangaContext, 'manga'> &
2024-12-27 00:30:19 +01:00
Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'readingDirection' | 'autoScroll'> &
Pick<TReaderAutoScrollContext, 'isActive' | 'toggleActive'>) => {
const { t } = useTranslation();
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? FALLBACK_MANGA);
2024-11-04 18:00:35 +01:00
if (!manga) {
return null;
}
return (
<Stack sx={{ gap: 2 }}>
<DefaultSettingFootnote />
2024-11-04 18:00:35 +01:00
<ReaderSettingReadingMode
readingMode={readingMode}
setReadingMode={(value) => ReaderService.updateSetting(manga, 'readingMode', value)}
isDefaultable
onDefault={() => deleteSetting('readingMode')}
/>
<ReaderSettingReadingDirection
readingDirection={readingDirection}
setReadingDirection={(value) => ReaderService.updateSetting(manga, 'readingDirection', value)}
isDefaultable
onDefault={() => deleteSetting('readingDirection')}
/>
2024-12-27 00:30:19 +01:00
<CheckboxInput
label={t('reader.settings.auto_scroll.title')}
checked={isActive}
onChange={() => toggleActive()}
/>
<ReaderSettingAutoScroll
autoScroll={autoScroll}
setAutoScroll={(...args) => ReaderService.updateSetting(manga, 'autoScroll', ...args)}
/>
2024-11-04 18:00:35 +01:00
</Stack>
);
};
2024-12-21 03:46:55 +01:00
export const ReaderBottomBarMobileQuickSettings = withPropsFrom(
2024-12-22 00:41:56 +01:00
memo(BaseReaderBottomBarMobileQuickSettings),
2024-12-27 00:30:19 +01:00
[useReaderStateMangaContext, ReaderService.useSettings, useReaderAutoScrollContext],
['manga', 'readingMode', 'readingDirection', 'autoScroll', 'isActive', 'toggleActive'],
2024-12-21 03:46:55 +01:00
);