Adding asynStorage methods

pull/5/head
Corentin RICHARD 2 years ago
commit 28b597d0cc

@ -46,13 +46,22 @@ export const getAllCards = () => {
//Have it first fetch data from our starwars url. //Have it first fetch data from our starwars url.
const options = { const options = {
method: 'GET', method: 'GET',
// headers: {
// 'content-length':'9505',
// 'content-type':'application/json; charset=utf-8',
// 'etag':'W/"74bb-QMT8DIj6saBS1wT4u5WWcEmZAdw"'
// }
//! Actualisation de l'API (16/03) :
headers: { headers: {
'content-length':'9505', 'content-length': '9508',
'content-type': 'application/json; charset=utf-8', 'content-type': 'application/json; charset=utf-8',
'etag':'W/"74bb-QMT8DIj6saBS1wT4u5WWcEmZAdw"' 'etag': 'W/"74bb-d4gMlMNks7UGES3Jmn6wzUTXaLI"'
} }
}; };
const CardsPromise = await fetch('https://us.api.blizzard.com/hearthstone/cards?locale=en_US&access_token=EURTWhjBC2SRb4Ez42BT1kx8R2NcJc07kL', options); //! Actualisation de l'API (16/03) :
const CardsPromise = await fetch('https://us.api.blizzard.com/hearthstone/cards?locale=en_US&access_token=EU1AbKy9Q7sOUjQYC5AFF1O1JPuoAgCNxk', options);
//const CardsPromise = await fetch('https://us.api.blizzard.com/hearthstone/cards?locale=en_US&access_token=EURTWhjBC2SRb4Ez42BT1kx8R2NcJc07kL', options);
//console.log("FETCH") //console.log("FETCH")
//console.log(CardsPromise) //console.log(CardsPromise)

@ -1,4 +1,5 @@
import { StyleSheet, Text, View, Button, TouchableHighlight, ImageBackground } from 'react-native';
import { StyleSheet, Text, View, Button, TouchableHighlight, TextInput } from 'react-native';
import { StatusBar } from 'expo-status-bar'; import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
@ -13,6 +14,11 @@ import { Card } from '../models/Card';
import { Image } from 'react-native'; import { Image } from 'react-native';
import { ImageURISource } from 'react-native'; import { ImageURISource } from 'react-native';
//* Icons
//import { BiSearchAlt } from 'react-icons';
//@ts-ignore //@ts-ignore
const Item = ({url}) => { // a mettre dans components et definir une props pour passer le param const Item = ({url}) => { // a mettre dans components et definir une props pour passer le param
@ -66,30 +72,32 @@ export default function ListScreen({navigation}){
//https://us.api.blizzard.com/hearthstone/cards/678?locale=en_US //https://us.api.blizzard.com/hearthstone/cards/678?locale=en_US
//* Search :
const [searchValue, setSearchValue] = useState('');
//@ts-ignore
const filteredList = nList.filter(item => item.name.toLowerCase().includes(searchValue.toLowerCase()));
return ( return (
<View style={styles.container}> <View style={styles.container}>
{/* <FlatList data={nList}
renderItem={({item}) => <Item title={item.name} />} <TextInput
keyExtractor={item => item.id}/> */} style={styles.textInput}
value={searchValue}
onChangeText={text => setSearchValue(text)}
placeholder="Rechercher une carte..."
/>
<FlatList <FlatList
numColumns={2} numColumns={2}
data={nList} data={filteredList}
renderItem={({item}) => renderItem={({item}) =>
//<TouchableHighlight onPress={() => navigation.navigate("CardsDetails", {"card": item})}> //* mettre la page de detail ici, renvoi a home pour l'instant
<TouchableHighlight onPress={() => navigation.navigate("ListFav")}> <TouchableHighlight onPress={() => navigation.navigate("ListFav")}>
<Item url={item.img}/> <Item url={item.img}/>
</TouchableHighlight> </TouchableHighlight>
}
// //<Text>{item.name}</Text> keyExtractor={(item: Card) => item.id.toString()}
// // <View> />
// // <Image
// // source={{uri:item.img}}
// // style={{flex:1, minHeight:250, minWidth:180}}/>
// // </View>
} keyExtractor={(item: Card) => item.id.toString()}/>
</View> </View>
@ -129,5 +137,14 @@ const styles = StyleSheet.create({
}, },
title: { title: {
fontStyle: "italic", fontStyle: "italic",
},
textInput: {
padding: 15,
margin: 5,
width:200,
backgroundColor: '#ffffff',
borderRadius : 15,
shadowColor: 'grey',
textAlign:'center'
} }
}); });

Loading…
Cancel
Save