diff --git a/src/Screens/More/ReaderSettings.js b/src/Screens/More/ReaderSettings.js index ffae8adb..6ec185dc 100644 --- a/src/Screens/More/ReaderSettings.js +++ b/src/Screens/More/ReaderSettings.js @@ -1,10 +1,11 @@ import React, { useState } from "react"; -import { Text, View } from "react-native"; +import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"; +import { ToggleButton } from "react-native-paper"; import { useDispatch } from "react-redux"; import { Appbar } from "../../Components/Appbar"; import ColorPickerModal from "../../Components/ColorPickerModal"; -import { ScreenContainer } from "../../Components/Common"; +import { Row, ScreenContainer } from "../../Components/Common"; import { ListItem, ListSection, ListSubHeader } from "../../Components/List"; import { useReaderSettings, useTheme } from "../../Hooks/reduxHooks"; @@ -68,50 +69,174 @@ const ReaderSettings = ({ navigation }) => { }, ]; + const presetThemes = [ + { + value: 1, + backgroundColor: "#000000", + textColor: "rgba(255,255,255,0.7)", + }, + { value: 2, backgroundColor: "#FFFFFF", textColor: "#000000" }, + { value: 3, backgroundColor: "#F4ECD8", textColor: "#000000" }, + { value: 4, backgroundColor: "#444444", textColor: "#FFFFFF" }, + ]; + + const onValueChange = (value) => { + dispatch(setReaderSettings("theme", value ?? reader.theme)); + dispatch( + setReaderSettings("textColor", textColor[value] ?? reader.textColor) + ); + }; + + const textAlignments = [ + { value: "left", icon: "format-align-left" }, + { value: "justify", icon: "format-align-justify" }, + { value: "right", icon: "format-align-right" }, + ]; + + const onValueChangeTextAlign = (value) => { + dispatch(setReaderSettings("textAlign", value ?? reader.textAlign)); + }; + return ( - navigation.goBack()} /> - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut - lobortis nunc id nisl tempor, sed tristique sem sagittis. - Mauris consequat orci egestas volutpat vestibulum. Nullam - convallis, leo in porttitor fringilla, ex mi finibus felis, - non molestie ligula ligula facilisis ligula. Nam eu est a - turpis porttitor aliquet sed vel risus. Ut ac scelerisque - diam. Nulla fringilla enim non ex rhoncus faucibus. Integer - eget lacus justo. Lorem ipsum dolor sit amet, consectetur - adipiscing elit. Ut vitae tempor metus. Morbi nec nisl - cursus, gravida ex vitae, laoreet leo. Pellentesque in - lectus ante. Aliquam porta suscipit pretium. Sed ut ligula - at dolor pretium egestas quis vitae urna. In ullamcorper - venenatis orci, eu pulvinar nibh venenatis sit amet. - - - - Reader - - - + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Ut lobortis nunc id nisl tempor, sed tristique sem + sagittis. Mauris consequat orci egestas volutpat + vestibulum. Nullam convallis, leo in porttitor + fringilla, ex mi finibus felis, non molestie ligula + ligula facilisis ligula. Nam eu est a turpis porttitor + aliquet sed vel risus. Ut ac scelerisque diam. Nulla + fringilla enim non ex rhoncus faucibus. Integer eget + lacus justo. Lorem ipsum dolor sit amet, consectetur + adipiscing elit. Ut vitae tempor metus. Morbi nec nisl + cursus, gravida ex vitae, laoreet leo. Pellentesque in + lectus ante. Aliquam porta suscipit pretium. Sed ut + ligula at dolor pretium egestas quis vitae urna. In + ullamcorper venenatis orci, eu pulvinar nibh venenatis + sit amet. + + + + Preset + + + Preset Themes + + + + {presetThemes.map((theme) => ( + + ))} + + + + Reader + + + Text + + + + Text Align + + + {reader.textAlign} + + + + + {textAlignments.map((item) => ( + + ))} + + + + + { }; export default ReaderSettings; + +const styles = StyleSheet.create({ + pressableListItem: { + padding: 16, + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", + }, + presetToggleButton: { + marginLeft: 12, + borderRadius: 50, + borderTopRightRadius: 50, + borderBottomRightRadius: 50, + borderTopLeftRadius: 50, + borderBottomLeftRadius: 50, + borderWidth: 0, + }, +}); diff --git a/src/Screens/Novel/components/ChapterItem.js b/src/Screens/Novel/components/ChapterItem.js index a4079970..9c292269 100644 --- a/src/Screens/Novel/components/ChapterItem.js +++ b/src/Screens/Novel/components/ChapterItem.js @@ -1,7 +1,14 @@ import React, { useState } from "react"; -import { View, Text, ActivityIndicator, StyleSheet } from "react-native"; +import { + View, + Text, + ActivityIndicator, + StyleSheet, + Pressable, +} from "react-native"; import { TouchableRipple, IconButton, Menu } from "react-native-paper"; +import { Row } from "../../../Components/Common"; import { deleteChapterAction, @@ -121,127 +128,114 @@ const ChapterItem = ({ return selected.some((obj) => obj.chapterId === chapterId); }; + const onPress = () => { + if (selected.length === 0) { + navigateToChapter(); + } else { + if (isSelected(chapter.chapterId)) { + setSelected((selected) => + selected.filter( + (item) => item.chapterId !== chapter.chapterId + ) + ); + } else { + setSelected((selected) => [...selected, chapter]); + } + } + }; + + const onLongPress = () => { + if (isSelected(chapter.chapterId)) { + setSelected((selected) => + selected.filter((item) => item.chapterId !== chapter.chapterId) + ); + } else { + setSelected((selected) => [...selected, chapter]); + } + }; + return ( - { - if (selected.length === 0) { - navigateToChapter(); - } else { - if (isSelected(chapter.chapterId)) { - setSelected((selected) => - selected.filter( - (item) => item.chapterId !== chapter.chapterId - ) - ); - } else { - setSelected((selected) => [...selected, chapter]); - } - } - }} - onLongPress={() => { - if (isSelected(chapter.chapterId)) { - setSelected((selected) => - selected.filter( - (item) => item.chapterId !== chapter.chapterId - ) - ); - } else { - setSelected((selected) => [...selected, chapter]); - } - // chapterActionsSheetRef.current.show(); - }} - rippleColor={theme.rippleColor} + onPress={onPress} + onLongPress={onLongPress} + android_ripple={{ color: theme.rippleColor }} > - <> + + {bookmarkButton()} + + {showChapterTitles + ? parseChapterNumber(chapter.chapterName) + ? "Chapter " + + parseChapterNumber(chapter.chapterName) + : "Chapter " + index + : chapter.chapterName.substring(0, 50)} + - {bookmarkButton()} - + {chapter.releaseDate && ( - {showChapterTitles - ? parseChapterNumber(chapter.chapterName) - ? "Chapter " + - parseChapterNumber( - chapter.chapterName - ) - : "Chapter " + index - : chapter.chapterName.substring(0, 50)} + {chapter.releaseDate} - - {chapter.releaseDate && ( - - {chapter.releaseDate} - - )} - {position && - !chapter.read && - position[chapter.chapterId] && - position[chapter.chapterId].percentage < - 100 && - position[chapter.chapterId].percentage > - 0 && ( - - {chapter.releaseDate && "• "} - {"Progress " + - position[chapter.chapterId] - .percentage + - "%"} - - )} - - + )} + {position && + !chapter.read && + position[chapter.chapterId] && + position[chapter.chapterId].percentage < 100 && + position[chapter.chapterId].percentage > 0 && ( + + {chapter.releaseDate && "• "} + {"Progress " + + position[chapter.chapterId].percentage + + "%"} + + )} - {displayDownloadButton()} - - + + {displayDownloadButton()} + ); }; diff --git a/src/redux/settings/settings.reducer.js b/src/redux/settings/settings.reducer.js index b2e7d04a..24e7db07 100644 --- a/src/redux/settings/settings.reducer.js +++ b/src/redux/settings/settings.reducer.js @@ -83,7 +83,6 @@ const settingsReducer = (state = initialState, action) => { [payload.key]: payload.val, }; case SET_READER_SETTINGS: - console.log(payload.val); return { ...state, reader: {