From 8faac7355898e4bfa2994d9b3300a0d1d665ec02 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Tue, 5 Oct 2021 09:02:21 +0530 Subject: [PATCH] Minor fixes --- src/components/IconButton/IconButton.js | 39 ++++++++++ src/components/ListView.js | 11 ++- src/components/NovelCover.js | 73 +++++++++---------- src/navigators/BottomNavigator.js | 5 +- src/screens/browse/Browse.js | 15 ++-- src/screens/history/components/HistoryItem.js | 19 +++-- .../reader/components/WebViewReader.js | 1 + src/sources/helpers/htmlToText.js | 2 +- .../multisrc/madara/MadaraGenerator.js | 8 ++ src/sources/sources.js | 2 +- 10 files changed, 111 insertions(+), 64 deletions(-) create mode 100644 src/components/IconButton/IconButton.js diff --git a/src/components/IconButton/IconButton.js b/src/components/IconButton/IconButton.js new file mode 100644 index 00000000..02540a8d --- /dev/null +++ b/src/components/IconButton/IconButton.js @@ -0,0 +1,39 @@ +import React from 'react'; +import {Pressable, StyleSheet, ViewPropTypes} from 'react-native'; +import PropTypes from 'prop-types'; + +import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; + +export const IconButton = ({ + icon, + size, + color, + onPress, + containerStyle, + theme, +}) => ( + + + +); + +IconButton.defaultProps = { + size: 24, +}; + +IconButton.propTypes = { + icon: PropTypes.string.isRequired, + size: PropTypes.number.isRequired, + color: PropTypes.string, + onPress: PropTypes.func, + containerStyle: ViewPropTypes.style, + theme: PropTypes.object.isRequired, +}; + +const styles = StyleSheet.create({ + container: {padding: 12}, +}); diff --git a/src/components/ListView.js b/src/components/ListView.js index 6758ef21..95d14209 100644 --- a/src/components/ListView.js +++ b/src/components/ListView.js @@ -2,6 +2,7 @@ import React from 'react'; import {StyleSheet, View, Text, Pressable} from 'react-native'; import FastImage from 'react-native-fast-image'; +import {defaultCoverUri} from '../sources/helpers/constants'; const ListView = ({ item, @@ -13,6 +14,11 @@ const ListView = ({ isSelected, onLongPress, }) => { + const uri = + item.novelCover && !item.novelCover.startsWith('/') + ? item.novelCover + : defaultCoverUri; + return ( diff --git a/src/components/NovelCover.js b/src/components/NovelCover.js index 568e9b8a..8335981e 100644 --- a/src/components/NovelCover.js +++ b/src/components/NovelCover.js @@ -14,6 +14,7 @@ import ListView from './ListView'; import {getDeviceOrientation} from '../services/utils/helpers'; import {useSettings} from '../hooks/reduxHooks'; +import {defaultCoverUri} from '../sources/helpers/constants'; const NovelCover = ({ item, @@ -41,6 +42,11 @@ const NovelCover = ({ const selectNovel = () => onLongPress && onLongPress(item.novelId); + const uri = + item.novelCover && !item.novelCover.startsWith('/') + ? item.novelCover + : defaultCoverUri; + return displayMode !== 2 ? ( - <> - - {libraryStatus && } - {showDownloadBadges && item.chaptersDownloaded && ( - - )} - {showUnreadBadges && item.chaptersUnread && ( - - )} - - - - {displayMode === 0 && } - - {displayMode === 1 && ( - + + {libraryStatus && } + {showDownloadBadges && item.chaptersDownloaded && ( + )} - + {showUnreadBadges && item.chaptersUnread && ( + + )} + + + + {displayMode === 0 && } + + {displayMode === 1 && ( + + )} ) : ( diff --git a/src/navigators/BottomNavigator.js b/src/navigators/BottomNavigator.js index 2d06840f..9994cd4f 100644 --- a/src/navigators/BottomNavigator.js +++ b/src/navigators/BottomNavigator.js @@ -26,10 +26,7 @@ const BottomNavigator = () => { return ( diff --git a/src/screens/browse/Browse.js b/src/screens/browse/Browse.js index 7f7b26e6..16341e5b 100644 --- a/src/screens/browse/Browse.js +++ b/src/screens/browse/Browse.js @@ -74,8 +74,8 @@ const Browse = ({navigation}) => { /> ); - const SourceHeader = ({title}) => ( - + const Header = ({title}) => ( + {title} ); @@ -115,7 +115,7 @@ const Browse = ({navigation}) => { {showMyAnimeList && ( <> - +
{showMyAnimeList && ( { keyExtractor={item => item.sourceId.toString()} renderItem={renderItem} extraData={pinnedSources} - ListHeaderComponent={} + ListHeaderComponent={
} /> )} - {sources.length > 0 && } + {sources.length > 0 &&
} } ListEmptyComponent={ @@ -174,8 +174,9 @@ const styles = StyleSheet.create({ container: { flex: 1, }, - sourcesHeader: { + header: { paddingHorizontal: 16, - paddingVertical: 8, + paddingVertical: 12, + textTransform: 'uppercase', }, }); diff --git a/src/screens/history/components/HistoryItem.js b/src/screens/history/components/HistoryItem.js index 466ad14d..60848720 100644 --- a/src/screens/history/components/HistoryItem.js +++ b/src/screens/history/components/HistoryItem.js @@ -1,11 +1,13 @@ import React, {useCallback} from 'react'; -import {Pressable, StyleSheet, View, Image, Text} from 'react-native'; +import {Pressable, StyleSheet, View, Text} from 'react-native'; import moment from 'moment'; -import {IconButton} from 'react-native-paper'; +import FastImage from 'react-native-fast-image'; import {parseChapterNumber} from '../../../services/utils/helpers'; import {setNovel} from '../../../redux/novel/novel.actions'; +import {defaultCoverUri} from '../../../sources/helpers/constants'; +import {IconButton} from '../../../components/IconButton/IconButton'; const HistoryItem = ({history, theme, dispatch, navigation, deleteHistory}) => { const { @@ -47,13 +49,8 @@ const HistoryItem = ({history, theme, dispatch, navigation, deleteHistory}) => { bookmark, }); - const getNovelCover = useCallback( - () => - novelCover && !novelCover.startsWith('/') - ? novelCover - : 'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true', - [], - ); + const uri = + novelCover && !novelCover.startsWith('/') ? novelCover : defaultCoverUri; return ( { - + { size={24} color={theme.textColorPrimary} onPress={() => deleteHistory(historyId)} + theme={theme} /> diff --git a/src/screens/reader/components/WebViewReader.js b/src/screens/reader/components/WebViewReader.js index 1ebdeb91..a0cc730e 100644 --- a/src/screens/reader/components/WebViewReader.js +++ b/src/screens/reader/components/WebViewReader.js @@ -22,6 +22,7 @@ const WebViewReader = ({ { html = html.trim(); - text = removeLineBreaks && html.replace(/(?:\n|\r\n|\r)/gi, ''); + let text = removeLineBreaks && html.replace(/(?:\n|\r\n|\r)/gi, ''); text = html /** diff --git a/src/sources/multisrc/madara/MadaraGenerator.js b/src/sources/multisrc/madara/MadaraGenerator.js index 6b8deacf..d88a8f3b 100644 --- a/src/sources/multisrc/madara/MadaraGenerator.js +++ b/src/sources/multisrc/madara/MadaraGenerator.js @@ -23,6 +23,7 @@ const getPath = extensionId => { 63: {novels: 'novel', novel: 'novel', chapter: 'novel'}, 75: {novels: 'series', novel: 'series', chapter: 'series'}, 80: {novels: 'manga', novel: 'manga', chapter: 'manga'}, + 21: {novels: 'novellist', novel: 'series', chapter: 'series'}, }; return ( @@ -34,6 +35,13 @@ const getPath = extensionId => { ); }; +export const WoopReadScraper = new MadaraScraper( + 21, + 'https://woopread.com/', + 'WoopRead', + getPath(21), +); + export const SkyNovelScraper = new MadaraScraper( 38, 'https://skynovel.org/', diff --git a/src/sources/sources.js b/src/sources/sources.js index 5c1f6d99..029021f0 100644 --- a/src/sources/sources.js +++ b/src/sources/sources.js @@ -19,7 +19,6 @@ import novelUpdatesCcScraper from './en/novelupdatescc'; import readLightNovelCcScraper from './en/readlightnovelcc'; import tapReadScraper from './en/tapread'; import WuxiaWorldCloudScraper from './en/wuxiaworldcloud'; -import WoopReadScraper from './en/woopread'; import FoxaHolicScraper from './en/foxaholic'; import EinharjarProjectScraper from './es/einherjarproject'; import TuNovelaLigeraScraper from './es/tunovelaligera'; @@ -55,6 +54,7 @@ import { SleepyTranslationsScraper, WBNovelScraper, WebNovelLoverScraper, + WoopReadScraper, WuxiaWorldDotSiteScraper, ZinnNovelScraper, } from './multisrc/madara/MadaraGenerator';