diff --git a/bob_party/assets/Icons/Coin.png b/bob_party/assets/Icons/Coin.png new file mode 100644 index 0000000..ca275e8 Binary files /dev/null and b/bob_party/assets/Icons/Coin.png differ diff --git a/bob_party/assets/Icons/Selected/SChat.png b/bob_party/assets/Icons/Selected/SChat.png index 3d5d289..68675b6 100644 Binary files a/bob_party/assets/Icons/Selected/SChat.png and b/bob_party/assets/Icons/Selected/SChat.png differ diff --git a/bob_party/assets/Icons/Selected/SGamepad.png b/bob_party/assets/Icons/Selected/SGamepad.png index be83964..3a898f5 100644 Binary files a/bob_party/assets/Icons/Selected/SGamepad.png and b/bob_party/assets/Icons/Selected/SGamepad.png differ diff --git a/bob_party/assets/Icons/Selected/SStore.png b/bob_party/assets/Icons/Selected/SStore.png index a10b982..7a33610 100644 Binary files a/bob_party/assets/Icons/Selected/SStore.png and b/bob_party/assets/Icons/Selected/SStore.png differ diff --git a/bob_party/assets/Icons/UnSelected/Chat.png b/bob_party/assets/Icons/UnSelected/Chat.png index 118277b..e1d0fbe 100644 Binary files a/bob_party/assets/Icons/UnSelected/Chat.png and b/bob_party/assets/Icons/UnSelected/Chat.png differ diff --git a/bob_party/assets/Icons/UnSelected/Cogs.png b/bob_party/assets/Icons/UnSelected/Cogs.png index 66bb3b8..0c2828e 100644 Binary files a/bob_party/assets/Icons/UnSelected/Cogs.png and b/bob_party/assets/Icons/UnSelected/Cogs.png differ diff --git a/bob_party/assets/Icons/UnSelected/Cross.png b/bob_party/assets/Icons/UnSelected/Cross.png index 54fb273..b5c9246 100644 Binary files a/bob_party/assets/Icons/UnSelected/Cross.png and b/bob_party/assets/Icons/UnSelected/Cross.png differ diff --git a/bob_party/assets/Icons/UnSelected/Gamepad.png b/bob_party/assets/Icons/UnSelected/Gamepad.png index fea60ee..4721a00 100644 Binary files a/bob_party/assets/Icons/UnSelected/Gamepad.png and b/bob_party/assets/Icons/UnSelected/Gamepad.png differ diff --git a/bob_party/assets/Icons/UnSelected/Store.png b/bob_party/assets/Icons/UnSelected/Store.png index 7af54fd..53acb67 100644 Binary files a/bob_party/assets/Icons/UnSelected/Store.png and b/bob_party/assets/Icons/UnSelected/Store.png differ diff --git a/bob_party/package.json b/bob_party/package.json index e71c9e9..7bf37f0 100644 --- a/bob_party/package.json +++ b/bob_party/package.json @@ -14,13 +14,13 @@ "@react-navigation/stack": "^6.3.2", "expo": "^46.0.15", "expo-status-bar": "~1.4.0", - "jest": "^29.1.2", + "jest": "^26.6.3", "node": "^18.10.0", "react": "18.0.0", "react-dom": "18.0.0", "react-native": "^0.69.6", - "react-native-gesture-handler": "^2.7.1", - "react-native-safe-area-context": "^4.4.1", + "react-native-gesture-handler": "~2.5.0", + "react-native-safe-area-context": "4.3.1", "react-native-web": "~0.18.7" }, "devDependencies": { diff --git a/bob_party/src/components/BotBar.tsx b/bob_party/src/components/BotBar.tsx index 09d9195..439906f 100644 --- a/bob_party/src/components/BotBar.tsx +++ b/bob_party/src/components/BotBar.tsx @@ -1,30 +1,87 @@ import { FC, ReactNode } from "react" -import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import { Pressable, Image, View} from "react-native" import React from "react" +/* + Importing the correct stylesheet +*/ +import styles from './style/BotBar.style'; + +/* + Images that are required to create a bottom bar +*/ + +/* + Icons when the corresponding screen is not displayed (white ones) +*/ +const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png'); +const message = require('../../assets/Icons/UnSelected/Chat.png'); +const store = require('../../assets/Icons/UnSelected/Store.png'); + +/* + Icons when the corresponding screen is displayed (blue ones) +*/ +const sgamepad = require('../../assets/Icons/Selected/SGamepad.png'); +const smessage = require('../../assets/Icons/Selected/SChat.png'); +const sstore = require('../../assets/Icons/Selected/SStore.png'); + export const BotBar : -FC<{messages:ImageSourcePropType, games: ImageSourcePropType, shop: ImageSourcePropType, style: ImageStyle, styleStore: ImageStyle, nav: any, styleBar : any}> = -({messages, games, shop,style, styleStore, nav,styleBar}) => +/* Parameters : + * nav : tool needed to allow the navigation between the screens + * state : optional parameter that indicates from which screen the component has been called + (the string must be the name of the screen) +*/ +FC<{nav: any, state?: String}> = +({nav, state}) => { + /* + By default, all the images are the white ones + */ + var imgLeft=message, imgMid=gamepad, imgRight=store + + /* + For each screen corresponding to a screen of the bottom bar, + we need to change one of the icons to the corresponding blue one + (for example, when the chat screen is displayed, + the icon of the messages must switch to the blue one) + */ + switch (state) { + case 'Home': + imgMid = sgamepad + break; + case 'Chat': + imgLeft = smessage + break; + case 'Store': + imgRight = sstore + break; + default: + break; + } + + /* + Once the icons are correctly attributed, + the function can display the component + */ return ( - + nav.navigate('ChatTab')}> - nav.navigate('HomeTab')}> + {nav.navigate('HomeTab', {screen: 'Home'})}}> nav.navigate('StoreTab')}> diff --git a/bob_party/src/components/ButtonChangeSkin.tsx b/bob_party/src/components/ButtonChangeSkin.tsx new file mode 100644 index 0000000..e9e72c4 --- /dev/null +++ b/bob_party/src/components/ButtonChangeSkin.tsx @@ -0,0 +1,16 @@ +import { FC} from "react" +import { Pressable, Text} from "react-native" +import React from "react" +import styles from "./style/ButtonChangeSkin.style" + +export const ButtonChangeSkin: +FC<{ onPress: any;}> += +({onPress}) => + { + return ( + + Changer de skin + + ); + } \ No newline at end of file diff --git a/bob_party/src/components/ButtonGameTypeChoice.tsx b/bob_party/src/components/ButtonGameTypeChoice.tsx new file mode 100644 index 0000000..2cf0e5e --- /dev/null +++ b/bob_party/src/components/ButtonGameTypeChoice.tsx @@ -0,0 +1,23 @@ +import { FC} from "react" +import { Pressable, Text} from "react-native" +import React from "react" +/* + Importing the corresponding stylesheet +*/ +import styles from "./style/ButtonGameTypeChoice.style" + +export const ButtonGameTypeChoice: +/* Parameters: + * onPress : function that must be called when the button has been clicked + * title : optional text that would be in the button +*/ +FC<{ onPress: any; title?: any | undefined; }> += +({onPress,title}) => + { + return ( + + {title} + + ); + } \ No newline at end of file diff --git a/bob_party/src/components/ConversationComponent.tsx b/bob_party/src/components/ConversationComponent.tsx new file mode 100644 index 0000000..254276c --- /dev/null +++ b/bob_party/src/components/ConversationComponent.tsx @@ -0,0 +1,42 @@ +import { FC, ReactNode } from "react" +import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import React from "react" +import { Skin } from "../core/skin" +import { Conversation } from "../core/conversation" + +/* + Importing the correct stylesheet +*/ +import styles from "./style/ConverstationComponent.style" +import { SkinComponent } from "./Skin" + +export const ConversationComponent : +/* Parameters : + * skin : Skin to be displayed + * state : Indicates from wich screen the component has been called +*/ +FC<{conv: Conversation, state: String}> = +({conv, state}) => +{ + /* The display of this component depends of the screen from where it has been called: + * From the TopBar (icon) : Small image in a circle + * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin + * From the profile (profile) : Name + Image, Pressable => Change the skin + */ + switch (state) { + case 'Preview': + return( + + + + + + {conv.getTabUser()[1].getUsername()} + {conv.getLastMessage()} + + + ) + default: + break; + } +} \ No newline at end of file diff --git a/bob_party/src/components/GameComponent.tsx b/bob_party/src/components/GameComponent.tsx new file mode 100644 index 0000000..53a7d5c --- /dev/null +++ b/bob_party/src/components/GameComponent.tsx @@ -0,0 +1,31 @@ +import { FC, ReactNode } from "react" +import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import React from "react" +import { trace } from "console" +import { Game } from "../core/Game" + +/* + Importing the correct stylesheet +*/ +import styles from './style/Game.style'; + +export const GameComponent : +/* + * game : Game that must be displayed + * nav : tool needed to allow the navigation between the screens +*/ +FC<{game: Game, nav: any}> = +({game, nav}) => +{ + return ( + + Alert.alert("Lancement du jeu")}> + + {game.getName()} + + + ) +} \ No newline at end of file diff --git a/bob_party/src/components/ScreenIndicator.tsx b/bob_party/src/components/ScreenIndicator.tsx new file mode 100644 index 0000000..8acaf9d --- /dev/null +++ b/bob_party/src/components/ScreenIndicator.tsx @@ -0,0 +1,13 @@ +import { FC, ReactNode } from "react" +import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import React from "react" +import styles from './style/ScreenIndicator.style' + +export const ScreenIndicator: FC<{title: String}> = ({title}) => +{ + return( + + {title} + + ) +} \ No newline at end of file diff --git a/bob_party/src/components/Skin.tsx b/bob_party/src/components/Skin.tsx new file mode 100644 index 0000000..3a20fff --- /dev/null +++ b/bob_party/src/components/Skin.tsx @@ -0,0 +1,66 @@ +import { FC, ReactNode } from "react" +import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import React from "react" +import { Skin } from "../core/skin" + +/* + Importing the correct stylesheet +*/ +import styles from "./style/Skin.style" + +export const SkinComponent : +/* Parameters : + * skin : Skin to be displayed + * state : Indicates from wich screen the component has been called +*/ +FC<{skin: Skin, state: String}> = +({skin, state}) => +{ + /* The display of this component depends of the screen from where it has been called: + * From the TopBar (icon) : Small image in a circle + * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin + * From the profile (profile) : Name + Image, Pressable => Change the skin + */ + switch (state) { + case 'icon': + return ( + + + + ) + + case 'shop': + return( + Alert.alert("Achat du skin")} style={styles.imageWrapper}> + {skin.getSkinName()} + + 100€ + + ) + case 'liste': + return( + Alert.alert("Changement du skin")} style={styles.imageWrapper}> + {skin.getSkinName()} + + + ) + case 'profile': + return( + Alert.alert("Achat du skin")} style={styles.imageWrapperProfil}> + {skin.getSkinName()} + + + ) + default: + break; + } +} \ No newline at end of file diff --git a/bob_party/src/components/TopBar.tsx b/bob_party/src/components/TopBar.tsx index 869443f..298ed2d 100644 --- a/bob_party/src/components/TopBar.tsx +++ b/bob_party/src/components/TopBar.tsx @@ -1,23 +1,59 @@ import { FC, ReactNode } from "react" -import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import { Pressable, Image, Text, View} from "react-native" import { Skin } from "../core/Skin" import React from "react" -import { SkinComponent } from "./skinAvatar" -import MainTabNavigator from "../navigation/AppNavigator" -import { BottomTabNavigationProp } from "@react-navigation/bottom-tabs" +import { SkinComponent } from "./Skin" +/* + Import the correct stylesheet +*/ +import styles from './style/TopBar.style'; -export const TopBar : FC<{skin: Skin, styleAvatar: ImageStyle, title: String, rightIcon: ImageSourcePropType, styleIcon: ImageStyle,nav: any, styleTitle: TextStyle, styleHeader : any}> = ({skin, styleAvatar, title, rightIcon,styleIcon, nav, styleTitle, styleHeader}) => +/* + Images required +*/ +const engrenage = require('../../assets/Icons/UnSelected/Cogs.png'); +const cross = require('../../assets/Icons/UnSelected/Cross.png'); +const msc = require('../../assets/Icons/FondGris.png'); + +export const TopBar : +/* Parameters: + * skin : optional skin to display + * nav : tool needed to allow the navigation between the screens + * 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}) => { - return ( - - nav.navigate('ProfileTab')}> - - - {title} - nav.navigate('Settings')}> - - - - ) + /* 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 + */ + switch (state) { + case 'settings': + return ( + + + + + BOB PARTY + nav.goBack()}> + + + + ) + default: + return ( + + nav.navigate('ProfileTab', {screen: 'Profile'})}> + + + BOB PARTY + nav.navigate('Settings')}> + + + + ) + } } \ No newline at end of file diff --git a/bob_party/src/components/skinAvatar.tsx b/bob_party/src/components/skinAvatar.tsx deleted file mode 100644 index 2e1eb8a..0000000 --- a/bob_party/src/components/skinAvatar.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { FC, ReactNode } from "react" -import { Button, Image, ImageStyle, Text, View } from "react-native" -import { Skin } from "../core/Skin" -import React from "react" - -export const SkinComponent : FC<{skin: Skin, children: ImageStyle}> = ({skin, children}) => { - return ( - - - - ) -} \ No newline at end of file diff --git a/bob_party/src/components/style/BotBar.style.js b/bob_party/src/components/style/BotBar.style.js new file mode 100644 index 0000000..6ef9a13 --- /dev/null +++ b/bob_party/src/components/style/BotBar.style.js @@ -0,0 +1,20 @@ +import { StyleSheet } from 'react-native'; + +/* + Stylesheet for the BotBar component +*/ + +export default StyleSheet.create({ + footer: { + flex: 0.15, + flexDirection: 'row', + backgroundColor: '#2D2C33', + width: '100%', + justifyContent: 'space-evenly', + alignItems: 'center', + }, + icon: { + width: 65, + height: 65, + }, +}); \ No newline at end of file diff --git a/bob_party/src/components/style/ButtonChangeSkin.style.js b/bob_party/src/components/style/ButtonChangeSkin.style.js new file mode 100644 index 0000000..990fc3b --- /dev/null +++ b/bob_party/src/components/style/ButtonChangeSkin.style.js @@ -0,0 +1,20 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + button: { + alignItems: 'center', + justifyContent: 'center', + padding: 3, + marginTop: 5, + marginHorizontal: 10, + borderRadius: 10, + backgroundColor: '#2D2C33', + }, + text: { + fontSize: 16, + lineHeight: 21, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, +}); \ No newline at end of file diff --git a/bob_party/src/components/style/ButtonGameTypeChoice.style.js b/bob_party/src/components/style/ButtonGameTypeChoice.style.js new file mode 100644 index 0000000..f76a17b --- /dev/null +++ b/bob_party/src/components/style/ButtonGameTypeChoice.style.js @@ -0,0 +1,25 @@ +import { StyleSheet } from 'react-native'; + +/* + Stylesheet for the ButtonGameTypeChoice component +*/ + +export default StyleSheet.create({ + button: { + alignItems: 'center', + justifyContent: 'center', + height: '30%', + width: '70%', + margin: '5%', + borderRadius: 10, + elevation: 3, + backgroundColor: '#0085FF', + }, + text: { + fontSize: 16, + lineHeight: 21, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, +}); \ No newline at end of file diff --git a/bob_party/src/components/style/ConverstationComponent.style.js b/bob_party/src/components/style/ConverstationComponent.style.js new file mode 100644 index 0000000..cafb0b3 --- /dev/null +++ b/bob_party/src/components/style/ConverstationComponent.style.js @@ -0,0 +1,15 @@ +import { StyleSheet } from "react-native"; + +export default StyleSheet.create({ + textNom: { + fontSize: 20, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + textMess: { + fontSize: 15, + letterSpacing: 0.25, + color: '#D9D9D9', + } +}); \ No newline at end of file diff --git a/bob_party/src/components/style/Game.style.js b/bob_party/src/components/style/Game.style.js new file mode 100644 index 0000000..110df78 --- /dev/null +++ b/bob_party/src/components/style/Game.style.js @@ -0,0 +1,24 @@ +import { StyleSheet } from "react-native"; + +/* + Stylesheet for the GameComponent component +*/ + +export default StyleSheet.create( +{ + image : { + borderRadius: 15, + marginTop: 15, + marginRight: 15, + width: 100, + height: 100, + }, + name :{ + textAlign: 'center', + fontSize: 15, + fontFamily: 'Helvetica', + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, +}) \ No newline at end of file diff --git a/bob_party/src/components/style/ScreenIndicator.style.js b/bob_party/src/components/style/ScreenIndicator.style.js new file mode 100644 index 0000000..3616932 --- /dev/null +++ b/bob_party/src/components/style/ScreenIndicator.style.js @@ -0,0 +1,21 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + textTop: { + textAlign: "center", + fontSize: 16, + lineHeight: 21, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + textTopView: { + backgroundColor: '#0085FF', + width: '30%', + padding: 5, + paddingBottom: 10, + alignSelf: 'center', + borderBottomRightRadius: 50, + borderBottomLeftRadius: 50, + } +}); \ No newline at end of file diff --git a/bob_party/src/components/style/Skin.style.js b/bob_party/src/components/style/Skin.style.js new file mode 100644 index 0000000..41cd4c3 --- /dev/null +++ b/bob_party/src/components/style/Skin.style.js @@ -0,0 +1,36 @@ +import { StyleSheet } from "react-native"; + +/* + Stylesheet for the Skin component +*/ + +export default StyleSheet.create({ + icon: { + width: 50, + height: 50, + borderRadius: 50, + }, + imageWrapper: { + height: 135, + width: '40%', + flexDirection: "column", + margin: 10, + }, + imageWrapperProfil: { + height: 135, + flexDirection: "column", + margin: 10, + }, + imageSkin : { + borderRadius: 15, + width: '100%', + flex:1 + }, + nomSkin :{ + textAlign: 'center', + fontSize: 25, + fontFamily: 'Helvetica', + fontWeight: 'bold', + color: 'white', + }, +}); \ No newline at end of file diff --git a/bob_party/src/components/style/TopBar.style.js b/bob_party/src/components/style/TopBar.style.js new file mode 100644 index 0000000..e7e427a --- /dev/null +++ b/bob_party/src/components/style/TopBar.style.js @@ -0,0 +1,35 @@ +import { StyleSheet } from 'react-native'; + +/* + Stylesheet for the TopBar component +*/ + +export default StyleSheet.create({ + header: { + flex: 0.15, + flexDirection: 'row', + backgroundColor: '#2D2C33', + width: '100%', + justifyContent: 'space-evenly', + alignItems: 'center', + }, + avatar: { + borderRadius: 50, + width: 50, + height: 50, + }, + icon: { + width: 50, + height: 50, + }, + titre: { + flex: 0.7, + flexDirection: 'column', + textAlign: 'center', + fontSize: 30, + fontFamily: 'Helvetica', + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, +}); \ No newline at end of file diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts new file mode 100644 index 0000000..e3f9a3a --- /dev/null +++ b/bob_party/src/constCov.ts @@ -0,0 +1,25 @@ +import { Message } from "./core/message" +import { Conversation } from "./core/conversation" +import tabSkinApp from './constSkin' +import { User } from "./core/user"; + + +let UserActu:User=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined); +let UserTest:User=new User("48", "Wesh Wesh", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[1], tabSkinApp, undefined); + +let tabMessageTest:Message[]=[ + new Message("Salut", UserActu, new Date(2022,12,12)), + new Message("Wesh", UserTest, new Date(2022,12,13)), + new Message("Ca va", UserActu, new Date(2022,12,14)), + new Message("Ouais et toi?", UserTest, new Date(2022,12,15)), +] + +let tabUS:User[]=[UserActu, UserTest]; + +let conv = new Conversation(tabUS, tabMessageTest, "le super nom"); + +let tabConv:Conversation[]=[conv]; + +export default tabConv; + + diff --git a/bob_party/src/constSkin.ts b/bob_party/src/constSkin.ts new file mode 100644 index 0000000..a5c4d54 --- /dev/null +++ b/bob_party/src/constSkin.ts @@ -0,0 +1,14 @@ +import { Skin } from "./core/skin"; + +let tabSkinApp:Skin[]=[ + new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), + new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100), + new Skin("S0003", "Bob BW",require('bob_party/assets/BobsSkins/BobBW.png'), 100), + new Skin("S0004", "Bob Green",require('bob_party/assets/BobsSkins/BobGreen.png'), 100), + new Skin("S0005", "Bob P&T",require('bob_party/assets/BobsSkins/BobPinkTurquoise.png'), 100), + new Skin("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100), + new Skin("S0007", "Bob Cute",require('bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png'), 100), +] + + +export default tabSkinApp; \ No newline at end of file diff --git a/bob_party/src/core/Game.ts b/bob_party/src/core/Game.ts index 8104ba9..7abbad5 100644 --- a/bob_party/src/core/Game.ts +++ b/bob_party/src/core/Game.ts @@ -1,35 +1,45 @@ -export interface Game{ - private Name:String; - private ImageSource:String; - private GameSource:String; +import { randomBytes } from "crypto"; +import { ImageSourcePropType } from "react-native"; - constructor(name:String, imageSource:String, gameSource:String){ +export class Game{ + private Name:string; + private ImageSource:ImageSourcePropType; + private GameSource:string ; + + /* Constructor of the class */ + constructor (name:string, imageSource:ImageSourcePropType, gameSource:string){ this.Name=name; - this.ImageSource=imageSource + this.ImageSource=imageSource; this.GameSource=gameSource; } + /* Brief : Function getting the name of a game */ getName(){ return this.Name; } - setName(name:String){ + /* Brief : Function setting the name of a game */ + setName(name:string){ this.Name=name; } - getImageSource(imageSource:String){ + /* Brief : Function getting the image of a game */ + getImageSource(){ return this.ImageSource; } - setImageSource(imageSource:String){ + /* Brief : Function setting the image of a game */ + setImageSource(imageSource:ImageSourcePropType){ this.ImageSource=imageSource; } + /* Brief : Function getting the source of a game */ getGameSource(){ return this.GameSource; } - setGameSource(gameSource:String){ + /* Brief : Function getting the source of a game */ + setGameSource(gameSource:string){ this.GameSource=gameSource; } } \ No newline at end of file diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts index f6c35c1..dcc0db0 100644 --- a/bob_party/src/core/conversation.ts +++ b/bob_party/src/core/conversation.ts @@ -3,29 +3,62 @@ import { User } from "./user"; export class Conversation{ - private TabUser?: User[]; - private TabMessage?: Message[]; + private TabUser: User[]; + private TabMessage: Message[]; + private Name?: string; - constructor(tabUser: User[], tabMessage:Message[]){ + /* Constructor of the class */ + constructor(tabUser: User[], tabMessage:Message[], name?:string){ this.TabUser=[...tabUser]; this.TabMessage=[...tabMessage]; + this.Name=name; } + /* Brief : function returning the messages of a conversation */ getTabMessage(){ + this.sortMessageDesc(); return this.TabMessage; } + /* Brief : function returning the users of a conversation */ getTabUser(){ return this.TabUser; } + /* Brief : function adding an user to a conversation */ ajouterUser(us:User){ this.TabUser?.push(us); } + /* Brief : function adding a message to a conversation */ ajouterMessage(mess:Message){ this.TabMessage?.push(mess); + this.sortMessageDesc(); + } + + /* Brief : function returning the name to a conversation */ + getName(){ + return this.Name; + } + + /* Brief : function setting the name to a conversation */ + setName(name:string){ + this.Name=name; + } + + /* Brief : function returning the last message of a conversation */ + getLastMessage(){ + this.sortMessageDesc(); + return this.TabMessage[0].getMessageContent(); + } + + /* Brief : function sorting the messages of a conversation to be in the discussion order */ + sortMessageDesc(){ + this.TabMessage.sort( + (objA, objB) => objB.getMessageDate().getTime() - objA.getMessageDate().getTime(), + ); } } + diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts new file mode 100644 index 0000000..9403bd4 --- /dev/null +++ b/bob_party/src/core/gameSolo.ts @@ -0,0 +1,27 @@ +import { ImageSourcePropType } from 'react-native'; +import { Game } from './game' + +export class GameSolo extends Game{ + readonly PtsToCoins:Map + + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, ptsToCoins:Map){ + super(name, imageSource, gameSource); + this.PtsToCoins=ptsToCoins; + } + + + getSoloMap(){ + return this.PtsToCoins; + } + + CoinsWithPoints(nbPoints:number){ + let coins; + for (let key of this.PtsToCoins.keys()){ + coins = this.PtsToCoins.get(key); + if (nbPoints { it('should return The wouhou', () => { expect(classique.getSkinSource()).toBe('The wouhou'); }) -}) \ No newline at end of file +})*/ \ No newline at end of file diff --git a/bob_party/src/core/skin.ts b/bob_party/src/core/skin.ts index 6f6bfde..57d6b60 100644 --- a/bob_party/src/core/skin.ts +++ b/bob_party/src/core/skin.ts @@ -1,25 +1,51 @@ +import { ImageSourcePropType } from "react-native"; + export class Skin{ + readonly Id: string; private Name: string; - private Source: any; + private Source: ImageSourcePropType; + private Cost:number; - constructor(name: string, source:any){ + /* Constructor of the class */ + constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){ + this.Id=id; this.Name=name; this.Source=source; + this.Cost=Cost; } + /* Brief : Fuction setting the name of a skin */ setSkinName(name: string){ this.Name=name; } - setSkinSource(source: any){ + /* Brief : Fuction setting the source of the image of a skin */ + setSkinSource(source: ImageSourcePropType){ this.Source=source; } + /* Brief : Fuction getting the source of the image of a skin */ getSkinSource(){ return this.Source; } + /* Brief : Fuction getting the name of a skin */ getSkinName(){ return this.Name; } + + /* Brief : Fuction getting the id of a skin */ + getSkinId(){ + return this.Id; + } + + /* Brief : Fuction getting the cost of a skin */ + getSkinCost(){ + return this.Cost; + } + + /* Brief : Fuction getting the cost of a skin */ + setSkinCost(cost:number){ + this.Cost=cost; + } } \ No newline at end of file diff --git a/bob_party/src/core/user.ts b/bob_party/src/core/user.ts index 0bb386f..c4b6807 100644 --- a/bob_party/src/core/user.ts +++ b/bob_party/src/core/user.ts @@ -1,109 +1,161 @@ import { Skin } from './Skin' import { Conversation } from './conversation'; +import { sign } from 'crypto'; export class User{ - private Id: string; + readonly Id: string; private Username: string; private Nationality: string; private Sexe: string; private DateOfBirth: Date; private CurrentCoins: number; private TotalCoins: number; + private NbGamePlayed: number; private CurrentSkin: Skin; private TabSkin: Skin[]; - private TabConv: Conversation[]; + private TabConv?: Conversation[]; + /* Consturctor of the class */ constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, - currentSkin: Skin, tabSkin: Skin[], tabConv: Conversation[] ){ + nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ this.Id=id; this.Username=username; this.Nationality=nationality; this.Sexe=sexe; this.DateOfBirth=dateOfBirth; + this.NbGamePlayed=nbGamePlayed; this.CurrentCoins=currentCoins; this.TotalCoins=totalCoins; this.CurrentSkin=currentSkin; this.TabSkin=[...tabSkin]; - this.TabConv=[...tabConv]; + tabConv?.forEach(conv => { + this.TabConv?.push(conv); + }); } + /* Brief : Function getting the name of an user */ getUsername(){ return this.Username; } + /* Brief : Function setting the name of an user */ setUsername(username: string){ this.Username=username; } + /* Brief : Function getting the id of an user */ getId(){ return this.Id; } - - setId(id: string){ - this.Id=id; - } + /* Brief : Function getting the current number of coins of an user */ getCurrentCoins(){ return this.CurrentCoins; } + /* Brief : Function setting the current number of coins of an user */ setCurrentCoins(currentCoins: number){ this.CurrentCoins=currentCoins; } + /* Brief : Function getting the sex of an user */ getSexe(){ return this.Sexe; } + /* Brief : Function getting the sex of an user */ setSexe(sexe: string){ this.Sexe=sexe; } + /* Brief : Function getting the date of birth of an user */ getDateOfBirth(){ return this.DateOfBirth; } + /* Brief : Function setting the date of birth of an user */ setDateOfBirth(dateOfBirth: Date){ this.DateOfBirth=dateOfBirth; } + /* Brief : Function getting the nationality of an user */ getNationality(){ return this.Nationality; } + /* Brief : Function setting the nationality of an user */ setNationality(nationality: string){ this.Nationality=nationality; } + /* Brief : Function getting the total number of coins of an user */ getTotalCoins(){ return this.TotalCoins; } + /* Brief : Function setting the total number of coins of an user */ setTotalCoins(totalCoins: number){ this.TotalCoins=totalCoins; } + /* Brief : Function getting the current number of game played by an user */ + + getGamePlayed(){ + return this.NbGamePlayed; + } + + /* Brief : Function setting the current number of game played by an user */ + + setGamePlayed(nb: number){ + this.NbGamePlayed=nb; + } + + /* Brief : Function getting the current skin of an user */ + getCurrentSkin(){ return this.CurrentSkin; } + /* Brief : Function setting the current skin of an user */ setCurrentSkin(newSkin: Skin){ this.CurrentSkin=newSkin; } + /* Brief : Function getting the skins of an user */ getTabSkin(){ return this.TabSkin; } + /* Brief : Function setting the skins of an user */ setTabSkin(tabSkin: Skin[]){ this.TabSkin=[...tabSkin]; } + /* Brief : Function getting the conversations of an user */ getTabConv(){ return this.TabConv; } - setTabConv(tabConv: Conversation[]){ - this.TabConv=[...tabConv]; + /* Brief : Function setting the conversations of an user */ + setTabConv(tabConv?: Conversation[]){ + tabConv?.forEach(conv => { + this.TabConv?.push(conv); + }); + } + + + changeUserCoins(coin:number){ + this.CurrentCoins+=coin; + if (coin>0){ + this.TotalCoins+=coin; + } + } + + changerCurrentSkin(skin:Skin){ + this.CurrentSkin=skin; + } + + ajouterSkin(skin:Skin){ + this.TabSkin.push(skin); } } \ No newline at end of file diff --git a/bob_party/src/navigation/AppNavigator.tsx b/bob_party/src/navigation/AppNavigator.tsx index d5836c5..9d28d72 100644 --- a/bob_party/src/navigation/AppNavigator.tsx +++ b/bob_party/src/navigation/AppNavigator.tsx @@ -8,6 +8,8 @@ import Store from '../screens/Store' import Chat from '../screens/Chat' import Settings from '../screens/Settings' import Profile from '../screens/Profile' +import SkinList from '../screens/SkinList' +import GameChoice from '../screens/GameChoice' import Test from '../screens/Test' @@ -15,17 +17,23 @@ import Test from '../screens/Test' const HomeStack = createStackNavigator(); +/* + Stack of screens for home and game choice +*/ function HomeStackScreen() { return ( - - + + + ); } const StoreStack = createStackNavigator(); - +/* + Stack of screens for the store and the purshase of new skins +*/ function StoreStackScreen() { return ( @@ -36,7 +44,9 @@ function StoreStackScreen() { } const ChatStack = createStackNavigator(); - +/* + Stack of screens for conversations +*/ function ChatStackScreen() { return ( @@ -47,23 +57,27 @@ function ChatStackScreen() { } const ProfileStack = createStackNavigator(); - +/* + Stack of screens for the profile and the changement of informations +*/ function ProfileStackScreen() { return ( - + + ); } const Tab = createBottomTabNavigator() - +/* + Tab navigator to navigate between the stacks +*/ function MainTabNavigator() { return ( diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index b70abed..a1305e9 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -1,142 +1,41 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' +import { StyleSheet, View, Text} from 'react-native' import React from 'react'; +import stylesScreen from './style/screens.style' import { Skin } from '../core/skin'; 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'; -const avatar = require('../../assets/Icons/BobClassic.png'); -const skinTest= new Skin("Bob",require('../../assets/Icons/BobClassic.png')); -const engrenage = require('../../assets/Icons/UnSelected/Cogs.png'); -const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png'); -const message = require('../../assets/Icons/Selected/SChat.png'); -const store = require('../../assets/Icons/UnSelected/Store.png'); +import tabSkinApp from '../constSkin'; +import tabConv from '../constCov'; + + +const UserActu=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); function Chat(props: { navigation: any; }) { const { navigation } = props return ( - + - - couille + + } + /> ); } - -function Button(props: { onPress: any; title?: "Save" | undefined; }) { - const { onPress, title = 'Save' } = props; - return ( - - {title} - - ); -} - - -const styles = StyleSheet.create({ - body: { - flex: 1, - flexDirection: 'column', - alignItems: 'flex-start', - width: '70%', - }, - - container: { - flex: 1, - backgroundColor: "#45444E", - flexDirection: "column", - justifyContent: "flex-start", - alignItems: "center", - }, - button: { - alignItems: 'center', - justifyContent: 'center', - height: '30%', - width: '100%', - marginTop: '10%', - paddingVertical: 12, - paddingHorizontal: 32, - borderRadius: 10, - elevation: 3, - backgroundColor: '#0085FF', - }, - text: { - fontSize: 16, - lineHeight: 21, - fontWeight: 'bold', - letterSpacing: 0.25, - color: 'white', - }, - header: { - flex : 0.15, - width: '100%', - flexDirection: 'row', - backgroundColor: '#2D2C33', - alignItems: 'center', - justifyContent: 'space-around', - }, - titre: { - flex: 0.7, - flexDirection: 'column', - textAlign: 'center', - fontSize: 30, - fontFamily: 'Helvetica', - fontWeight: 'bold', - letterSpacing: 0.25, - color: 'white', - }, - engrenage: { - borderRadius: 50, - width: 50, - height: 50, - }, - avatar: { - borderRadius: 50, - width: 50, - height: 50, - }, - - footer: { - flex: 0.15, - flexDirection: 'row', - backgroundColor: '#2D2C33', - flexWrap: 'wrap', - width: '100%', - justifyContent: 'space-evenly', - }, - iconFooter: { - marginBot: 25, - marginTop: 10, - width: 65, - height: 50, - }, - iconStore: { - marginBot: 25, - marginTop: 10, - marginLeft: 7, - marginRight: 8, - width: 50, - height: 50, - }, - -}); - export default Chat \ No newline at end of file diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx new file mode 100644 index 0000000..cebbc89 --- /dev/null +++ b/bob_party/src/screens/GameChoice.tsx @@ -0,0 +1,155 @@ +import { StatusBar } from 'expo-status-bar' +import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' +import React from 'react'; +import { Game } from '../core/Game'; +import { Skin } from '../core/skin'; +import { TopBar } from '../components/TopBar'; +import { BotBar } from '../components/BotBar'; +import { GameComponent } from '../components/GameComponent'; +import { User } from '../core/user'; +import tabSkinApp from '../constSkin'; +import { Conversation } from '../core/conversation'; +let tabConv:Conversation[]=[]; + + +const msc = require('../../assets/Icons/FondGris.png'); + +const UserActu=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); +const jeuTest= new Game("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin"); +function GameChoice(props: { navigation: any; }) { + const { navigation } = props + return ( + + + + + + + + ); +} + + +function Button(props: { onPress: any; title?: any | undefined; }) { + const { onPress, title = 'Save' } = props; + return ( + + {title} + + ); +} + + +const styles = StyleSheet.create({ + body: { + flex: 1, + flexDirection: 'column', + alignItems: 'flex-start', + width: '70%', + }, + + container: { + flex: 1, + backgroundColor: "#45444E", + flexDirection: "column", + justifyContent: "flex-start", + alignItems: "center", + }, + button: { + alignItems: 'center', + justifyContent: 'center', + height: '30%', + width: '100%', + marginTop: '10%', + paddingVertical: 12, + paddingHorizontal: 32, + borderRadius: 10, + elevation: 3, + backgroundColor: '#0085FF', + }, + text: { + fontSize: 16, + lineHeight: 21, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + header: { + flex : 0.15, + width: '100%', + flexDirection: 'row', + backgroundColor: '#2D2C33', + alignItems: 'center', + justifyContent: 'space-around', + }, + titre: { + flex: 0.7, + flexDirection: 'column', + textAlign: 'center', + fontSize: 30, + fontFamily: 'Helvetica', + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + engrenage: { + borderRadius: 50, + width: 50, + height: 50, + }, + avatar: { + borderRadius: 50, + width: 50, + height: 50, + }, + + footer: { + flex: 0.15, + flexDirection: 'row', + backgroundColor: '#2D2C33', + flexWrap: 'wrap', + width: '100%', + justifyContent: 'space-evenly', + }, + iconFooter: { + marginBottom: 25, + marginTop: 10, + width: 65, + height: 50, + }, + iconStore: { + marginBottom: 25, + marginTop: 10, + marginLeft: 7, + marginRight: 8, + width: 50, + height: 50, + }, + imageSkin : { + borderRadius: 15, + marginTop: 15, + marginRight: 15, + width: 100, + height: 100, + }, + nomSkin :{ + textAlign: 'center', + fontSize: 15, + fontFamily: 'Helvetica', + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + +}); + +export default GameChoice \ No newline at end of file diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx index e8dadba..cfcf35f 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -1,161 +1,47 @@ import { StatusBar } from 'expo-status-bar' -import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' -import React, { Children } from 'react'; -import { SkinComponent } from '../components/skinAvatar'; +import { StyleSheet, View, ImageSourcePropType} 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'; -const avatar = require('../../assets/Icons/BobClassic.png'); -let tabSkin:Skin[]; -const skinTest= new Skin("Bob",require('../../assets/Icons/BobClassic.png')); -const skinTest2= new Skin("wesh",require('../../assets/BobsSkins/BobBlue.png')); -tabSkin=[skinTest]; -tabSkin.push(skinTest2); +//const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", ); let tabConv:Conversation[]=[]; -const UserActu=new User("14", "leBg", "ouioui", "grand", "la", 12222, 123324, skinTest, tabSkin, tabConv); -const engrenage = require('../../assets/Icons/UnSelected/Cogs.png'); -const gamepad = require('../../assets/Icons/Selected/SGamepad.png'); -const message = require('../../assets/Icons/UnSelected/Chat.png'); -const store = require('../../assets/Icons/UnSelected/Store.png'); - +const UserActu=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); function Home(props: { navigation: any; }) { const { navigation } = props return ( - - - -