diff --git a/components/ListItemComponent.tsx b/components/ListItemComponent.tsx
index e087af4..97cbe13 100644
--- a/components/ListItemComponent.tsx
+++ b/components/ListItemComponent.tsx
@@ -3,7 +3,7 @@ import { Card } from "../models/Card";
import { setFavList } from "../redux/actions/action_setFavList";
import { ImageBackground, TouchableHighlight, View } from "react-native";
import React, { useEffect } from "react";
-import {CardProps} from "../props/favprops"
+import {CardProps} from "../props/favProps"
import { FontAwesome } from '@expo/vector-icons';
import { StyleSheet} from 'react-native';
@@ -15,8 +15,7 @@ export default function Item(props: CardProps){ // a mettre dans components et d
const dispatch = useDispatch()
const HandleAddFav = (props : CardProps) => {
- console.log("add new card")
- dispatch(setFavList(props));
+ dispatch(setFavList(props));
}
return(
diff --git a/components/mainComponent.tsx b/components/mainComponent.tsx
deleted file mode 100644
index c7e5640..0000000
--- a/components/mainComponent.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { StatusBar } from 'expo-status-bar';
-import { StyleSheet, Text, View, Button } from 'react-native';
-import React, { useState } from "react";
-
-// @ts-ignore
-export default function Main(props : mainProps){
- const [count, setCount] = useState(0);
- return (
-
-
- Maman, prend la caméra ! !
-
- {count}
-
-
- );
-}
-
-
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#ffffff',
- alignItems: 'center',
- justifyContent: 'center',
- borderWidth: 5,
- borderColor : "#ff00ff",
- },
- border: {
- flex: 1,
- backgroundColor: '#ff0000',
- maxHeight : 100,
- borderWidth : 15,
- borderRadius : 15,
- borderColor : '#00ffaa',
- alignItems: 'center',
- justifyContent: 'center',
- }
-});
diff --git a/models/Card.tsx b/models/Card.tsx
index 64ee37a..64b1425 100644
--- a/models/Card.tsx
+++ b/models/Card.tsx
@@ -1,138 +1,27 @@
-import {isValidNumber} from "react-native-gesture-handler/lib/typescript/web_hammer/utils";
-import {CardSet} from "./CardSet";
-import {Type} from "./Type";
-import {Classe} from "./Classe";
export class Card {
- constructor(id: string,name :string, img : string, imgGold : string,fav : boolean = true){//,set : CardSet,type : Type,clas : Classe,rarity : string,cost : number,attack : number, health : number, desc : string,flavor : string,artist : string,collectible : boolean,elite : boolean,race : string, cropImg :string ) {
+ constructor(id: string,name :string, img : string, imgGold : string,fav : boolean = true){
this.id=id
this.name=name
- //this._set=set
- // this._type=type
- // this._class=clas
- // this._rarity=rarity
- // this._cost=cost
- // this._attack = attack
- // this._health = health
- // this._desc = desc
- // this._flavor = flavor
- // this._artist = artist
- // this._collectible = collectible
this.img = img
this.imgGold = imgGold
- // this._cropImg = cropImg
this.fav = fav
}
// ID //
-
public id;
// NAME //
public name;
-
- // private _set : CardSet;
- // get set(): CardSet{
- // return this._set
- // }
-
- // set set(value : CardSet){
- // this._set = value
- // }
-
- // private _type : Type;
- // get type():Type{
- // return this._type
- // }
- // set type(value : Type){
- // this._type=value
- // }
-
- // private _class : Classe;
-
- // get class():Classe{
- // return this._class
- // }
- // set class(value : Classe){
- // this._class=value
- // }
- // private _rarity : string
-
- // get rarity(): string {
- // return this._rarity;
- // }
-
- // set rarity(value: string) {
- // this._rarity = value ;
- // }
- // private _cost : number
-
- // get cost(): number {
- // return this._cost;
- // }
- // set cost(value: number) {
- // this._cost = value ;
- // }
-
- // private _attack : number
- // get attack(): number {
- // return this._attack;
- // }
- // set attack(value: number) {
- // this._attack = value ;
- // }
- // private _health : number
- // get health(): number {
- // return this._health;
- // }
- // set health(value: number) {
- // this._health = value ;
- // }
- // private _desc : string
- // get desc(): string {
- // return this._desc;
- // }
- // set desc(value: string) {
- // this._desc = value ;
- // }
-
- // private _flavor : string
-
- // get flavor(): string {
- // return this._flavor;
- // }
- // set flavor(value: string) {
- // this._flavor = value ;
- // }
-
- // private _artist : string
- // get artist(): string {
- // return this._artist;
- // }
- // set artist(value: string) {
- // this._artist = value ;
- // }
- // private _collectible : boolean
- // get collectible(): boolean {
- // return this._collectible;
- // }
- // set collectible(value: boolean ){
- // this._collectible = value;
- // }
-
+ //IMG//
public img;
- public imgGold;
- // private _cropImg : string
- // get cropImg(): string {
- // return this._cropImg;
- // }
- // set cropImg(value: string) {
- // this._cropImg = value;
- // }
+ //IMGGOLD//
+ public imgGold;
+ //FAV//
public fav;
}
\ No newline at end of file
diff --git a/models/CardSet.tsx b/models/CardSet.tsx
deleted file mode 100644
index 5099582..0000000
--- a/models/CardSet.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-
-export class CardSet {
-
- constructor(id: number,name : string, type : string ) {
- this._id = id
- this._name =name
- this._type = type
-
- }
-
- private _id : number
-
- get id(): number {
- return this._id
- }
-
- // NAME //
- private _name : string;
- get name(): string {
- return this._name;
- }
- set name(value: string) {
- this._name = value;
- }
-
- private _type : string;
- get type(): string {
- return this._type;
- }
- set type(value: string) {
- this._type = value;
- }
-
-
-
-
-}
\ No newline at end of file
diff --git a/models/Classe.tsx b/models/Classe.tsx
deleted file mode 100644
index fde1c57..0000000
--- a/models/Classe.tsx
+++ /dev/null
@@ -1,4 +0,0 @@
-export class Classe {
- constructor(private id : number, private name : string) {
- }
-}
\ No newline at end of file
diff --git a/models/Type.tsx b/models/Type.tsx
deleted file mode 100644
index ab44953..0000000
--- a/models/Type.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-export class Type{
-
- constructor(private id : number, private name : string) {
- }
-}
\ No newline at end of file
diff --git a/navigation/ListNavigator.tsx b/navigation/ListNavigator.tsx
deleted file mode 100644
index 47e7b3a..0000000
--- a/navigation/ListNavigator.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-// import { NavigationContainer } from '@react-navigation/native';
-// import { createStackNavigator } from '@react-navigation/stack';
-
-// import HomeScreen from '../screens/HomeScreen';
-// import ListScreen from '../screens/ListScreen';
-// import ListFav from '../screens/ListFav';
-
-
-
-
-// export default function ListNavigator() {
-// const Stack = createStackNavigator();
-// return (
-//
-//
-//
-//
-// )
-// }
\ No newline at end of file
diff --git a/navigation/Navigation.tsx b/navigation/Navigation.tsx
index 6c18b78..e117afd 100644
--- a/navigation/Navigation.tsx
+++ b/navigation/Navigation.tsx
@@ -1,20 +1,13 @@
- import { StatusBar } from 'expo-status-bar';
-import { StyleSheet, Text, View, Button } from 'react-native';
import React, { useState } from "react";
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
-
-import HomeScreen from '../screens/HomeScreen';
import ListScreen from '../screens/ListScreen';
import ListFav from '../screens/ListFav';
import TabBarIcon from '../components/TabBarIcon';
import StackNavigation from './StackNavigation';
-
-
-
export default function Navigation() {
const BottomTabNavigator = createBottomTabNavigator();
return (
diff --git a/navigation/StackNavigation.tsx b/navigation/StackNavigation.tsx
index 3c63f32..5fd776c 100644
--- a/navigation/StackNavigation.tsx
+++ b/navigation/StackNavigation.tsx
@@ -11,12 +11,10 @@ import ListFav from '../screens/ListFav';
export default function StackNavigation() {
const Stack = createStackNavigator();
return (
- //
- //
)
}
\ No newline at end of file
diff --git a/props/favprops.tsx b/props/favProps.tsx
similarity index 100%
rename from props/favprops.tsx
rename to props/favProps.tsx
diff --git a/redux/actions/actionSelection.tsx b/redux/actions/actionSelection.tsx
index 45249cf..b68c59f 100644
--- a/redux/actions/actionSelection.tsx
+++ b/redux/actions/actionSelection.tsx
@@ -1,75 +1,28 @@
import { setCardsList } from "./action_setCardsList";
-
import { Card } from "../../models/Card";
-//! se fichier devra possiblement changer de dossier !!!
-
-//! classe pour tester
-// export class Card {
-// cardId : String
-// name : String
-// manaCost : number
-// attack : number
-// health : number
-// desc : String
-
-// // constructor() {
-// // this.cardId = "cardId";
-// // this.name = "name";
-// // this.manaCost = 0;
-// // this.attack = 0;
-// // this.health = 0;
-// // this.desc = "desc";
-// // }
-
-// constructor(cardId : String, name : String, manaCost : number, attack : number, health : number, desc : String){
-// this.cardId = cardId;
-// this.name = name;
-// this.manaCost = manaCost;ADD_FAVORITE_DATA, FETCH_DATA,
-// this.attack = attack;
-// this.health = health;
-// this.desc = desc;
-// }
-
-
-// }
-
-
-//Define your action creators that will be responsible for asynchronous operations
+//Fonction chargé de l'appel à l'API
export const getAllCards = () => {
- //In order to use await your callback must be asynchronous using async keyword.
- console.log("getallcard")
+
//@ts-ignore
return async dispatch => {
- //Then perform your asynchronous operations.
try {
- //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"'
- // }ADD_FAVORITE_DATA, FETCH_DATA,
-
- //! Actualisation de l'API (16/03) :
+ method: 'GET',
headers: {
'content-length': '9508',
'content-type': 'application/json; charset=utf-8',
'etag': 'W/"74bb-d4gMlMNks7UGES3Jmn6wzUTXaLI"',
}
- //'pageSize':'100'
+
};
- //! Actualisation de l'API (16/03) :
+ //! Actualisation de l'API (19/04) :
const CardsPromise = await fetch('https://us.api.blizzard.com/hearthstone/cards?locale=en_US&access_token=EUo8Snb09AfE3zQR4CoaB71gq1q3qvSmgL', 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)
//Then use the json method to get json data from api/
const CardsListJson = await CardsPromise.json();
- //console.log(CardsListJson['cards'])
+
//@ts-ignore
@@ -79,17 +32,13 @@ export const getAllCards = () => {
elt["imageGold"] ? elt["imageGold"] : "",
)); //, elt["cardSet"], elt["type"], elt["faction"], elt["rarity"], elt["cost"], elt["attack"], elt["health"],elt["text"], elt["flavor"], elt["artist"], elt["collectible"], elt["elite"], elt["race"], elt["img"], elt["imgGold"]
//elt["cardId"] == null ? elt["cardId"] : ""
-
- //console.log("TOTO")
-
- //console.log(CardsList)
+
//call the action
dispatch(setCardsList(CardsList));
} catch (error) {
console.log('Error---------', error);
- //You can dispatch to another action if you want to display an error message in the application
- //dispatch(fetchDataRejected(error))
+
}
}
}
\ No newline at end of file
diff --git a/redux/actions/action_setCardsList.tsx b/redux/actions/action_setCardsList.tsx
index 708b5dd..2a9c7e8 100644
--- a/redux/actions/action_setCardsList.tsx
+++ b/redux/actions/action_setCardsList.tsx
@@ -1,8 +1,5 @@
-import {ADD_FAVORITE_DATA, FETCH_DATA} from '../constants';
-
-//? Changer cette importe quand la classe sera definit dans un fichier correctement.
-import {Card} from '../../models/Card'
-
+import { Card } from '../../models/Card';
+import {FETCH_DATA} from '../constants';
export const setCardsList = (List: Card[]) => {
return {
type: FETCH_DATA,
diff --git a/redux/actions/action_setFavList.tsx b/redux/actions/action_setFavList.tsx
index 8707ffa..0cfd14d 100644
--- a/redux/actions/action_setFavList.tsx
+++ b/redux/actions/action_setFavList.tsx
@@ -1,6 +1,6 @@
import { Card } from '../../models/Card';
-import { CardProps } from '../../props/favprops';
-import {ADD_FAVORITE_DATA, FETCH_DATA} from '../constants';
+import { CardProps } from '../../props/favProps';
+import {ADD_FAVORITE_DATA} from '../constants';
export const setFavList = (props : CardProps) => {
return {
diff --git a/redux/constants.tsx b/redux/constants.tsx
index 3bf354d..e48e34a 100644
--- a/redux/constants.tsx
+++ b/redux/constants.tsx
@@ -1,10 +1,6 @@
-
-
export const FETCH_DATA = "FETCH_DATA"
export const ADD_FAVORITE_DATA = "ADD_FAVORITE_DATA"
-export const DISPLAY_ALL_CARD = "DISPLAY_ALL_CARD"
-
export const SET_FAVS = "SET_FAVS"
diff --git a/redux/reducers/appReducer.tsx b/redux/reducers/appReducer.tsx
index 1d57186..8b553f9 100644
--- a/redux/reducers/appReducer.tsx
+++ b/redux/reducers/appReducer.tsx
@@ -1,4 +1,4 @@
-import { CardProps } from '../../props/favprops'
+import { CardProps } from '../../props/favProps'
import {FETCH_DATA, ADD_FAVORITE_DATA, SET_FAVS} from '../constants'
import StorageHeart from '../../service/AsyncStorage'
@@ -11,7 +11,7 @@ const initialState = {
// @ts-ignore
export default appReducer = (state = initialState, action) => {
switch (action.type) {
- case ADD_FAVORITE_DATA:
+ case ADD_FAVORITE_DATA: //Ajout d'une carte aux favoris
const a : CardProps = action.payload
if(a.route.bool ==false){
@@ -24,7 +24,6 @@ export default appReducer = (state = initialState, action) => {
//@ts-ignore
const tab = state.favoriteCards.concat([a.route.card])
- console.log(state.favoriteCards)
StorageHeart.setItem("favoriteList",tab)
return {...state, favoriteCards : tab};
}
@@ -35,11 +34,14 @@ export default appReducer = (state = initialState, action) => {
StorageHeart.setItem("favoriteList",tab)
return {...state, favoriteCards : tab };
}
- case FETCH_DATA:
+
+
+ case FETCH_DATA: //Récupération des données des cartes depuis l'API
return {...state, cards: action.payload};
- case SET_FAVS:
+
+
+ case SET_FAVS: //Récupération des favoris depuis l'async storage
//@ts-ignore
- console.log("Set_favs : ",action.payload)
return {...state, favoriteCards: action.payload}
default:
return state;
diff --git a/redux/store.tsx b/redux/store.tsx
index 367d0bf..db2dc51 100644
--- a/redux/store.tsx
+++ b/redux/store.tsx
@@ -1,7 +1,6 @@
import {configureStore} from '@reduxjs/toolkit'
import appReducer from './reducers/appReducer';
-// Reference here all your application reducers
const reducer = {
appReducer: appReducer,
}
@@ -10,7 +9,6 @@ const reducer = {
const store = configureStore({
// @ts-ignore
reducer,
-
// @ts-ignore
middleware: (getDefaultMiddleware) => getDefaultMiddleware({serializableCheck : false}), //desactive le check de la serialization (primitif)
},);
diff --git a/screens/HomeScreen.tsx b/screens/HomeScreen.tsx
index f79eea6..3920061 100644
--- a/screens/HomeScreen.tsx
+++ b/screens/HomeScreen.tsx
@@ -1,37 +1,22 @@
-
import { StyleSheet, Text, View, TouchableNativeFeedback, Image } from 'react-native';
-import { useNavigation } from '@react-navigation/native';
-import { NavigationContainer } from '@react-navigation/native';
-import StackNavigation from '../navigation/StackNavigation'
-import { Colors } from 'react-native/Libraries/NewAppScreen';
import { useDispatch } from 'react-redux';
import { useEffect } from 'react';
import { getAllCards } from "../redux/actions/actionSelection"
import StorageHeart from '../service/AsyncStorage';
-import { setFavList } from '../redux/actions/action_setFavList';
import { setList } from '../redux/actions/action_setFavs';
-import { Card } from '../models/Card';
-//import { setList } from '../redux/actions/action_setList';
-
-
-
-
-
+import Navigation from '../navigation/Navigation';
// @ts-ignore //
export default function HomeScreen({navigation}) {
-
-
const dispatch = useDispatch();
+ //chargement des listes
useEffect(() => {
- console.log("USEEFFECT")
+
const loadFavCards = async () => {
//@ts-ignore
- //await dispatch(getAllCards());
const list = await StorageHeart.getItem("favoriteList")
- console.log("async favs : ",list)
//@ts-ignore
dispatch(setList(list))
@@ -39,7 +24,7 @@ export default function HomeScreen({navigation}) {
loadFavCards();
}, [dispatch]);
useEffect(() => {
- console.log("USEEFFECT")
+
const loadCards = async () => {
//@ts-ignore
await dispatch(getAllCards());
@@ -47,10 +32,10 @@ export default function HomeScreen({navigation}) {
loadCards();
}, [dispatch]);
+ const tabNav = Navigation()
-
-
+ // affichage de la homePage
return (
@@ -64,7 +49,7 @@ export default function HomeScreen({navigation}) {
- navigation.navigate("ListScreen")}>
+ navigation.navigate("ListScreen")}>
List
@@ -107,10 +92,10 @@ export default function HomeScreen({navigation}) {
},
ButtonStyle :{
- backgroundColor: "#2E8AE6",
+ backgroundColor: "#F5F5F5",
borderRadius: 15,
padding: 20,
- color: "white",
+ color: "black",
fontSize : 36,
width: "45%",
textAlign: 'center',
diff --git a/screens/ListFav.tsx b/screens/ListFav.tsx
index 6e2768a..72f2632 100644
--- a/screens/ListFav.tsx
+++ b/screens/ListFav.tsx
@@ -1,25 +1,12 @@
-import { StyleSheet, Text, View, Button, TouchableHighlight, TextInput, ImageBackground } from 'react-native';
-import { StatusBar } from 'expo-status-bar';
-import React, { useState, useEffect } from "react";
+import { StyleSheet, View, TouchableHighlight, TextInput } from 'react-native';
+import React, { useState} from "react";
import { FlatList } from 'react-native-gesture-handler';
-import {useDispatch, useSelector} from 'react-redux';
-import { FontAwesome } from '@expo/vector-icons';
-import { ThunkAction } from 'redux-thunk';
+import {useSelector} from 'react-redux';
-
-//? possiblement à supprimer
-import { getAllCards } from "../redux/actions/actionSelection"
import { Card } from '../models/Card';
-import { Image } from 'react-native';
-import { ImageURISource } from 'react-native';
import Item from '../components/ListItemComponent';
-//* Icons
-// import { BiSearchAlt } from 'react-icons';
-
-//* Components
-
@@ -28,7 +15,6 @@ export default function ListScreen({navigation}){
//@ts-ignore
var nList : Card[] = useSelector(state => state.appReducer.favoriteCards);
- console.log(" favs : ",nList)
const [searchValue, setSearchValue] = useState('');
diff --git a/screens/ListScreen.tsx b/screens/ListScreen.tsx
index 863029a..e30781a 100644
--- a/screens/ListScreen.tsx
+++ b/screens/ListScreen.tsx
@@ -1,49 +1,19 @@
-import { StyleSheet, Text, View, Button, TouchableHighlight, TextInput, ImageBackground, LogBox } from 'react-native';
-import { StatusBar } from 'expo-status-bar';
-import React, { useState, useEffect } from "react";
+import { StyleSheet,View,TouchableHighlight, TextInput} from 'react-native';
+import React, { useState} from "react";
import { FlatList } from 'react-native-gesture-handler';
-import {useDispatch, useSelector} from 'react-redux';
-import { FontAwesome } from '@expo/vector-icons';
-import { ThunkAction } from 'redux-thunk';
-
-
-//? possiblement à supprimer
-import { getAllCards } from "../redux/actions/actionSelection"
+import {useSelector} from 'react-redux';
import { Card } from '../models/Card';
-import { Image } from 'react-native';
-import { ImageURISource } from 'react-native';
-//* Icons
-// import { BiSearchAlt } from 'react-icons';
//* Components
-import { setFavList } from '../redux/actions/action_setFavList';
import Item from '../components/ListItemComponent';
//@ts-ignore
export default function ListScreen({navigation}){
- const [count, setCount] = useState(0);
-
- // // Initialize the binding content with the application initial state
//@ts-ignore
var nList = useSelector(state => state.appReducer.cards);
- // Create a const that will hold the react-redux events dispatcher
- const dispatch = useDispatch();
-
- // Let's define a hook that will be used to update the rendered state after the return will be called
- // You cannot perform side-effects outside of a useEffect hook
-
- // useEffect(() => {
- // console.log("USEEFFECT")
- // const loadCards = async () => {
- // //@ts-ignore
- // await dispatch(getAllCards());
- // };
- // loadCards();
- // }, [dispatch]);
-
-
+
//* Search :
const [searchValue, setSearchValue] = useState('');
diff --git a/service/AsyncStorage.tsx b/service/AsyncStorage.tsx
index 65a16e3..f2ce631 100644
--- a/service/AsyncStorage.tsx
+++ b/service/AsyncStorage.tsx
@@ -7,7 +7,7 @@ export default class StorageHeart {
static async getItem(key: string): Promise {
try {
const value = await AsyncStorage.getItem(key);
- console.log("load")
+
if (value !== null) {
return JSON.parse(value);
}
@@ -20,7 +20,7 @@ export default class StorageHeart {
static async setItem(key: string, value: any): Promise {
try {
await AsyncStorage.setItem(key, JSON.stringify(value));
- console.log("save")
+
} catch (e) {
console.error(`AsyncStorage setItem error: ${e}`);
}