Skip to content

Commit

Permalink
LNReader beta version (#961)
Browse files Browse the repository at this point in the history
* beta host

* Refactor: url -> path (#944)

* refactor: url -> pathr

* fix: pluginId

* page support (#947)

* add new fields

* minor fix

* pages for novel

* render novel pages with drawer

* support real paginated novels

* descending novel chapter list

* update when has new latest chapter

* set hasUpdate for all pages after update

* fix: insert pageIndex

* fix: refreshChapters

* minor refactor: pageIndex

* fix: update page logic

* fix: order by pageIndex

* refactor: Chapter.pageindex -> index (position in page)

* Revert "refactor: Chapter.pageindex -> index (position in page)"

This reverts commit 109298e.

* refactor: pageindex -> position

* fix: reader drawer

* temporary fix migration

* fix: Serialize plugins into one file (#949)

* serialize plugins into one file

* fix typo

* Fix: insertChapters (#950)

* Fix: re-renders in novel screen(#951)

* remove unnecessary wrap

* fix: add local novel back to local category

* fix: use variables for default states

* fix: do not re-render when no FAB

* close drawer if pages length = 1

* add Portal.Host

* Cheaper useNovel hook (#952)

* fix: using pure state for novel and chapters

* fix: remove latestChapter mmkv hook

* shorter key

* fix: bookmark

* fix: save chapter progress in db

* minor refactor: chapterProgressElement

* Fix: Error/Empty actions (#956)

* fix: reader error handler

* fix: opacity for novel summary

* fix: library empty view

* fix: upsert and pages logic

* fix: update novel logic

* fix: import epub

* fix: plugin site in global search

* fix: scrollbar font size

* minor fix
  • Loading branch information
nyagami authored Feb 19, 2024
1 parent 1b5e345 commit 1bcc0e6
Show file tree
Hide file tree
Showing 59 changed files with 1,410 additions and 1,056 deletions.
4 changes: 2 additions & 2 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import BackgroundService from 'react-native-background-actions';

import { createTables } from '@database/db';
import AppErrorBoundary from '@components/AppErrorBoundary/AppErrorBoundary';
import { collectPlugins } from '@plugins/pluginManager';
import { deserializePlugins } from '@plugins/pluginManager';

import Main from './src/navigators/Main';
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
Expand All @@ -36,7 +36,7 @@ const App = () => {
const { refreshPlugins } = usePlugins();
useEffect(() => {
createTables();
collectPlugins().then(() => LottieSplashScreen.hide());
deserializePlugins().then(() => LottieSplashScreen.hide());
refreshPlugins();
if (!BackgroundService.isRunning()) {
MMKVStorage.delete(BACKGROUND_ACTION);
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/assets/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ img {
border-radius: 1.2rem;
background-color: var(--theme-surface-0-9);
touch-action: none;
font-size: 16;
}

.scrollbar-item {
Expand Down
17 changes: 7 additions & 10 deletions android/app/src/main/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ class Reader {
() =>
this.post({
type: 'save',
data: {
offsetY: window.scrollY,
percentage: parseInt(
((window.scrollY + this.layoutHeight) / this.chapterHeight) * 100,
),
},
data: parseInt(
((window.scrollY + this.layoutHeight) / this.chapterHeight) * 100,
),
}),
autoSaveInterval,
);
Expand Down Expand Up @@ -175,7 +172,7 @@ class TextToSpeech {
};
}

const reader = new Reader();
const scrollHandler = new ScrollHandler(reader);
const swipeHandler = new SwipeHandler(reader);
const tts = new TextToSpeech(reader);
var reader = new Reader();
var scrollHandler = new ScrollHandler(reader);
var swipeHandler = new SwipeHandler(reader);
var tts = new TextToSpeech(reader);
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,13 @@ private void unzipProcess(ZipInputStream zis, String distDirPath) throws Excepti
int len;
byte[] buffer = new byte[4096];
while ((zipEntry = zis.getNextEntry()) != null) {
if(zipEntry.getName().endsWith("/")) continue;
String escapedFilePath = this.escapeFilePath(zipEntry.getName());
File newFile = new File(distDirPath, escapedFilePath);
newFile.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(newFile);
boolean isWritten = false; // ignore folder entry;
while ((len = zis.read(buffer)) > 0) {
isWritten = true;
fos.write(buffer, 0, len);
}
while ((len = zis.read(buffer)) > 0) fos.write(buffer, 0, len);
fos.close();
if(!isWritten) newFile.delete();
}
zis.closeEntry();
}
Expand Down
4 changes: 2 additions & 2 deletions reader_playground/template.index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
}else{
scrollHandler.show();
}
hidden = !hidden;
break;
default:
console.log('unsupported event', event.type);
Expand All @@ -55,7 +56,6 @@
var swipeGestures = false;
var autoSaveInterval = 2222;
</script>
<script defer src="../android/app/src/main/assets/js/index.js"></script>
</head>

<body>
Expand All @@ -67,5 +67,5 @@
<div id="reader-percentage"></div>
</div>
</body>
</body>
<script defer src="../android/app/src/main/assets/js/index.js"></script>
</html>
8 changes: 7 additions & 1 deletion src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export const Checkbox: React.FC<CheckboxProps> = ({
</Pressable>
);

export const SortItem = ({ label, status, onPress, theme }) => (
interface SortItemProps {
label: string;
status?: string;
onPress: () => void;
theme: ThemeColors;
}
export const SortItem = ({ label, status, onPress, theme }: SortItemProps) => (
<Pressable
android_ripple={{ color: theme.rippleColor }}
style={[styles.pressable, { paddingVertical: 16, paddingLeft: 64 }]}
Expand Down
38 changes: 37 additions & 1 deletion src/components/EmptyView/EmptyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,47 @@ import React from 'react';
import { StyleSheet, View, Text } from 'react-native';

import { ThemeColors } from '../../theme/types';
import { Button } from 'react-native-paper';

interface EmptyViewProps {
icon?: string;
description: string;
theme: ThemeColors;
actions?: Array<{
iconName: string;
title: string;
onPress: () => void;
}>;
}

const EmptyView: React.FC<EmptyViewProps> = ({ icon, description, theme }) => (
const EmptyView: React.FC<EmptyViewProps> = ({
icon,
description,
theme,
actions,
}) => (
<View style={styles.container}>
{icon ? (
<Text style={[styles.icon, { color: theme.outline }]}>{icon}</Text>
) : null}
<Text style={[styles.text, { color: theme.outline }]}>{description}</Text>
{actions?.length ? (
<View style={styles.actionsCtn}>
{actions.map(action => (
<View key={action.title} style={styles.buttonWrapper}>
<Button
rippleColor={theme.rippleColor}
onPress={action.onPress}
icon={action.iconName}
textColor={theme.outline}
mode="outlined"
>
{action.title}
</Button>
</View>
))}
</View>
) : null}
</View>
);

Expand All @@ -34,4 +62,12 @@ const styles = StyleSheet.create({
text: {
marginTop: 16,
},
buttonWrapper: {
marginHorizontal: 4,
flexDirection: 'row',
},
actionsCtn: {
marginTop: 20,
flexDirection: 'row',
},
});
50 changes: 45 additions & 5 deletions src/components/ErrorScreenV2/ErrorScreenV2.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { Pressable, StyleSheet, Text, View } from 'react-native';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { useTheme } from '@hooks/persisted';

interface ErrorScreenProps {
error: string;
onRetry?: () => void;
retryIconColor?: string;
actions?: Array<{
iconName: string;
title: string;
onPress: () => void;
}>;
}

const ErrorScreen: React.FC<ErrorScreenProps> = ({ error }) => {
const ErrorScreen: React.FC<ErrorScreenProps> = ({ error, actions }) => {
const theme = useTheme();

return (
<View style={styles.container}>
<Text style={[styles.icon, { color: theme.outline }]}>ಥ_ಥ</Text>
<Text style={[styles.error, { color: theme.outline }]}>{error}</Text>
{actions?.length ? (
<View style={styles.actionsCtn}>
{actions.map(action => (
<View key={action.title} style={styles.buttonWrapper}>
<Pressable
android_ripple={{ color: theme.rippleColor }}
onPress={action.onPress}
style={styles.buttonCtn}
>
<MaterialCommunityIcons
name={action.iconName}
size={24}
color={theme.outline}
/>
<Text style={{ color: theme.outline }}>{action.title}</Text>
</Pressable>
</View>
))}
</View>
) : null}
</View>
);
};
Expand All @@ -36,4 +59,21 @@ const styles = StyleSheet.create({
paddingHorizontal: 16,
textAlign: 'center',
},
buttonWrapper: {
overflow: 'hidden',
borderRadius: 50,
marginHorizontal: 4,
flexDirection: 'row',
flex: 1 / 3,
},
buttonCtn: {
flex: 1,
paddingVertical: 8,
alignItems: 'center',
justifyContent: 'center',
},
actionsCtn: {
marginTop: 20,
flexDirection: 'row',
},
});
2 changes: 1 addition & 1 deletion src/components/NovelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const NovelList: React.FC<
]}
numColumns={numColumns}
key={numColumns}
keyExtractor={item => item.url}
keyExtractor={(item, index) => index + '_' + item.path}
{...props}
/>
);
Expand Down
Loading

0 comments on commit 1bcc0e6

Please sign in to comment.