This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added follows list screen - added bookmark icon on manga list + manga screen - added notifications for followed mangas releases
- Loading branch information
Showing
16 changed files
with
340 additions
and
8,507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { | ||
View, | ||
Image | ||
} from 'react-native'; | ||
import styles from "../assets/styles/styles"; | ||
import { useEffect } from 'react'; | ||
|
||
|
||
const BannerHeader = () => { | ||
|
||
useEffect(() => { | ||
Image.resolveAssetSource({ uri: '../assets/img/banner.png' }); | ||
}, []); | ||
|
||
return ( | ||
<View style={styles.fullContainer}> | ||
<Image | ||
style={styles.banner} | ||
source={require('../assets/img/banner.png')} | ||
fadeDuration={0} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
|
||
module.exports = BannerHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
View, | ||
Image, | ||
RefreshControl, | ||
Text, | ||
FlatList, | ||
TouchableHighlight | ||
} from 'react-native'; | ||
import BackgroundImage from './BackgroundImage'; | ||
import LoadingScreen from './LoadingScreen'; | ||
import BannerHeader from './BannerHeader'; | ||
import styles from "../assets/styles/styles"; | ||
import secrets from '../config/secrets'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { get } from 'axios'; | ||
|
||
const MangaScreen = ({navigation}) => { | ||
|
||
const [isLoadingChapters, setLoadingChapters] = useState(true); | ||
const [chapters, setChapters] = useState([]); | ||
const [refreshing, setRefreshing] = useState(false); | ||
|
||
const getLastChapters = async limit => { | ||
return get(secrets.sf_api.url + "chapters/" + limit, { headers: { Authorization: `Bearer ${secrets.sf_api.token}` } }).then(res => res.data).catch(console.error); | ||
}; | ||
const loadChapters = () => { | ||
getLastChapters(20) | ||
.then(chaps => { | ||
if (!chaps) return; | ||
try { | ||
AsyncStorage.getItem('follows').then(f => JSON.parse(f || "[]")).then(follows => { | ||
setChapters(chaps.filter(c => follows.includes(c.manga.id))); | ||
setLoadingChapters(false); | ||
}).catch(console.error); | ||
} catch (err) { console.error(err); } | ||
}).catch(err => { | ||
console.error(err); | ||
setLoadingChapters(false); | ||
}); | ||
}; | ||
const wait = timeout => { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, timeout); | ||
}); | ||
} | ||
const onRefresh = () => { | ||
setRefreshing(true); | ||
wait(2000).then(() => { | ||
setLoadingChapters(true); | ||
loadChapters(); | ||
setRefreshing(false); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
loadChapters(); | ||
}, []); | ||
|
||
if (isLoadingChapters) | ||
return (<LoadingScreen />); | ||
if (!chapters.length) | ||
return ( | ||
<View> | ||
<Text> | ||
Une erreur s'est produite lors du chargement des chapitres... | ||
</Text> | ||
</View> | ||
); | ||
return ( | ||
<BackgroundImage> | ||
<FlatList | ||
style={styles.listChapters} | ||
data={chapters} | ||
renderItem={({ item }) => <ThumbnailChapter navigation={navigation} chapter={item} />} | ||
keyExtractor={item => item.title} | ||
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />} | ||
ListHeaderComponent={BannerHeader} | ||
/> | ||
</BackgroundImage> | ||
); | ||
} | ||
|
||
const ThumbnailChapter = ({ navigation, chapter }) => { | ||
const sliceText = (text, max) => { | ||
if (text.length <= max) return [text, ""]; | ||
let t = text.split(' '); | ||
let n = t[0].length, i = 0; while (i < t.length && n < max) { n += t[i].length + 1; i++; } | ||
return [t.slice(0, i - 1).join(' '), t.slice(i - 1).join(' ')]; | ||
}; | ||
|
||
return ( | ||
<View style={styles.item}> | ||
<TouchableHighlight style={styles.chapterPreviewFullContainer} onPress={() => navigation.navigate('Chapter', { chapter: chapter })}> | ||
<View> | ||
<Text> | ||
<TouchableHighlight style={styles.chapterPreviewContainer} onPress={() => navigation.navigate('Manga', { manga: chapter.manga })}> | ||
<View> | ||
<Image style={styles.chapterPreviewThumbnail} source={{ uri: chapter.manga.thumbnail }} fadeDuration={0} /> | ||
<View style={styles.chapterPreviewThumbnailBorder} /> | ||
</View> | ||
</TouchableHighlight> | ||
<View style={styles.chapterPreviewContainer}> | ||
<View style={{ flexWrap: 'nowrap' }}> | ||
<Text style={[styles.text, styles.chapterPreviewName]}>{chapter.manga.name.slice(0, 28) + (chapter.manga.name.length > 28 ? "-" : "")}</Text> | ||
</View> | ||
<View> | ||
<Text style={[styles.text, styles.chapterPreviewTitle]}>{sliceText(chapter.title, 43)[0]}</Text> | ||
<Text style={[styles.text, styles.chapterPreviewTitle]}>{sliceText(chapter.title, 43)[1]}</Text> | ||
</View> | ||
</View> | ||
</Text> | ||
<Text style={[styles.text, styles.chapterPreviewNumber]}>{chapter.number}</Text> | ||
<Text style={[styles.text, styles.chapterPreviewDate]}>{`Il y a ${chapter.release_date}`}</Text> | ||
</View> | ||
</TouchableHighlight> | ||
</View> | ||
); | ||
}; | ||
|
||
|
||
module.exports = MangaScreen; |
Oops, something went wrong.