Merge "Context" and "ContextProvider" components

This commit is contained in:
schroda
2025-08-16 02:14:49 +02:00
parent f548ba9502
commit f4c06d474d
65 changed files with 290 additions and 422 deletions

View File

@@ -6,8 +6,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { ReactNode, useMemo, useState } from 'react';
import { ReaderTapZoneContext } from '@/features/reader/tap-zones/contexts/ReaderTapZoneContext.tsx';
import { createContext, useContext, ReactNode, useMemo, useState } from 'react';
import { TReaderTapZoneContext } from '@/features/reader/tap-zones/TapZoneLayout.types.ts';
export const ReaderTapZoneContext = createContext<TReaderTapZoneContext>({
showPreview: false,
setShowPreview: () => undefined,
});
export const useReaderTapZoneContext = () => useContext(ReaderTapZoneContext);
export const ReaderTapZoneContextProvider = ({ children }: { children: ReactNode }) => {
const [showPreview, setShowPreview] = useState(false);

View File

@@ -9,9 +9,9 @@
import Box from '@mui/material/Box';
import { useCallback, useLayoutEffect, useState } from 'react';
import { useTheme } from '@mui/material/styles';
import { useReaderTapZoneContext } from '@/features/reader/tap-zones/contexts/ReaderTapZoneContext.tsx';
import { useReaderTapZoneContext } from '@/features/reader/tap-zones/ReaderTapZoneContext.tsx';
import { ReaderTapZoneService } from '@/features/reader/tap-zones/ReaderTapZoneService.ts';
import { useNavBarContext } from '@/features/navigation-bar/contexts/NavbarContext.tsx';
import { useNavBarContext } from '@/features/navigation-bar/NavbarContext.tsx';
import { useResizeObserver } from '@/features/core/hooks/useResizeObserver.tsx';
import { ReaderService } from '@/features/reader/services/ReaderService.ts';
import { IReaderSettings, ReadingDirection } from '@/features/reader/Reader.types.ts';

View File

@@ -1,17 +0,0 @@
/*
* 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 { createContext, useContext } from 'react';
import { TReaderTapZoneContext } from '@/features/reader/tap-zones/TapZoneLayout.types.ts';
export const ReaderTapZoneContext = createContext<TReaderTapZoneContext>({
showPreview: false,
setShowPreview: () => undefined,
});
export const useReaderTapZoneContext = () => useContext(ReaderTapZoneContext);