diff --git a/bob_party/src/components/TopBar.tsx b/bob_party/src/components/TopBar.tsx index 298ed2d..928652a 100644 --- a/bob_party/src/components/TopBar.tsx +++ b/bob_party/src/components/TopBar.tsx @@ -3,11 +3,14 @@ import { Pressable, Image, Text, View} from "react-native" import { Skin } from "../core/Skin" import React from "react" import { SkinComponent } from "./Skin" +import { User } from "../core/user" /* Import the correct stylesheet */ import styles from './style/TopBar.style'; +import { useSelector } from "react-redux" +import { RootState } from "../redux/store" /* Images required @@ -23,9 +26,12 @@ export const TopBar : * state : optional parameter that indicates from which screen the component has been called (the string must be the name of the screen) */ -FC<{skin?: Skin, nav: any, state?: string}> = -({skin, nav, state}) => +FC<{nav: any, state?: string}> = +({nav, state}) => { + + const currentUser = useSelector((state: RootState) => state.currentUser.value)[0]; + /* The display of this component depends of the screen from where it has been called: * From the Settings (icon) : Name of the page + cross button * From other : skin + Title + parameters icon @@ -47,7 +53,7 @@ FC<{skin?: Skin, nav: any, state?: string}> = return ( nav.navigate('ProfileTab', {screen: 'Profile'})}> - + BOB PARTY nav.navigate('Settings')}> diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index 01fa2ae..5964920 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -1,32 +1,28 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View, Text} from 'react-native' +import {View} from 'react-native' import React from 'react'; -import stylesScreen from './style/screens.style' -import { Skin } from '../core/skin'; +import stylesScreen from './style/screens.style'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; -import { ScreenIndicator } from '../components/ScreenIndicator'; -import { User } from '../core/user'; import { FlatList } from 'react-native-gesture-handler'; import { ConversationComponent } from '../components/ConversationComponent'; - -import tabSkinApp from '../constSkin'; -import tabConv from '../constCov'; - - -const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); +import { useSelector } from 'react-redux'; +import { RootState } from '../redux/store'; function Chat(props: { navigation: any; }) { const { navigation } = props - return ( + + const currentUser = useSelector((state: RootState) => state.currentUser.value[0]); + + return ( } /> diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx index 73d774b..6126942 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -1,46 +1,46 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View, ImageSourcePropType} from 'react-native' +import { View} from 'react-native' import React from 'react'; import stylesScreen from './style/screens.style' -import { User } from '../core/user'; -import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { Conversation } from '../core/conversation'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; -import tabSkinApp from '../constSkin'; -import { GameSolo } from '../core/gameSolo'; - +import { useSelector } from 'react-redux'; +import { RootState } from '../redux/store'; //const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", ); let tabConv:Conversation[]=[]; -const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); + function Home(props: { navigation: any; }) { const { navigation } = props - return ( - - - - navigation.navigate('GameChoice')} + + const currentUser = useSelector((state: RootState) => state.currentUser.value[0]); + + return ( + + - navigation.navigate('GameChoice')} + + navigation.navigate('GameChoice')} + /> + navigation.navigate('GameChoice')} + /> + + - - ); } diff --git a/bob_party/src/screens/Profile.tsx b/bob_party/src/screens/Profile.tsx index 631e9e9..5007d82 100644 --- a/bob_party/src/screens/Profile.tsx +++ b/bob_party/src/screens/Profile.tsx @@ -1,46 +1,49 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View, Text, Image} from 'react-native' +import { View, Text, Image} from 'react-native' import React from 'react'; import stylesScreen from './style/screens.style' import styles from './style/Profile.style' import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { SkinComponent } from '../components/Skin'; -import { User } from '../core/user'; -import tabSkinApp from '../constSkin'; -import tabConv from '../constCov' import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ScreenIndicator } from '../components/ScreenIndicator'; +import { useSelector } from 'react-redux'; +import { RootState } from '../redux/store'; const coin = require('../../assets/Icons/Coin.png') -const UserActu=new User("14", "leBg","MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); + function Profile(props: { navigation: any; }) { const { navigation } = props + + const currentUser = useSelector((state: RootState) => state.currentUser.value)[0]; + return ( + {currentUser.getUsername()} - {UserActu.getCurrentCoins()} + {currentUser.getCurrentCoins()} - + navigation.navigate('SkinList')} title='Changer de skin' state='Profile'/> - Total de BobCoin gagnés: {UserActu.getTotalCoins()} + Total de BobCoin gagnés: {currentUser.getTotalCoins()} state.currentUser.value[0]); + return ( diff --git a/bob_party/src/screens/Store.tsx b/bob_party/src/screens/Store.tsx index 662d1c3..3221278 100644 --- a/bob_party/src/screens/Store.tsx +++ b/bob_party/src/screens/Store.tsx @@ -1,28 +1,30 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View} from 'react-native' +import { View } from 'react-native' import React from 'react'; -import stylesScreen from './style/screens.style' -import { Skin } from '../core/skin'; +import stylesScreen from './style/screens.style'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { FlatList } from 'react-native-gesture-handler'; import { SkinComponent } from '../components/Skin'; import { ScreenIndicator } from '../components/ScreenIndicator'; - -import tabSkinApp from '../constSkin'; +import { useSelector } from 'react-redux'; +import { RootState } from '../redux/store'; function Store(props: { navigation: any; }) { - const { navigation } = props - return ( + const { navigation } = props + + const currentUser = useSelector((state: RootState) => state.currentUser.value[0]); + + return ( item.getSkinName()}