diff --git a/.gitignore b/.gitignore index de2de2be7..6a99b45c4 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,5 @@ web-build/ .vscode/ src/sources/en/generators/ -*.lockb \ No newline at end of file +*.lockb +.tool-versions \ No newline at end of file diff --git a/src/database/types/index.ts b/src/database/types/index.ts index 07dc3ca59..5e3c2c7aa 100644 --- a/src/database/types/index.ts +++ b/src/database/types/index.ts @@ -35,6 +35,7 @@ export interface ChapterInfo { chapterNumber?: number; page: string; progress: number | null; + position?: number; } export interface DownloadedChapter extends ChapterInfo { diff --git a/src/screens/reader/components/ChapterDrawer.tsx b/src/screens/reader/components/ChapterDrawer.tsx deleted file mode 100644 index 4f64825e5..000000000 --- a/src/screens/reader/components/ChapterDrawer.tsx +++ /dev/null @@ -1,265 +0,0 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { StyleSheet, View, Pressable } from 'react-native'; -import { Text } from 'react-native-paper'; -import color from 'color'; -import { useAppSettings, useTheme } from '@hooks/persisted'; -import { FlashList, FlashListProps } from '@shopify/flash-list'; -import { Button, LoadingScreenV2 } from '@components/index'; -import { EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context'; -import { getString } from '@strings/translations'; -import { ChapterScreenProps } from '@navigators/types'; -import { ChapterInfo } from '@database/types'; -import { ThemeColors } from '@theme/types'; -import { NovelSettings } from '@hooks/persisted/useNovel'; - -type ChapterDrawerProps = ChapterScreenProps & { - chapters: ChapterInfo[]; - novelSettings: NovelSettings; - pages: string[]; - setPageIndex: (value: number) => void; -}; - -const ChapterDrawer = ({ - route, - navigation, - chapters, - novelSettings, - pages, - setPageIndex, -}: ChapterDrawerProps) => { - const theme = useTheme(); - const insets = useSafeAreaInsets(); - const styles = createStylesheet(theme, insets); - const listRef = useRef>(null); - const { chapter, novel: novelItem } = route.params; - const { defaultChapterSort } = useAppSettings(); - const { sort = defaultChapterSort } = novelSettings; - - const listAscending = sort === 'ORDER BY position ASC'; - const scrollToIndex = useMemo(() => { - if (chapters.length < 1) { - return 0; - } - const indexOfCurrentChapter = - chapters.findIndex(el => { - return el.id === chapter.id; - }) || 0; - let res = indexOfCurrentChapter >= 2 ? indexOfCurrentChapter - 2 : 0; - return res; - }, [chapters, chapter.id, listAscending]); - - const [buttonProperties, setButtonProperties] = useState({ - up: { - text: getString('readerScreen.drawer.scrollToTop'), - func: () => { - listRef.current?.scrollToIndex({ index: 0, animated: true }); - }, - }, - down: { - text: getString('readerScreen.drawer.scrollToBottom'), - func: () => { - listRef.current?.scrollToEnd({ - animated: true, - }); - }, - }, - }); - - const changeChapter = (item: ChapterInfo) => { - navigation.replace('Chapter', { - novel: novelItem, - chapter: item, - }); - }; - const renderItem: FlashListProps['renderItem'] = ({ item }) => { - return ( - - changeChapter(item)} - style={styles.chapterCtn} - > - - {item.name} - - {item.releaseTime ? ( - - {item.releaseTime} - - ) : null} - - - ); - }; - - const ListFooter = () => { - return ( - -