2021-10-26 12:13:37 +03:30
|
|
|
/*
|
|
|
|
|
* 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
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2021-10-26 12:13:37 +03:30
|
|
|
|
2024-07-11 17:22:52 +02:00
|
|
|
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
2021-10-26 14:57:11 +03:30
|
|
|
import Tab from '@mui/material/Tab';
|
2023-02-14 16:47:38 +03:30
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-10-28 00:32:02 +02:00
|
|
|
import { Sources } from '@/screens/Sources';
|
|
|
|
|
import { Extensions } from '@/screens/Extensions';
|
2024-01-02 23:32:49 +01:00
|
|
|
import { TabPanel } from '@/components/tabs/TabPanel.tsx';
|
|
|
|
|
import { TabsWrapper } from '@/components/tabs/TabsWrapper.tsx';
|
|
|
|
|
import { TabsMenu } from '@/components/tabs/TabsMenu.tsx';
|
2024-01-26 20:50:51 +01:00
|
|
|
import { Migration } from '@/screens/Migration.tsx';
|
|
|
|
|
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
2024-07-11 17:22:52 +02:00
|
|
|
import { useResizeObserver } from '@/util/useResizeObserver.tsx';
|
2021-10-26 14:57:11 +03:30
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export function Browse() {
|
2023-02-14 16:47:38 +03:30
|
|
|
const { t } = useTranslation();
|
2024-01-26 20:50:51 +01:00
|
|
|
const { setTitle } = useContext(NavBarContext);
|
2023-02-14 16:47:38 +03:30
|
|
|
|
2024-07-11 17:22:52 +02:00
|
|
|
const tabsMenuRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
const [tabsMenuHeight, setTabsMenuHeight] = useState(0);
|
|
|
|
|
useResizeObserver(
|
|
|
|
|
tabsMenuRef,
|
2024-07-17 22:08:31 +02:00
|
|
|
useCallback(() => setTabsMenuHeight(tabsMenuRef.current!.offsetHeight), [tabsMenuRef.current]),
|
2024-07-11 17:22:52 +02:00
|
|
|
);
|
|
|
|
|
|
2021-10-26 14:57:11 +03:30
|
|
|
const [tabNum, setTabNum] = useState<number>(0);
|
|
|
|
|
|
2024-01-26 20:50:51 +01:00
|
|
|
useEffect(() => {
|
|
|
|
|
setTitle(t('global.label.browse'));
|
|
|
|
|
}, [t]);
|
|
|
|
|
|
2021-10-26 14:57:11 +03:30
|
|
|
return (
|
2024-01-02 23:32:49 +01:00
|
|
|
<TabsWrapper>
|
2024-07-11 17:22:52 +02:00
|
|
|
<TabsMenu ref={tabsMenuRef} value={tabNum} tabsCount={2} onChange={(e, newTab) => setTabNum(newTab)}>
|
2024-07-01 19:51:27 +02:00
|
|
|
<Tab sx={{ textTransform: 'none' }} label={t('source.title_one')} />
|
|
|
|
|
<Tab sx={{ textTransform: 'none' }} label={t('extension.title_other')} />
|
2024-01-26 20:50:51 +01:00
|
|
|
<Tab sx={{ textTransform: 'none' }} label={t('migrate.title')} />
|
2024-01-02 23:32:49 +01:00
|
|
|
</TabsMenu>
|
2021-10-26 14:57:11 +03:30
|
|
|
<TabPanel index={0} currentIndex={tabNum}>
|
|
|
|
|
<Sources />
|
|
|
|
|
</TabPanel>
|
|
|
|
|
<TabPanel index={1} currentIndex={tabNum}>
|
2024-07-11 17:22:52 +02:00
|
|
|
<Extensions tabsMenuHeight={tabsMenuHeight} />
|
2021-10-26 14:57:11 +03:30
|
|
|
</TabPanel>
|
2024-01-26 20:50:51 +01:00
|
|
|
<TabPanel index={2} currentIndex={tabNum}>
|
|
|
|
|
<Migration />
|
|
|
|
|
</TabPanel>
|
2024-01-02 23:32:49 +01:00
|
|
|
</TabsWrapper>
|
2021-10-26 14:57:11 +03:30
|
|
|
);
|
2021-10-26 12:13:37 +03:30
|
|
|
}
|