Ajout classe card simple

pull/2/head
Corentin RICHARD 2 years ago
parent f222fd03a8
commit 0722b3d0ae

@ -8,7 +8,7 @@ import StackNavigation from './navigation/StackNavigation';
import { createStackNavigator } from '@react-navigation/stack';
// Import your application store
import store from "./redux/store";
//import store from "./redux/store";
import {
@ -18,25 +18,25 @@ import {
import { Provider } from 'react-redux';
export default function App() {
//safearea
//mettre le navigateur ayant le princ
return (
<SafeAreaProvider>
<Navigation/>
</SafeAreaProvider>
);
}
// export default function App() {
// //safearea
// //mettre le navigateur ayant le princ
// return (
// <>
// {/* Bind your application store to the Provider store */}
// {/* <Provider store={store}> */}
// <SafeAreaProvider>
// <Navigation/>
// </SafeAreaProvider>
// {/* </Provider> */}
// </>
// );
// }
export default function App() {
return (
<>
{/* Bind your application store to the Provider store */}
<Provider store={store}>
<SafeAreaProvider>
<Navigation/>
</SafeAreaProvider>
</Provider>
</>
);
}

@ -2,6 +2,7 @@ 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 (

@ -1,14 +1,14 @@
class ApiDataManager{
// export class ApiDataManager{
public async getCards() : Promise<String[]> {
// public async getCards() : Promise<String[]> {
const CardPromise = await fetch('https://omgvamp-hearthstone-v1.p.rapidapi.com/cards')
// const CardPromise = await fetch('https://omgvamp-hearthstone-v1.p.rapidapi.com/cards')
const CardListJson = await CardPromise.json();
const CardList: String[] = Array.of(CardListJson);
return CardList;
}
}
// const CardListJson = await CardPromise.json();
// const CardList: String[] = Array.of(CardListJson);
// return CardList;
// }
// }

@ -1,11 +1,12 @@
class StubLib {
import { Card } from "../models/Card"
export class StubLib {
public getCards(): Card[] {
const NOUNOURS_LIST : Card[] = [
new Card("Chewie"),
new Card("Rupert"),
new Card("Ronflex"),
new Card("c1","Chewie"),
new Card("r2","Rupert"),
new Card("a3","Ronflex"),
]
return NOUNOURS_LIST
}

@ -1,15 +1,165 @@
class Card {
import {isValidNumber} from "react-native-gesture-handler/lib/typescript/web_hammer/utils";
constructor(name :string) {
export class Card {
constructor(id: string,name :string,set : string,type : string,faction : string,rarity : string,cost : number,attack : number, health : number, desc : string,flavor : string,artist : string,collectible : boolean,elite : boolean,race : string, img : string, imgGold : string) {
this._id=id
this._name=name
this._set=set
this._type=type
this._faction=faction
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._elite = elite
this._race = race
this._img = img
this._imgGold = imgGold
}
// ID //
private _id : string;
get id(): string {
return this._id
}
// NAME //
private _name : string;
get name(): string {
return this._name;
}
set name(value: string) {
this._name = value;
}
private _name : string;
private _set : string;
get set(): string{
return this._set
}
set set(value : string){
this._set = value
}
private _type : string;
get type():string{
return this._type
}
set type(value : string){
this._type=value
}
private _faction : string;
get faction():string{
return this._faction
}
set faction(value : string){
this._faction=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;
}
private _elite : boolean
get elite(): boolean {
return this._elite;
}
set elite(value: boolean) {
this._elite = value ;
}
private _race : string
get race(): string {
return this._race;
}
set race(value: string) {
this._race = value ;
}
private _img : string
get img(): string {
return this._img;
}
set img(value: string) {
this._img = value ;
}
private _imgGold : string
get imgGold(): string {
return this._imgGold;
}
set imgGold(value: string) {
this._imgGold = value ;
}
}

@ -20,7 +20,7 @@
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "~2.8.0",
"react-native-safe-area-context": "^4.5.0",
"react-native-safe-area-context": "4.4.1",
"react-native-web": "~0.18.9",
"react-redux": "^8.0.5",
"redux": "^4.2.1"

@ -1,14 +0,0 @@
import {configureStore} from '@reduxjs/toolkit'
import appReducer from './reducers/appReducer';
// Reference here all your application reducers
const reducer = {
appReducer: appReducer,
}
// @ts-ignore
const store = configureStore({
reducer,
},);
export default store;

@ -3,34 +3,8 @@ import { StyleSheet, Text, View, Button } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import React, { useState } from "react";
import { FlatList } from 'react-native-gesture-handler';
export const DATA = [
{
id: '1',
title: "premier élément",
},
{
id: '2',
title: "second élément",
},
{
id: '3',
title: "élément",
},
{
id: '4',
title: "Rick",
},
{
id: '5',
title: "Corentin",
},
{
id: '10',
title: "dernier élément",
},
];
import { StubLib } from '../data/stub';
import { Card } from '../models/Card';
//@ts-ignore
const Item = ({title}) => (
@ -39,23 +13,23 @@ const Item = ({title}) => (
</View>
);
export default async function Main() {
export default function Main() {
const [count, setCount] = useState(0);
const {getCards} = new StubLib();
const list: Card[] = getCards();
const req = fetch('https://omgvamp-hearthstone-v1.p.rapidapi.com/cards')
return (
<View style={styles.container}>
<View style={styles.border}>
<Text>Maman, prend la caméra ! !</Text>
<StatusBar style="auto"/>
<Text>{count}</Text>
<Text>{list.at(0)?.name}</Text>
<Button onPress={() => setCount(count + 1)} title="+1"/>
</View>
<FlatList data={DATA}
renderItem={({item}) => <Item title={item.title} />}
<Text>{}</Text>
<FlatList data={list}
renderItem={({item}) => <Item title={item.name} />}
keyExtractor={item => item.id}/>
</View>
);
}

@ -1781,7 +1781,7 @@
"@react-navigation/stack@^6.3.14":
version "6.3.14"
resolved "https://registry.npmjs.org/@react-navigation/stack/-/stack-6.3.14.tgz"
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-6.3.14.tgz#de282d8bc5616bfb12fa4c89f18792193563fb7a"
integrity sha512-a1ivkESWsZYimUQHr3TA2Nu2g3FALEyJqQ8bJxXkEcBp+5cglOakhfKbbCuNV2knC/9zjUmP9N0Q3Jh3fK9nfw==
dependencies:
"@react-navigation/elements" "^1.3.15"
@ -5492,10 +5492,10 @@ react-native-gradle-plugin@^0.70.3:
resolved "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz"
integrity sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A==
react-native-safe-area-context@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.5.0.tgz"
integrity sha512-0WORnk9SkREGUg2V7jHZbuN5x4vcxj/1B0QOcXJjdYWrzZHgLcUzYWWIUecUPJh747Mwjt/42RZDOaFn3L8kPQ==
react-native-safe-area-context@4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.4.1.tgz#239c60b8a9a80eac70a38a822b04c0f1d15ffc01"
integrity sha512-N9XTjiuD73ZpVlejHrUWIFZc+6Z14co1K/p1IFMkImU7+avD69F3y+lhkqA2hN/+vljdZrBSiOwXPkuo43nFQA==
react-native-web@~0.18.9:
version "0.18.11"

Loading…
Cancel
Save