diff --git a/src/components/Switch/Switch.js b/src/components/Switch/Switch.js
new file mode 100644
index 00000000..7758349f
--- /dev/null
+++ b/src/components/Switch/Switch.js
@@ -0,0 +1,56 @@
+import React from "react";
+import { Pressable, StyleSheet, View, Text } from "react-native";
+
+import { Switch, List } from "react-native-paper";
+
+const SwitchSetting = ({ label, description, onPress, theme, icon, value }) => (
+
+
+ {icon && (
+
+ )}
+
+
+ {label}
+
+ {description && (
+
+ {description}
+
+ )}
+
+
+
+
+);
+
+export default SwitchSetting;
+
+const styles = StyleSheet.create({
+ container: {
+ paddingHorizontal: 16,
+ paddingVertical: 12,
+ flexDirection: "row",
+ justifyContent: "space-between",
+ },
+});
diff --git a/src/redux/settings/settings.reducer.js b/src/redux/settings/settings.reducer.js
index e554499d..ad36ee93 100644
--- a/src/redux/settings/settings.reducer.js
+++ b/src/redux/settings/settings.reducer.js
@@ -59,6 +59,8 @@ const initialState = {
swipeGestures: true,
incognitoMode: false,
searchAllSources: false,
+ textSelectable: false,
+ updateLibraryOnLaunch: false,
};
const settingsReducer = (state = initialState, action) => {
diff --git a/src/screens/Chapter/Chapter.js b/src/screens/Chapter/Chapter.js
index 90219467..7d321dc5 100644
--- a/src/screens/Chapter/Chapter.js
+++ b/src/screens/Chapter/Chapter.js
@@ -70,7 +70,11 @@ const Chapter = ({ route, navigation }) => {
const showScrollPercentage = useSelector(
(state) => state.settingsReducer.showScrollPercentage
);
- const { swipeGestures = true, incognitoMode = false } = useSettings();
+ const {
+ swipeGestures = true,
+ incognitoMode = false,
+ textSelectable = false,
+ } = useSettings();
const [hidden, setHidden] = useState(true);
@@ -85,7 +89,6 @@ const Chapter = ({ route, navigation }) => {
const [scrollPercentage, setScrollPercentage] = useState(0);
const [firstLayout, setFirstLayout] = useState(true);
- const [selectText, setSelectText] = useState(false);
const [contentSize, setContentSize] = useState(0);
@@ -341,7 +344,7 @@ const Chapter = ({ route, navigation }) => {
setHidden(!hidden)}
>
{chapter.chapterText
@@ -357,8 +360,7 @@ const Chapter = ({ route, navigation }) => {
reader={reader}
dispatch={dispatch}
bottomSheetRef={readerSheetRef}
- selectText={selectText}
- setSelectText={setSelectText}
+ selectText={textSelectable}
showScrollPercentage={showScrollPercentage}
/>
diff --git a/src/screens/Chapter/components/ReaderSheet.js b/src/screens/Chapter/components/ReaderSheet.js
index d7da3da4..ca9a857e 100644
--- a/src/screens/Chapter/components/ReaderSheet.js
+++ b/src/screens/Chapter/components/ReaderSheet.js
@@ -18,7 +18,6 @@ const ReaderSheet = ({
dispatch,
bottomSheetRef,
selectText,
- setSelectText,
showScrollPercentage,
}) => {
const [fontMenu, setFontMenu] = useState(false);
@@ -412,7 +411,14 @@ const ReaderSheet = ({
+ dispatch(
+ setAppSettings(
+ "textSelectable",
+ !selectText
+ )
+ )
+ }
color={theme.colorAccent}
/>
diff --git a/src/screens/Library/Library.js b/src/screens/Library/Library.js
index 3adcb2ca..775c21e8 100644
--- a/src/screens/Library/Library.js
+++ b/src/screens/Library/Library.js
@@ -1,15 +1,13 @@
-import React, { useState, useCallback, useRef } from "react";
+import React, { useState, useCallback, useRef, useEffect } from "react";
import {
StyleSheet,
Text,
View,
RefreshControl,
ActivityIndicator,
- TouchableOpacity,
} from "react-native";
import { useFocusEffect } from "@react-navigation/native";
import { useSelector, useDispatch } from "react-redux";
-import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
import { Searchbar } from "../../components/Searchbar";
import NovelList from "../../components/NovelList";
@@ -29,7 +27,11 @@ import LibraryFilterSheet from "./components/LibraryFilterSheet";
const LibraryScreen = ({ navigation }) => {
const theme = useTheme();
const dispatch = useDispatch();
- const { showNumberOfNovels, incognitoMode = false } = useSettings();
+ const {
+ showNumberOfNovels,
+ incognitoMode = false,
+ updateLibraryOnLaunch = false,
+ } = useSettings();
const libraryFilterSheetRef = useRef(null);
@@ -49,6 +51,10 @@ const LibraryScreen = ({ navigation }) => {
}, [getLibraryAction, sort, filter])
);
+ useEffect(() => {
+ updateLibraryOnLaunch && dispatch(updateLibraryAction());
+ }, []);
+
const onRefresh = () => {
setRefreshing(true);
dispatch(updateLibraryAction());
diff --git a/src/screens/More/GeneralSettings.js b/src/screens/More/GeneralSettings.js
index 252bd305..3cd1c955 100644
--- a/src/screens/More/GeneralSettings.js
+++ b/src/screens/More/GeneralSettings.js
@@ -10,12 +10,16 @@ import {
} from "../../components/List";
import { ScreenContainer } from "../../components/Common";
-import { useTheme } from "../../hooks/reduxHooks";
+import { useSettings, useTheme } from "../../hooks/reduxHooks";
import DisplayModeModal from "./components/DisplayModeModal";
import GridSizeModal from "./components/GridSizeModal";
import ThemeModal from "./components/ThemeModal";
-import { setAccentColor } from "../../redux/settings/settings.actions";
+import {
+ setAccentColor,
+ setAppSettings,
+} from "../../redux/settings/settings.actions";
import ColorPickerModal from "../../components/ColorPickerModal";
+import SwitchSetting from "../../components/Switch/Switch";
const GenralSettings = ({ navigation }) => {
const theme = useTheme();
@@ -25,6 +29,8 @@ const GenralSettings = ({ navigation }) => {
(state) => state.settingsReducer
);
+ const { updateLibraryOnLaunch = false } = useSettings();
+
const displayModeLabel = (displayMode) => {
const label = {
0: "Compact Grid",
@@ -81,6 +87,20 @@ const GenralSettings = ({ navigation }) => {
theme={theme}
/>
+ Library
+
+ dispatch(
+ setAppSettings(
+ "updateLibraryOnLaunch",
+ !updateLibraryOnLaunch
+ )
+ )
+ }
+ theme={theme}
+ />
Theme
{
}
});
- await BackgroundService.start(veryIntensiveTask, options);
+ if (libraryNovels.length > 0) {
+ await BackgroundService.start(veryIntensiveTask, options);
+ }
};
export const parseChapterNumber = (chapterName) => {