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

66 lines
2.9 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';
2025-08-16 02:02:13 +02:00
import { DefaultSettingFootnote } from '@/features/reader/settings/components/DefaultSettingFootnote.tsx';
import { IReaderSettingsWithDefaultFlag } from '@/features/reader/Reader.types.ts';
import { withPropsFrom } from '@/base/hoc/withPropsFrom.tsx';
2025-08-16 02:02:13 +02:00
import { ReaderSettingAutoScroll } from '@/features/reader/auto-scroll/settings/ReaderSettingAutoScroll.tsx';
import { CheckboxInput } from '@/base/components/inputs/CheckboxInput.tsx';
import { useReaderStoreShallow } from '@/features/reader/ReaderStore.ts';
2024-11-04 18:00:35 +01:00
2024-12-21 03:46:55 +01:00
const BaseReaderBottomBarMobileQuickSettings = ({
readingMode,
readingDirection,
2024-12-27 00:30:19 +01:00
autoScroll,
}: Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'readingDirection' | 'autoScroll'>) => {
2024-12-27 00:30:19 +01:00
const { t } = useTranslation();
const { isActive, toggleActive } = useReaderStoreShallow((state) => ({
isActive: state.autoScroll.isActive,
toggleActive: state.autoScroll.toggleActive,
}));
2024-11-04 18:00:35 +01:00
return (
<Stack sx={{ gap: 2 }}>
<DefaultSettingFootnote />
2024-11-04 18:00:35 +01:00
<ReaderSettingReadingMode
readingMode={readingMode}
setReadingMode={(value) => ReaderService.updateSetting('readingMode', value)}
2024-11-04 18:00:35 +01:00
isDefaultable
onDefault={() => ReaderService.deleteSetting('readingMode')}
2024-11-04 18:00:35 +01:00
/>
<ReaderSettingReadingDirection
readingDirection={readingDirection}
setReadingDirection={(value) => ReaderService.updateSetting('readingDirection', value)}
2024-11-04 18:00:35 +01:00
isDefaultable
onDefault={() => ReaderService.deleteSetting('readingDirection')}
2024-11-04 18:00:35 +01:00
/>
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('autoScroll', ...args)}
2024-12-27 00:30:19 +01:00
/>
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),
[ReaderService.useSettings],
['readingMode', 'readingDirection', 'autoScroll'],
2024-12-21 03:46:55 +01:00
);