forked from LNReader/lnreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Scroll to current Chapter (LNReader#1101)
* cleanup + fixed scroll to current Chapter * removed unused memoization * removed unused import * ChapterDrawer.tsx => index.tsx * added correct types * applied suggestion * changed chapter.position to scrollIndex + 2 * refactored index.ts
- Loading branch information
Showing
5 changed files
with
318 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,5 @@ web-build/ | |
|
||
.vscode/ | ||
src/sources/en/generators/ | ||
*.lockb | ||
*.lockb | ||
.tool-versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
src/screens/reader/components/ChapterDrawer/RenderListChapter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from 'react'; | ||
import { View, Pressable, TextStyle } from 'react-native'; | ||
import { Text } from 'react-native-paper'; | ||
import color from 'color'; | ||
import { ChapterInfo, NovelInfo } from '@database/types'; | ||
import { ThemeColors } from '@theme/types'; | ||
import { StackNavigationProp } from '@react-navigation/stack'; | ||
import { RootStackParamList } from '@navigators/types'; | ||
import { StyleProp } from 'react-native'; | ||
import { ViewStyle } from 'react-native'; | ||
|
||
type Styles = { | ||
chapterCtn: StyleProp<ViewStyle>; | ||
drawerElementContainer: StyleProp<ViewStyle>; | ||
chapterNameCtn: StyleProp<TextStyle>; | ||
releaseDateCtn: StyleProp<TextStyle>; | ||
}; | ||
type Navigation = StackNavigationProp<RootStackParamList, 'Chapter', undefined>; | ||
|
||
type Props = { | ||
item: ChapterInfo; | ||
novelItem: NovelInfo; | ||
styles: Styles; | ||
theme: ThemeColors; | ||
navigation: Navigation; | ||
chapterId: number; | ||
}; | ||
const changeChapter = ( | ||
item: ChapterInfo, | ||
navigation: Navigation, | ||
novelItem: NovelInfo, | ||
) => { | ||
navigation.replace('Chapter', { | ||
novel: novelItem, | ||
chapter: item, | ||
}); | ||
}; | ||
const renderListChapter = ({ | ||
item, | ||
novelItem, | ||
styles, | ||
theme, | ||
navigation, | ||
chapterId, | ||
}: Props) => { | ||
return ( | ||
<View | ||
style={[ | ||
styles.drawerElementContainer, | ||
item.id === chapterId && { | ||
backgroundColor: color(theme.primary).alpha(0.12).string(), | ||
}, | ||
]} | ||
> | ||
<Pressable | ||
android_ripple={{ color: theme.rippleColor }} | ||
onPress={() => changeChapter(item, navigation, novelItem)} | ||
style={styles.chapterCtn} | ||
> | ||
<Text | ||
numberOfLines={1} | ||
style={[ | ||
styles.chapterNameCtn, | ||
{ color: item.unread ? theme.onSurface : theme.outline }, | ||
]} | ||
> | ||
{item.name} | ||
</Text> | ||
{item.releaseTime ? ( | ||
<Text | ||
style={[ | ||
styles.releaseDateCtn, | ||
{ color: item.unread ? theme.onSurfaceVariant : theme.outline }, | ||
]} | ||
> | ||
{item.releaseTime} | ||
</Text> | ||
) : null} | ||
</Pressable> | ||
</View> | ||
); | ||
}; | ||
export default renderListChapter; |
Oops, something went wrong.