diff --git a/App.tsx b/App.tsx index ff2e2bd..2fb9515 100644 --- a/App.tsx +++ b/App.tsx @@ -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 { diff --git a/data/ApiDataManager.tsx b/data/ApiDataManager.tsx new file mode 100644 index 0000000..a08be79 --- /dev/null +++ b/data/ApiDataManager.tsx @@ -0,0 +1,14 @@ + +// export class ApiDataManager{ + + +// public async getCards() : Promise { + + +// 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; +// } +// } diff --git a/data/stub.ts b/data/stub.ts index c2c79dd..af96cf8 100644 --- a/data/stub.ts +++ b/data/stub.ts @@ -1,188 +1,14 @@ -export class City { - private _name: string; - private _latitude: number; - private _longitude: number; - - constructor(name: string, latitude: number, longitude: number) { - this._name = name; - this._latitude = latitude; - this._longitude = longitude; - } - - get name(): string { - return this._name; - } - - set name(value: string) { - this._name = value; - } - - get latitude(): number { - return this._latitude; - } - - set latitude(value: number) { - this._latitude = value; - } - - get longitude(): number { - return this._longitude; - } - - set longitude(value: number) { - this._longitude = value; - } +import { Card } from "../models/Card" + +export class StubLib { + + public getCards(): Card[] { + const NOUNOURS_LIST : Card[] = [ + new Card("c1","Chewie"), + new Card("r2","Rupert"), + new Card("a3","Ronflex"), + ] + return NOUNOURS_LIST + } } -export class Weather { - private _at: string; - private _visibility: number; - private _weatherType: string; - private _weatherDescription: string; - private _temperature: number; - private _temperatureFeelsLike: number; - private _humidity: number; - private _windSpeed: number; - private _pressure: number; - private _city: City; - - constructor(at: string, visibility: number, weatherType: string, weatherDescription: string, temperature: number, temperatureFeelsLike: number, humidity: number, windSpeed: number, pressure: number, city: City) { - this._at = at; - this._visibility = visibility; - this._weatherType = weatherType; - this._weatherDescription = weatherDescription; - this._temperature = temperature; - this._temperatureFeelsLike = temperatureFeelsLike; - this._humidity = humidity; - this._windSpeed = windSpeed; - this._pressure = pressure; - this._city = city; - } - - get at(): string { - return this._at; - } - - set at(value: string) { - this._at = value; - } - - get visibility(): number { - return this._visibility; - } - - set visibility(value: number) { - this._visibility = value; - } - - get weatherType(): string { - return this._weatherType; - } - - set weatherType(value: string) { - this._weatherType = value; - } - - get weatherDescription(): string { - return this._weatherDescription; - } - - set weatherDescription(value: string) { - this._weatherDescription = value; - } - - get temperature(): number { - return this._temperature; - } - - set temperature(value: number) { - this._temperature = value; - } - - get temperatureFeelsLike(): number { - return this._temperatureFeelsLike; - } - - set temperatureFeelsLike(value: number) { - this._temperatureFeelsLike = value; - } - - get humidity(): number { - return this._humidity; - } - - set humidity(value: number) { - this._humidity = value; - } - - get windSpeed(): number { - return this._windSpeed; - } - - set windSpeed(value: number) { - this._windSpeed = value; - } - - get pressure(): number { - return this._pressure; - } - - set pressure(value: number) { - this._pressure = value; - } - - get city(): City { - return this._city; - } - - set city(value: City) { - this._city = value; - } -} - -export const CITIES_DATA: City[] = [ - new City("Paris", 48.866667, 2.333333), - new City("Clermont-Ferrand", 45.777222, 3.087025), - new City("Lyon", 45.764043, 4.835659), - new City("Marseille", 43.296482, 5.36978), - new City("Bruxelles", 50.85034, 4.35171), -]; - -export const FAVORITE_CITY_DATA = - new City("Clermont-Ferrand", 45.777222, 3.087025); - -export const DEFAULT_SELECTED_CITY_DATA: City = - new City("Paris", 48.866667, 2.333333); - -export const WEATHER_DATA: Weather[] = [ - new Weather("2023-01-22 09:55:59", 10000, "Nuageux", - "couvert", 0.52, -4.34, - 82, 5.14, 1032, - new City("Paris", 48.866667, 2.333333) - ), - new Weather("2023-01-22 09:55:59", 10000, "Nuageux", - "couvert", 0.52, -4.34, - 82, 5.14, 1032, - new City("Clermont-Ferrand", 45.777222, 3.087025) - ), - new Weather("2023-01-22 09:55:59", 10000, "Nuageux", - "couvert", 0.52, -4.34, - 82, 5.14, 1032, - new City("Lyon", 45.764043, 4.835659) - ), - new Weather("2023-01-22 09:55:59", 10000, "Nuageux", - "couvert", 0.52, -4.34, - 82, 5.14, 1032, - new City("Marseille", 43.296482, 5.36978) - ), - new Weather("2023-01-22 09:55:59", 10000, "Nuageux", - "couvert", 0.52, -4.34, - 82, 5.14, 1032, - new City("Bruxelles", 50.85034, 4.35171) - ), -]; - -export const getCurrentWeather = (cityName: string) => { - if (cityName === undefined) return {}; - return WEATHER_DATA.filter(elt => elt.city.name === cityName)[0]; -} diff --git a/models/Card.tsx b/models/Card.tsx new file mode 100644 index 0000000..ea3c82e --- /dev/null +++ b/models/Card.tsx @@ -0,0 +1,165 @@ +import {isValidNumber} from "react-native-gesture-handler/lib/typescript/web_hammer/utils"; + +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 _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 ; + } + +} \ No newline at end of file diff --git a/screens/ListScreen.tsx b/screens/ListScreen.tsx index fa150d0..c4018b7 100644 --- a/screens/ListScreen.tsx +++ b/screens/ListScreen.tsx @@ -11,34 +11,8 @@ import { ThunkAction } from 'redux-thunk'; //? possiblement à supprimer import { Card, getAllCards } from "../redux/actions/getAllCards" - - -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}) => ( @@ -71,16 +45,16 @@ export default function ListScreen({navigation}){ // loadCards(); // }, [dispatch]); + const {getCards} = new StubLib(); + const list: Card[] = getCards(); + const req = fetch('https://omgvamp-hearthstone-v1.p.rapidapi.com/cards') + + return ( - - Maman, prend la caméra ! ! - - {count} -