changement des villes, on inclut les pays maintenant 🇫🇷 🇩🇪 🇮🇹

brancheRedux
Paul SQUIZZATO 2 years ago
parent cf253b482a
commit 7657952e1f

@ -2,18 +2,27 @@ import { StatusBar } from 'expo-status-bar';
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
import HomePage from './src/screen/HomePage';
import store from "./redux/store";
import MainTab from './src/navigator/Navigator';
export default function App() {
return (
/*<>
{}
<Provider store={store}>
<SafeAreaView style={styles.topSafeArea}/>
<SafeAreaView style={styles.mainSafeArea}>
<MainTab></MainTab>
</SafeAreaView>
</Provider>
</>*/
<>
<SafeAreaView style={styles.topSafeArea}/>
<SafeAreaView style={styles.mainSafeArea}>
<MainTab></MainTab>
</SafeAreaView>
<SafeAreaView style={styles.topSafeArea}/>
<SafeAreaView style={styles.mainSafeArea}>
<MainTab></MainTab>
</SafeAreaView>
</>
);
}

@ -2,11 +2,13 @@ export class City {
private _name: string;
private _latitude: number;
private _longitude: number;
private _pays: string;
constructor(name: string, latitude: number, longitude: number) {
constructor(name: string, latitude: number, longitude: number, pays: string) {
this._name = name;
this._latitude = latitude;
this._longitude = longitude;
this._pays = pays;
}
get name(): string {
@ -32,6 +34,14 @@ export class City {
set longitude(value: number) {
this._longitude = value;
}
get pays(): string {
return this._pays;
}
set pays(value: string) {
this._pays = value;
}
}
export class Weather {
@ -141,11 +151,11 @@ export class Weather {
}
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),
new City("Paris", 48.866667, 2.333333,"France"),
new City("Clermont-Ferrand", 45.777222, 3.087025,"France"),
new City("Lyon", 45.764043, 4.835659,"France"),
new City("Marseille", 43.296482, 5.36978,"France"),
new City("Bruxelles", 50.85034, 4.35171,"France"),
];
export const FAVORITE_CITY_DATA =
@ -158,27 +168,27 @@ export const WEATHER_DATA: Weather[] = [
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 7, -4.34,
82, 5.14, 1032,
new City("Paris", 48.866667, 2.333333)
CITIES_DATA[0]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 5, -4.34,
82, 5.14, 1032,
new City("Clermont-Ferrand", 45.777222, 3.087025)
CITIES_DATA[1]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 6, -4.34,
82, 5.14, 1032,
new City("Lyon", 45.764043, 4.835659)
CITIES_DATA[2]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 10, -4.34,
82, 5.14, 1032,
new City("Marseille", 43.296482, 5.36978)
CITIES_DATA[3]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 9, -4.34,
82, 5.14, 1032,
new City("Bruxelles", 50.85034, 4.35171)
CITIES_DATA[4]
),
];

@ -0,0 +1,8 @@
import {FETCH_VILLES} from '../constants';
export const setVilleCherchee = (nomVille: string)=>{
return {
type: FETCH_VILLES,
payload: nomVille,
};
}

@ -16,27 +16,27 @@ export const WEATHER_DATA: Weather[] = [
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 7, -4.34,
82, 5.14, 1032,
new City("Paris", 48.866667, 2.333333)
CITIES_DATA[0]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 5, -4.34,
82, 5.14, 1032,
new City("Clermont-Ferrand", 45.777222, 3.087025)
CITIES_DATA[1]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 6, -4.34,
82, 5.14, 1032,
new City("Lyon", 45.764043, 4.835659)
CITIES_DATA[2]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 10, -4.34,
82, 5.14, 1032,
new City("Marseille", 43.296482, 5.36978)
CITIES_DATA[3]
),
new Weather("2023-01-22 09:55:59", 10000, "Nuageux",
"couvert", 9, -4.34,
82, 5.14, 1032,
new City("Bruxelles", 50.85034, 4.35171)
CITIES_DATA[4]
),
];

@ -8,7 +8,7 @@ export const getCityApi = (cityName:string) =>{
const response = await fetch(url);
const json = await response.json();
const cities: City[] = json["results"].map(v => new City(v["name"],v["latitude"],v["longitude"]));
dispatch(cities[0]);
dispatch(cities);
} catch (error) {
console.log("probleme : ",error);
}

@ -0,0 +1,12 @@
const initialState = {
villes: [],
}
export default villeRechercheReducer = (state = initialState, action) => {
switch (action.type) {
case FETCH_VILLES:
return {...state, villes: state.villes.push(action.payload)};
default:
return state;
}
}

@ -1,13 +0,0 @@
const initialState = {
villes: [],
}
export default appReducer = (state = initialState, action) => {
switch (action.type) {
case FETCH_VILLE:
// @ts-ignore
return {...state, villes: action.payload};
default:
return state;
}
}

@ -1,9 +1,11 @@
import {configureStore} from '@reduxjs/toolkit'
import appReducer from './reducers/appReducer';
import VilleRechercheReducer from './reducers/VilleRechercheReducer';
// Reference here all your application reducers
const reducerVille = {
const reducer = {
appReducer: appReducer,
VilleRechercheReducer: VilleRechercheReducer,
}
// @ts-ignore
Loading…
Cancel
Save