Skip to content

Commit fc228c6

Browse files
feat: add support for ReadAllComics API and update navigation logic in Home and ComicBook components
1 parent 44da42f commit fc228c6

File tree

5 files changed

+109
-18
lines changed

5 files changed

+109
-18
lines changed

src/Screens/Comic/APIs/Home.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const HomeType = {
116116
getComics(ComicHostName.comichubfree, 1, 'popular-comic'),
117117
getComics(ComicHostName.comichubfree, 1),
118118
],
119+
readallcomics: [getComics(ComicHostName.readallcomics, 1)],
119120
};
120121

121122
export const getComicsHome = async (

src/Screens/Comic/APIs/constance.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const HomePageCardClasses = {
6666
statusClass: null, // Not applicable for readallcomics
6767
dateClass: '.pinbin-copy span', // Date is inside this span tag
6868
lastPageClass: '.pagenavi span.page-numbers.dots',
69+
cardLinkClass: '.front-link',
6970
},
7071
},
7172
comichubfree: {

src/Screens/Comic/Book/index.js

Lines changed: 97 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import Header from '../../../Components/UIComp/Header';
2323
import {goBack} from '../../../Navigation/NavigationService';
2424
import GalleryImage from './GalleryImage';
2525
import VerticalView from './VerticalView';
26-
import {downloadComicBook, showRewardedAd} from '../../../InkNest-Externals/Redux/Actions/Download';
26+
import {
27+
downloadComicBook,
28+
showRewardedAd,
29+
} from '../../../InkNest-Externals/Redux/Actions/Download';
2730
import {updateData, setScrollPreference} from '../../../Redux/Reducers';
2831
import {handleScrollModeChange} from '../../../Utils/ScrollModeUtils';
2932
import {NAVIGATION} from '../../../Constants';
@@ -51,10 +54,14 @@ export function ComicBook({navigation, route}) {
5154

5255
const loading = useSelector(state => state?.data?.loading);
5356
const error = useSelector(state => state?.data?.error);
54-
const userScrollPreference = useSelector(state => state?.data?.scrollPreference);
57+
const userScrollPreference = useSelector(
58+
state => state?.data?.scrollPreference,
59+
);
5560

5661
const [imageLinkIndex, setImageLinkIndex] = useState(0);
57-
const [isVerticalScroll, setIsVerticalScroll] = useState(userScrollPreference === 'vertical');
62+
const [isVerticalScroll, setIsVerticalScroll] = useState(
63+
userScrollPreference === 'vertical',
64+
);
5865
const [isModalVisible, setIsModalVisible] = useState(false);
5966
const [downloadLoading, setDownloadLoading] = useState(false);
6067
const [progress, setProgress] = useState({downloaded: 0, total: 0});
@@ -174,7 +181,11 @@ export function ComicBook({navigation, route}) {
174181

175182
if (loading) {
176183
return (
177-
<SafeAreaView style={styles.container}>
184+
<SafeAreaView
185+
style={[
186+
styles.container,
187+
{justifyContent: 'center', alignItems: 'center'},
188+
]}>
178189
<Text style={styles.text}>Loading comic data...</Text>
179190
</SafeAreaView>
180191
);
@@ -183,22 +194,98 @@ export function ComicBook({navigation, route}) {
183194
if (error) {
184195
return (
185196
<SafeAreaView style={styles.container}>
186-
<Text style={styles.text}>Error: {error}</Text>
197+
<Header
198+
style={{
199+
width: '100%',
200+
height: heightPercentageToDP('4%'),
201+
flexDirection: 'row',
202+
justifyContent: 'space-between',
203+
alignItems: 'center',
204+
paddingHorizontal: 12,
205+
}}>
206+
<TouchableOpacity
207+
onPress={() => {
208+
analytics().logEvent('go_back_error', {
209+
screen: 'ComicBook',
210+
comicBookLink: comicBookLink?.toString(),
211+
DetailsPageLink: detailsPageLink?.toString(),
212+
});
213+
goBack();
214+
}}>
215+
<Ionicons
216+
name="arrow-back"
217+
size={24}
218+
color="#fff"
219+
style={{marginRight: 10, opacity: 0.9}}
220+
/>
221+
</TouchableOpacity>
222+
<Text
223+
style={{
224+
fontSize: 14,
225+
fontWeight: '700',
226+
color: '#fff',
227+
opacity: 0.9,
228+
}}>
229+
Comic Book
230+
</Text>
231+
<View style={{flex: 0.1}} />
232+
</Header>
233+
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
234+
<Text style={styles.text}>Error: {error}</Text>
235+
</View>
187236
</SafeAreaView>
188237
);
189238
}
190239

191-
if (!comicBook) {
240+
if (!comicBook?.images?.length > 0) {
192241
return (
193242
<SafeAreaView style={styles.container}>
194-
<Text style={styles.text}>No data available</Text>
243+
<Header
244+
style={{
245+
width: '100%',
246+
height: heightPercentageToDP('4%'),
247+
flexDirection: 'row',
248+
justifyContent: 'space-between',
249+
alignItems: 'center',
250+
paddingHorizontal: 12,
251+
}}>
252+
<TouchableOpacity
253+
onPress={() => {
254+
analytics().logEvent('go_back_nodata', {
255+
screen: 'ComicBook',
256+
comicBookLink: comicBookLink?.toString(),
257+
DetailsPageLink: detailsPageLink?.toString(),
258+
});
259+
goBack();
260+
}}>
261+
<Ionicons
262+
name="arrow-back"
263+
size={24}
264+
color="#fff"
265+
style={{marginRight: 10, opacity: 0.9}}
266+
/>
267+
</TouchableOpacity>
268+
<Text
269+
style={{
270+
fontSize: 14,
271+
fontWeight: '700',
272+
color: '#fff',
273+
opacity: 0.9,
274+
}}>
275+
Comic Book
276+
</Text>
277+
<View style={{flex: 0.1}} />
278+
</Header>
279+
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
280+
<Text style={styles.text}>No data available</Text>
281+
</View>
195282
</SafeAreaView>
196283
);
197284
}
198285

199286
return (
200287
<>
201-
<SafeAreaView style={{flex: 1, backgroundColor: '#14142A'}}>
288+
<SafeAreaView style={styles.container}>
202289
<Header
203290
style={{
204291
width: '100%',
@@ -243,7 +330,7 @@ export function ComicBook({navigation, route}) {
243330
color: '#fff',
244331
opacity: 0.9,
245332
}}>
246-
Page: {imageLinkIndex + 1} / {comicBook?.images.length}
333+
Page: {imageLinkIndex + 1} / {comicBook?.images?.length}
247334
</Text>
248335

249336
<TouchableOpacity onPress={() => setIsModalVisible(true)}>
@@ -321,7 +408,7 @@ export function ComicBook({navigation, route}) {
321408
setScrollPreference,
322409
() => setIsModalVisible(false),
323410
'ComicBook',
324-
comicBookLink
411+
comicBookLink,
325412
);
326413
}}>
327414
<Text style={styles.text}>
@@ -494,8 +581,6 @@ const styles = StyleSheet.create({
494581
container: {
495582
flex: 1,
496583
backgroundColor: '#14142A',
497-
justifyContent: 'center',
498-
alignItems: 'center',
499584
},
500585
text: {
501586
fontSize: 20,

src/Screens/Comic/Home/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ import {AppendAd} from '../../../InkNest-Externals/Ads/AppendAd';
2828
import AnimeAdbanner from '../../../Components/UIComp/AnimeAdBanner/AnimeAdbanner';
2929
import {clearHistory} from '../../../Redux/Reducers';
3030
import {ComicHostName} from '../../../Utils/APIs';
31-
import {widthPercentageToDP} from 'react-native-responsive-screen';
3231

3332
export function Home({navigation}) {
3433
const flatListRef = useRef(null);
3534
const [comicsData, setComicsData] = useState({});
3635
const [loading, setLoading] = useState(false);
37-
const [type, setType] = useState('comichubfree');
36+
const [type, setType] = useState('readcomicsonline');
3837
const [changeType, setChangeType] = useState(false);
3938
const History = useSelector(state => state.data.history);
4039
const dispatch = useDispatch();
@@ -323,10 +322,14 @@ export function Home({navigation}) {
323322
link: item?.link?.toString(),
324323
title: item?.title?.toString(),
325324
});
326-
navigation.navigate(NAVIGATION.comicDetails, {
327-
...item,
328-
isComicBookLink: key === 'readallcomics',
329-
});
325+
type === 'readallcomics'
326+
? navigation.navigate(NAVIGATION.comicBook, {
327+
comicBookLink: item?.link,
328+
})
329+
: navigation.navigate(NAVIGATION.comicDetails, {
330+
...item,
331+
isComicBookLink: key === 'readallcomics',
332+
});
330333
}}
331334
/>
332335
)}

src/Utils/APIs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const ComicHostName = {
22
readcomicsonline: 'https://readcomicsonline.ru/',
33
comichubfree: 'https://comichubfree.com/',
4+
readallcomics: 'https://readallcomics.com/',
45
};
56
export const AnimeHostName = {
67
gogoanimes: 'https://ww12.gogoanimes.fi/',

0 commit comments

Comments
 (0)