From f069a67660a2d4ce386a62318b70a4743e630ac4 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Wed, 1 Nov 2023 20:29:36 +0530 Subject: [PATCH] feat: Save Covers Locally (Closes #780) --- .../components/Info/NovelInfoComponents.js | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/screens/novel/components/Info/NovelInfoComponents.js b/src/screens/novel/components/Info/NovelInfoComponents.js index ab0076c31..2910cb2d8 100644 --- a/src/screens/novel/components/Info/NovelInfoComponents.js +++ b/src/screens/novel/components/Info/NovelInfoComponents.js @@ -8,6 +8,7 @@ import { Dimensions, StatusBar, } from 'react-native'; +import RNFetchBlob from 'rn-fetch-blob'; import color from 'color'; import { IconButton, Portal } from 'react-native-paper'; import { LinearGradient } from 'expo-linear-gradient'; @@ -16,6 +17,7 @@ import FastImage from 'react-native-fast-image'; import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; import { Chip } from '../../../../components'; import { coverPlaceholderColor } from '../../../../theme/colors'; +import { showToast } from '@hooks/showToast'; const NovelInfoContainer = ({ children }) => ( {children} @@ -69,17 +71,41 @@ const NovelThumbnail = ({ source, theme, setCustomNovelCover }) => { } else { return ( - + > + + { + RNFetchBlob.config({ + fileCache: true, + addAndroidDownloads: { + useDownloadManager: true, + notification: true, + path: + RNFetchBlob.fs.dirs.DownloadDir + + '/' + + source.uri.split('/').pop(), + description: 'Image', + }, + }) + .fetch('GET', source.uri) + .then(() => showToast('Cover saved')); + }} + /> +