From 67aea8e3602dcce87e5a63f7cb1b6d67392155f3 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Thu, 16 Mar 2023 18:45:19 +0100
Subject: [PATCH] :zap: Ajout de l'option de recherche dans la liste de carte !
:boom:
---
redux/actions/actionSelection.tsx | 17 ++++++++---
screens/ListScreen.tsx | 48 ++++++++++++++++++++-----------
2 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/redux/actions/actionSelection.tsx b/redux/actions/actionSelection.tsx
index d91f603..61b57c3 100644
--- a/redux/actions/actionSelection.tsx
+++ b/redux/actions/actionSelection.tsx
@@ -46,13 +46,22 @@ export const getAllCards = () => {
//Have it first fetch data from our starwars url.
const options = {
method: 'GET',
+ // headers: {
+ // 'content-length':'9505',
+ // 'content-type':'application/json; charset=utf-8',
+ // 'etag':'W/"74bb-QMT8DIj6saBS1wT4u5WWcEmZAdw"'
+ // }
+
+ //! Actualisation de l'API (16/03) :
headers: {
- 'content-length':'9505',
- 'content-type':'application/json; charset=utf-8',
- 'etag':'W/"74bb-QMT8DIj6saBS1wT4u5WWcEmZAdw"'
+ 'content-length': '9508',
+ 'content-type': 'application/json; charset=utf-8',
+ '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(CardsPromise)
diff --git a/screens/ListScreen.tsx b/screens/ListScreen.tsx
index 33d6fce..f252aa6 100644
--- a/screens/ListScreen.tsx
+++ b/screens/ListScreen.tsx
@@ -1,5 +1,5 @@
-import { StyleSheet, Text, View, Button, TouchableHighlight } from 'react-native';
+import { StyleSheet, Text, View, Button, TouchableHighlight, TextInput } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from "react";
import { FlatList } from 'react-native-gesture-handler';
@@ -16,6 +16,11 @@ import { Card } from '../models/Card';
import { Image } from 'react-native';
import { ImageURISource } from 'react-native';
+//* Icons
+
+//import { BiSearchAlt } from 'react-icons';
+
+
//@ts-ignore
const Item = ({url}) => (
//
@@ -63,30 +68,32 @@ export default function ListScreen({navigation}){
//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 (
- {/* }
- keyExtractor={item => item.id}/> */}
+
+ setSearchValue(text)}
+ placeholder="Rechercher une carte..."
+ />
-
- // navigation.navigate("CardsDetails", {"card": item})}> //* mettre la page de detail ici, renvoi a home pour l'instant
navigation.navigate("ListFav")}>
-
-
- // //{item.name}
- // //
- // //
-
- // //
- } keyExtractor={(item: Card) => item.id.toString()}/>
+ }
+ keyExtractor={(item: Card) => item.id.toString()}
+ />
@@ -121,5 +128,14 @@ const styles = StyleSheet.create({
},
title: {
fontStyle: "italic",
+ },
+ textInput: {
+ padding: 15,
+ margin: 5,
+ width:200,
+ backgroundColor: '#ffffff',
+ borderRadius : 15,
+ shadowColor: 'grey',
+ textAlign:'center'
}
});