Merge branch 'Persistance' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into Persistance

Persistance
Mathilde JEAN 2 years ago
commit 54724ca3f5

@ -1,3 +1,6 @@
import MainTabNavigator from './src/navigation/AppNavigator'
import store from './src/redux/store'
import { Provider } from 'react-redux'
import LoaderUserApi from './src/services/userServices/loaderUserApi'
import ManagerUser from './src/services/userServices/ManagerUser'
import FakeSaverUser from './src/services/userServices/fakeSaverUser'

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -1,6 +1,9 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
presets: [
['babel-preset-expo'],
'@babel/preset-typescript',
],
};
};

@ -6,10 +6,11 @@
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
"web": "expo start --web",
"test": "jest"
},
"dependencies": {
"@expo/webpack-config": "^0.17.0",
"@react-native-community/datetimepicker": "6.2.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
@ -18,12 +19,13 @@
"axios": "^1.1.3",
"expo": "^46.0.15",
"expo-status-bar": "~1.4.0",
"jest": "^26.6.3",
"jest": "^29.3.1",
"jquery": "^3.6.1",
"node": "^18.10.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "^0.69.6",
"react-native-date-picker": "^4.2.5",
"react-native-dialog": "^9.2.2",
"react-native-dialog-input": "^1.0.8",
"react-native-gesture-handler": "~2.5.0",
@ -35,12 +37,15 @@
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/jest": "^29.1.2",
"@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.3.1",
"@types/jest": "^29.2.3",
"@types/jquery": "^3.5.14",
"@types/mocha": "^10.0.0",
"@types/node": "^18.8.4",
"@types/react": "~18.0.14",
"@types/react-native": "~0.69.1",
"ts-jest": "^29.0.3",
"typescript": "~4.3.5"
},
"private": true

@ -0,0 +1,21 @@
import { FC} from "react"
import { Pressable, Text} from "react-native"
import React from "react"
import styles from "./style/PickerGreySmall"
import RNPickerSelect from "react-native-picker-select";
export const PickerGreySmall:
FC<{ valueChange: any, title: string, donePress?: any, values?: any;}>
=
({valueChange, donePress, title, values}) =>
{
return(
<RNPickerSelect
placeholder={{label:title, value: null}}
onValueChange={valueChange}
onDonePress={donePress}
items={values}
style={styles}
/>
)
}

@ -7,8 +7,10 @@ import { Skin } from "../core/skin"
Importing the correct stylesheet
*/
import styles from "./style/Skin.style"
import { useDispatch } from "react-redux"
import { updateSkin } from "../redux/features/currentUserSlice"
import { useDispatch, useSelector } from "react-redux"
import { loginUser } from "../redux/features/currentUserSlice"
import { RootState } from "../redux/store"
import { MANAGER_USER } from "../../App"
export const SkinComponent :
/* Parameters :
@ -20,6 +22,7 @@ FC<{skin: Skin, state: String}> =
{
const dispatch=useDispatch();
/* 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
@ -46,7 +49,7 @@ FC<{skin: Skin, state: String}> =
)
case 'liste':
return(
<Pressable onPress={() => dispatch(updateSkin(skin))} style={styles.imageWrapper}>
<Pressable onPress={() => {MANAGER_USER.getCurrentUser().setCurrentSkin(skin)}} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}

@ -11,6 +11,7 @@ import { User } from "../core/User/user"
import styles from './style/TopBar.style';
import { useSelector } from "react-redux"
import { RootState } from "../redux/store"
import { MANAGER_USER } from "../../App"
/*
Images required
@ -30,8 +31,6 @@ 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
@ -53,7 +52,7 @@ FC<{nav: any, state?: string}> =
return (
<View style={styles.header}>
<Pressable onPress={() => nav.navigate('ProfileTab', {screen: 'Profile'})}>
<SkinComponent skin={currentUser.getCurrentSkin()} state='icon' />
<SkinComponent skin={MANAGER_USER.getCurrentUser().getCurrentSkin()} state='icon' />
</Pressable>
<Text style={styles.titre}>BOB PARTY</Text>
<Pressable onPress={() => nav.navigate('Settings')}>

@ -0,0 +1,40 @@
import { StyleSheet } from "react-native";
export default StyleSheet.create(
{inputIOS: {
alignItems: 'center',
justifyContent: 'center',
padding: 3,
marginTop: 5,
borderRadius: 10,
backgroundColor: '#2D2C33',
paddingHorizontal: 10,
fontSize: 16,
fontWeight: 'bold',
letterSpacing: 0.25,
textAlign: 'center',
color: 'white',
},
placeholder: {
color: 'white',
},
},
{inputAndroid: {
alignItems: 'center',
justifyContent: 'center',
padding: 3,
marginTop: 5,
borderRadius: 10,
backgroundColor: '#2D2C33',
paddingHorizontal: 10,
fontSize: 16,
fontWeight: 'bold',
letterSpacing: 0.25,
textAlign: 'center',
color: 'white',
},
placeholder: {
color: 'white',
},
}
)

@ -1,25 +0,0 @@
import { Message } from "./core/message"
import { Conversation } from "./core/conversation"
import tabSkinApp from './constSkin'
import { User } from "./core/User/user";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[5], tabSkinApp, []);
let tabMessageTest:Message[]=[
new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)),
new Message("Wesh", UserTest, new Date(2022,12,13,12,20,40)),
new Message("Ca va", UserActu, new Date(2022,12,14, 12, 30, 35)),
new Message("Ouais et toi?", UserTest, new Date(2022,12,14,12,35,0)),
]
let tabUS:User[]=[UserActu, UserTest];
let conv = new Conversation(tabUS, tabMessageTest, "le super nom");
let tabConv:Conversation[]=[conv];
export default tabConv;

@ -1,11 +0,0 @@
const tabNat = [
{ label: "France", value: "Français" },
{ label: "Allemagne", value: "Allemand" },
{ label: "Espagne", value: "Espagnol" },
{ label: "Royaume-Uni", value: "Anglais" },
{ label: "États-Unis", value: "Américain" },
{ label: "Italie", value: "Italien" },
]
export default tabNat;

@ -1,9 +0,0 @@
const tabSex = [
{ label: "Homme", value: "Homme" },
{ label: "Femmme", value: "Femmme" },
{ label: "Non-binaire", value: "Non-binaire" },
{ label: "Autre", value: "Autre" },
]
export default tabSex;

@ -0,0 +1,71 @@
import { loginUser } from '../../redux/features/currentUserSlice';
import tabUS from "../../constUser";
import { User } from '../User/user';
import { updateAlreadyUsedPseudo,updateImpossibleBirthDate,updateUndefinedBirthDate,updateUndefinedNationality,updateTooLongPseudo,updateUndefinedPseudo,updateUndefinedSex, updateTooShortPassword, updateInvalidPassword, updateInvalidPseudo, updateUndefinedPassword } from '../../redux/features/credentialErrorsSlice';
function max(array: User[]){
let max: string = "";
for (let index = 0; index < array.length; index++) {
const element = array[index].getId();
if (element > max) max = element;
}
return max;
}
export const checkNewUserValidity = (login: string, password: string, dateOfBirth: Date, nationality: string, sexe: string, dispatch: any, nav: any) => {
let actualDate : number = Date.now();
let givenDate : number = dateOfBirth.getTime();
let passwordRegex : RegExp = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-])(?!.*?[.\n\\{}[\],]).{8,}$/;
let loginRegex : RegExp = /^[A-Za-z0-9_-]{1,22}$/;
switch(true){
case (login === ''):
dispatch(updateUndefinedPseudo(true));
break;
case (password === ''):
dispatch(updateUndefinedPassword(true));
break;
case (givenDate == null):
dispatch(updateUndefinedBirthDate(true));
break;
case (nationality == ''):
dispatch(updateUndefinedNationality(true))
break;
case (sexe == ''):
dispatch(updateUndefinedSex(true));
break;
case (login.length > 22):
dispatch(updateTooLongPseudo(true));
break;
case (! loginRegex.test(login)):
dispatch(updateInvalidPseudo(true));
break;
//ALREADY USED PSEUDO
case (password.length < 8):
dispatch(updateTooShortPassword(true));
break;
case (! passwordRegex.test(password)):
dispatch(updateInvalidPassword(true));
break;
case ((actualDate-givenDate) < 409968000000):
dispatch(updateImpossibleBirthDate(true));
break;
default:
const newUser : User = new User("0",login,password,nationality,sexe,dateOfBirth);
dispatch(loginUser(newUser));
nav.navigate('HomeTab');
}
};

@ -30,7 +30,7 @@ export class User{
this.currentCoins=currentCoins;
this.totalCoins=totalCoins;
this.currentSkin=currentSkin;
this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0);
this.tabSkin=[];
}

@ -3,12 +3,14 @@ import { User } from "./User/user";
export class Conversation{
private Id: string;
private tabUser: User[];
private tabMessage: Message[];
private name: string;
/* Constructor of the class */
constructor(tabUser: User[], tabMessage:Message[], name:string){
constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){
this.Id=id;
this.tabUser=[...tabUser];
this.tabMessage=[...tabMessage];
this.name=name;
@ -36,6 +38,11 @@ export class Conversation{
this.sortMessageDesc();
}
/* Brief : function returning the id of a conversation */
getId(){
return this.Id;
}
/* Brief : function returning the name to a conversation */
getName(){
return this.name;

@ -9,7 +9,7 @@ export abstract class Match{
private tabUsers:User[];
private theGame:Game;
constructor(code:string, tabUser:User[], game:Game){
constructor(code:string, inGame:Boolean, tabUser:User[], game:Game){
this.code=code;
this.inGame=false;
this.tabUsers=[...tabUser];
@ -67,6 +67,6 @@ export abstract class Match{
}
abstract updatePostMatch(user:User, coins:number):void;
abstract updatePostMatch(user:User, points:number):void;
}

@ -6,13 +6,13 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchMulti extends Match{
constructor(code:string, tabUser:User[], game:GameCasino){
super(code, tabUser, game);
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameCasino){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, coins: number): void {
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(coins));
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -6,12 +6,12 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchMulti extends Match{
constructor(code:string, tabUser:User[], game:GameMulti){
super(code, tabUser, game);
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameMulti){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, coins: number): void {
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(coins));
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -6,8 +6,8 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchSolo extends Match{
constructor(code:string, tabUser:User[], game:GameSolo){
super(code, tabUser, game);
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameSolo){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, points: number): void {

@ -2,12 +2,14 @@ import { User } from './User/user'
export class Message{
private Id: string;
private Content: string;
private Sender: User;
private DateEnvoie: Date;
/* Constructor of the class */
constructor(content: string, sender:User, dateEnvoie:Date){
constructor(id: string, content: string, sender:User, dateEnvoie:Date){
this.Id=id;
this.Content=content;
this.Sender=sender;
this.DateEnvoie=dateEnvoie;
@ -28,6 +30,11 @@ export class Message{
this.DateEnvoie=dateEnvoie;
}
/* Brief : Function getting the id of a message */
getMessageId(){
return this.Id;
}
/* Brief : Function getting the content of a message */
getMessageContent(){
return this.Content;

@ -1,3 +1,4 @@
import exp from 'constants';
import { Conversation } from '../Conversation';
import { Message } from '../Message';
import { Skin } from '../Skin';
@ -14,26 +15,29 @@ let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8
let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13);
let theDate3 = new Date(2022,10,15);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate2);
let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate2);
let tabU:User[] = [usr, usr2];
let mess2 = new Message('Oui tout à fait', usr2, theDate);
let mess3 = new Message('Mais oui trop de ouf', usr, theDate3);
let mess2 = new Message('M0002', 'Oui tout à fait', usr2, theDate);
let mess3 = new Message('M0003', 'Mais oui trop de ouf', usr, theDate3);
let tabM:Message[] = [mess, mess2];
let convo = new Conversation(tabU, tabM, 'the conv');
let convo = new Conversation('C0001', tabU, tabM, 'the conv');
let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
// Get tests
describe('Conversation get tests', () => {
it('should return C0001', () => {
expect(convo.getId()).toBe('C0001');
})
it('should return the conv', () => {
expect(convo.getName()).toBe('the conv');
})
it('should return tabU [usr, usr2] (users)', () => {
expect(convo.getTabUser()).toBe(tabU);
})
it('should return tabM [mess, mess2] (messages)', () => {
expect(convo.getTabMessage()).toBe(tabM);
})
it('should return the conv', () => {
expect(convo.getName()).toBe('the conv');
})
it('should return Oui tout à fait (mess2)', () => {
expect(convo.getLastMessage()).toBe('Oui tout à fait');
})
@ -42,6 +46,8 @@ describe('Conversation get tests', () => {
// Setting new value
convo.setName('THE conv');
convo.ajouterUser(usr3);
convo.ajouterMessage(mess3);
// Set test
@ -49,4 +55,13 @@ describe('Conversation set test', () => {
it('should return THE conv', () => {
expect(convo.setName).toBe('THE conv');
})
it('should return tabU [usr, usr2, usr3] (users)', () => {
expect(convo.getTabUser()).toBe(tabU);
})
it('should return tabM [mess, mess2, mess3] (messages)', () => {
expect(convo.getTabMessage()).toBe(tabM);
})
it('should return Mais oui trop de ouf (mess3)', () => {
expect(convo.getLastMessage()).toBe('Mais oui trop de ouf');
})
})

@ -37,7 +37,6 @@ describe('GameSolo get tests', () => {
// Setting new values
game.setId('newId');
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
@ -47,9 +46,6 @@ game.setNbPlayerMax(3);
// Set tests
describe('GameSolo set tests', () => {
it('should return newId', () => {
expect(game.getId()).toBe('newId');
})
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})

@ -3,7 +3,7 @@ import { GameCasino } from '../GameCasino';
// Instances
let game = new GameCasino("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
let game = new GameCasino("GC001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
// Get tests
@ -51,3 +51,12 @@ describe('GameCasino set tests', () => {
it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4);
})
})
// Coins Calculator Tests
describe('Coins calculator tests', () => {
it('should return 200', () => {
expect(game.coinsCalculator(200)).toBe(200);
})
})

@ -6,16 +6,19 @@ import { GameCasino } from '../GameCasino';
// Instances
let myMap = new Map<number, number>([
[50, 3],
[75, 4],
[100, 5],
[150, 6]
[4, 1],
[3, 3],
[2, 5],
[1, 10]
]);
let game = new GameMulti("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
let game = new GameMulti("GM001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
// Get tests
describe('GameMuti get tests', () => {
it('should return GM001', () => {
expect(game.getId()).toBe('GM001');
})
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
@ -63,3 +66,20 @@ describe('GameMulti set tests', () => {
expect(game.getNbPlayerMin()).toBe(4);
})
})
// Coins Calculator tests
describe('Coins calculator tests', () => {
it('should return 1', () => {
expect(game.coinsCalculator(4)).toBe(1);
})
it('should return 3', () => {
expect(game.coinsCalculator(3)).toBe(3);
})
it('should return 5', () => {
expect(game.coinsCalculator(2)).toBe(5);
})
it('should return 10', () => {
expect(game.coinsCalculator(1)).toBe(10);
})
})

@ -1,3 +1,4 @@
import exp from 'constants';
import { GameSolo } from '../GameSolo';
// Instances
@ -7,11 +8,14 @@ let myMap = new Map<number, number>([
[100, 5],
[150, 6]
]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
// Get tests
describe('GameSolo get tests', () => {
it('should return G0001', () => {
expect(game.getId()).toBe('G0001');
})
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
@ -59,3 +63,20 @@ describe('GameSolo set tests', () => {
expect(game.getNbPlayerMax()).toBe(3);
})
})
// Coins Calculator tests
describe('Coins calculator tests', () => {
it('should return 3', () => {
expect(game.coinsCalculator(50)).toBe(3);
})
it('should return 4', () => {
expect(game.coinsCalculator(75)).toBe(4);
})
it('should return 5', () => {
expect(game.coinsCalculator(100)).toBe(5);
})
it('should return 6', () => {
expect(game.coinsCalculator(150)).toBe(6);
})
})

@ -11,8 +11,8 @@ let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/Bob
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
let tab:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7);
let conv:Conversation[] = [];
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr2 = new User('00002', 'Rémi', 'pwd', 'Martinique', 'M', dateBirth, 0, 0, 0, classique, tab);
let tabU:User[] = [usr];
let myMap = new Map<number, number>([
[50, 3],
@ -20,10 +20,10 @@ let myMap = new Map<number, number>([
[100, 5],
[150, 6]
]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
let match = new MatchSolo("machin", false, tabU, game);
let tabU2:User[] = [];
let game2 = new GameSolo("jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
let game2 = new GameSolo("G0002", "jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
// Get tests
@ -61,3 +61,24 @@ describe('Match set tests', () => {
expect(match.getGame).toBe(game2);
})
})
// Update Post-Match tests
describe('Update post-match tests', () => {
it('should return 3', () => {
match.updatePostMatch(tabU[0],50);
expect(tabU[0].getCurrentCoins()).toBe(3);
})
it('should return 8', () => {
match.updatePostMatch(tabU[0],100);
expect(tabU[0].getCurrentCoins()).toBe(8);
})
it('should return 4', () => {
match.updatePostMatch(usr2,75);
expect(usr2.getCurrentCoins()).toBe(4);
})
it('should return 10', () => {
match.updatePostMatch(usr2,150);
expect(usr2.getCurrentCoins()).toBe(10);
})
})

@ -8,15 +8,18 @@ let conv:Conversation[] = [];
let tab:Skin[] = [];
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab);
let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate);
let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate);
// Get tests
describe('Message get tests', () => {
it('should return M0001', () => {
expect(mess.getMessageId()).toBe('M0001');
})
it('should return Bob Party est le meilleur projet', () => {
expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet');
})

@ -11,7 +11,7 @@ import Profile from '../screens/Profile'
import SkinList from '../screens/SkinList'
import GameChoice from '../screens/GameChoice'
import SignIn from '../screens/SignIn'
//import SignUp from '../screens/SignUp'
import SignUp from '../screens/SignUp'
@ -87,6 +87,7 @@ function MainTabNavigator() {
<Tab.Screen name='ChatTab' component={ChatStackScreen} />
<Tab.Screen name='ProfileTab' component={ProfileStackScreen} />
<Tab.Screen name='SignIn' component={SignIn} />
<Tab.Screen name='SignUp' component={SignUp} />
</Tab.Navigator>
</NavigationContainer>
)

@ -0,0 +1,174 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
var incorrectCredentialsBool : boolean = false;
var tooLongPseudodBool : boolean = false;
var tooShortPasswordBool : boolean = false;
var invalidPseudoBool : boolean = false;
var invalidPasswordBool : boolean = false;
var impossibleBirthDateBool : boolean = false;
var undefinedPseudoBool : boolean = false;
var undefinedPasswordBool : boolean = false;
var undefinedBirthDateBool : boolean = false;
var undefinedNationalityBool : boolean = false;
var undefinedSexBool : boolean = false;
var alreadyUsedPseudoBool : boolean = false;
export const credentialErrorsSlice = createSlice({
name: "credentialErrors",
initialState:{
newUserErrorList : {
tooLongPseudo: tooLongPseudodBool,
tooShortPassword : tooShortPasswordBool,
invalidPseudo: invalidPseudoBool,
invalidPassword: invalidPasswordBool,
impossibleBirthDate: impossibleBirthDateBool,
undefinedPseudo: undefinedPseudoBool,
undefinedPassword: undefinedPasswordBool,
undefinedBirthDate: undefinedBirthDateBool,
undefinedNationality: undefinedNationalityBool,
undefinedSex: undefinedSexBool,
alreadyUsedPseudo: alreadyUsedPseudoBool,
},
loginErrorList : {
incorrectCredentials: incorrectCredentialsBool,
}
},
reducers: {
updateIncorrectCredentials: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
incorrectCredentials: action.payload
}
}
},
updateTooLongPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooShortPseudo: action.payload
}
}
},
updateTooLongPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooLongPassword: action.payload
}
}
},
updateTooShortPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooShortPassword: action.payload
}
}
},
updateInvalidPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
invalidPseudo: action.payload
}
}
},
updateInvalidPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
invalidPassword: action.payload
}
}
},
updateImpossibleBirthDate: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
impossibleBirthDate: action.payload
}
}
},
updateUndefinedPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedPseudo: action.payload
}
}
},
updateUndefinedPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedPassword: action.payload
}
}
},
updateUndefinedBirthDate: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedBirthDate: action.payload
}
}
},
updateUndefinedNationality: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedNationality: action.payload
}
}
},
updateUndefinedSex: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedSex: action.payload
}
}
},
updateAlreadyUsedPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
alreadyUsedPseudo: action.payload
}
}
},
},
});
export const { updateIncorrectCredentials } = credentialErrorsSlice.actions
export const { updateTooShortPassword } = credentialErrorsSlice.actions
export const { updateTooLongPseudo } = credentialErrorsSlice.actions
export const { updateTooLongPassword } = credentialErrorsSlice.actions
export const { updateInvalidPseudo } = credentialErrorsSlice.actions
export const { updateInvalidPassword } = credentialErrorsSlice.actions
export const { updateImpossibleBirthDate } = credentialErrorsSlice.actions
export const { updateUndefinedPseudo } = credentialErrorsSlice.actions
export const { updateUndefinedPassword } = credentialErrorsSlice.actions
export const { updateUndefinedBirthDate } = credentialErrorsSlice.actions
export const { updateUndefinedNationality } = credentialErrorsSlice.actions
export const { updateUndefinedSex } = credentialErrorsSlice.actions
export const { updateAlreadyUsedPseudo } = credentialErrorsSlice.actions
export default credentialErrorsSlice.reducer;

@ -2,50 +2,65 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import { Skin } from "../../core/Skin";
import { User } from "../../core/User/user";
interface currentUserState {
value: User[]
}
const dateNull = new Date();
const initialState: currentUserState = {
value: [],
}
const userNull:User= new User("","","","","",dateNull);
var currentUser:User = userNull;
export const currentUserSlice = createSlice({
name: "currentUser",
initialState,
name: "currentUserManager",
initialState : {
currentUser
},
reducers: {
loginUser: (state, action: PayloadAction<User>) => {
state.value.push(action.payload);
const newUser : User = new User(action.payload.getId(), action.payload.getUsername(),action.payload.getPassword(),action.payload.getNationality(),action.payload.getSexe(),action.payload.getDateOfBirth(), action.payload.getCurrentCoins(), action.payload.getTotalCoins(),action.payload.getGamePlayed(),action.payload.getCurrentSkin(),action.payload.getTabSkin(), action.payload.getTabConv())
state.currentUser = newUser;
},
updateSkin: (state, action: PayloadAction<Skin>) =>{
const newUser = state.value[0]
const newUser : User = new User(currentUser.getId(), currentUser.getUsername(),currentUser.getPassword(),currentUser.getNationality(),currentUser.getSexe(),currentUser.getDateOfBirth(), currentUser.getCurrentCoins(), currentUser.getTotalCoins(),currentUser.getGamePlayed(),currentUser.getCurrentSkin(),currentUser.getTabSkin(), currentUser.getTabConv())
newUser.setCurrentSkin(action.payload);
state.value.pop();
state.value.push(newUser);
state.currentUser = newUser;
},
updatePseudo: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0]
const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
console.log(currentUser);
newUser.setUsername(action.payload);
state.value.pop();
state.value.push(newUser);
return {
...state,
currentUser: newUser,
}
},
updatePassword: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0]
newUser.setPassword(action.payload);
state.value.pop();
state.value.push(newUser);
const newUser = state.currentUser;
currentUser.setPassword(action.payload)
return {
...state,
currentUser: newUser,
}
},
updateNationality: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0]
newUser.setNationality(action.payload);
state.value.pop();
state.value.push(newUser);
const newUser = state.currentUser;
currentUser.setNationality(action.payload)
return {
...state,
currentUser: newUser,
}
},
updateSex: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0]
newUser.setSexe(action.payload);
state.value.pop();
state.value.push(newUser);
const newUser = state.currentUser;
currentUser.setSexe(action.payload)
return {
...state,
currentUser: newUser,
}
}
},
});

@ -1,4 +1,5 @@
import { configureStore } from "@reduxjs/toolkit";
import credentialErrorsSlice from "./features/credentialErrorsSlice";
import { getDefaultMiddleware } from '@reduxjs/toolkit';
const customizedMiddleware = getDefaultMiddleware({
@ -7,6 +8,7 @@ const customizedMiddleware = getDefaultMiddleware({
const store = configureStore({
reducer: {
credentialErrors: credentialErrorsSlice,
},
middleware: (getDefaultMiddleware) => customizedMiddleware,
})

@ -6,11 +6,14 @@ import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar';
import { FlatList } from 'react-native-gesture-handler';
import { ConversationComponent } from '../components/ConversationComponent';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App';
function Chat(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar
@ -19,7 +22,7 @@ function Chat(props: { navigation: any; }) {
<View style={stylesScreen.bodyStart}>
{/*
<FlatList
data={currentUser.getTabConv()}
data={MANAGER_USER.getCurrentUser().getTabConv()}
renderItem={({item}) => <ConversationComponent conv={item} state='Preview'/>}
/>
*/}

@ -19,7 +19,6 @@ function Home(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar

@ -8,6 +8,8 @@ import { BotBar } from '../components/BotBar';
import { SkinComponent } from '../components/Skin';
import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App';
const coin = require('../../assets/Icons/Coin.png')
@ -17,7 +19,6 @@ const coin = require('../../assets/Icons/Coin.png')
function Profile(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar
@ -40,7 +41,7 @@ function Profile(props: { navigation: any; }) {
</View>
</View>
<View style={styles.infoView}>
<Text style={styles.infoText}>Total de BobCoin gagnés: </Text>
<Text style={styles.infoText}>Total de BobCoin gagnés: {MANAGER_USER.getCurrentUser().getTotalCoins()}</Text>
</View>
</View>
<BotBar

@ -9,23 +9,37 @@ import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import Dialog from "react-native-dialog"
import RNPickerSelect from "react-native-picker-select";
import tabNat from '../constNat';
import tabSex from '../constSex';
import DialogInput from 'react-native-dialog/lib/Input';
import { PickerGreySmall } from '../components/PickerGreySmall';
import { MANAGER_USER } from '../../App';
import { useUserStore } from '../../userContext';
function Settings(props: { navigation: any; }) {
const { navigation } = props
const setUser = useUserStore((state) => state.setUser);
const currentUser = useSelector((state: RootState) => state.currentUser.value)[0];
const [dialogPseudoVisible, setDialogPseudoVisible] = useState(false);
const [dialogPasswordVisible, setDialogPasswordVisible] = useState(false);
const [dialogNationalityVisible, setDialogNationalityVisible] = useState(false);
const [dialogSexVisible, setDialogSexVisible] = useState(false);
const [selectedSex, setSelectedSex] = useState("");
const [selectedNationality, setSelectedNationality] = useState("");
function changeUsername(username:string){
MANAGER_USER.getCurrentUser()?.setUsername(username);
console.log(MANAGER_USER.getCurrentUser()?.getUsername());
setUser(MANAGER_USER.getCurrentUser());
MANAGER_USER.getsaverUser().updateUser(MANAGER_USER.getCurrentUser());
}
function changePassword(password:string){
MANAGER_USER.getCurrentUser()?.setPassword(password);
console.log(MANAGER_USER.getCurrentUser()?.getPassword());
setUser(MANAGER_USER.getCurrentUser());
MANAGER_USER.getsaverUser().updateUser(MANAGER_USER.getCurrentUser());
}
const dispatch=useDispatch();
return (
@ -40,23 +54,23 @@ function Settings(props: { navigation: any; }) {
<View style={{flexDirection: 'row', justifyContent: 'space-between',}}>
<View>
<View>
<Text style={styles.text}>Pseudo: {currentUser.getUsername()}</Text>
<Text style={styles.text}>Pseudo: {MANAGER_USER.getCurrentUser().getUsername()}</Text>
<ButtonGreySmall onPress={() => setDialogPseudoVisible(true)} title='Changer le pseudo'/>
</View>
<View>
<Text style={styles.text}>Mot de passe: {currentUser.getPassword()}</Text>
<ButtonGreySmall onPress={() => setDialogPasswordVisible(true)} title='Changer le mot de passe'/>
<Text style={styles.text}>Mot de passe: {MANAGER_USER.getCurrentUser().getPassword()}</Text>
<ButtonGreySmall onPress={() => setDialogPasswordVisible(true) } title='Changer le mot de passe'/>
</View>
<View>
<Text style={styles.text}>Nationalité: {currentUser.getNationality()}</Text>
<ButtonGreySmall onPress={() => setDialogNationalityVisible(true)} title='Changer la nationnalité'/>
<Text style={styles.text}>Nationalité: {MANAGER_USER.getCurrentUser().getNationality()}</Text>
<PickerGreySmall title='Changer la nationalité' valueChange={(value:string) => setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={["Francais", "Anglais"]} />
</View>
<View>
<Text style={styles.text}>Sexe: {currentUser.getSexe()}</Text>
<ButtonGreySmall onPress={() => setDialogSexVisible(true)} title='Changer le sexe'/>
<Text style={styles.text}>Sexe: {MANAGER_USER.getCurrentUser().getSexe()}</Text>
<PickerGreySmall title='Changer le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={["Homme", "Femme", "Autre"]} />
</View>
</View>
<Text style={styles.textID}>ID: {currentUser.getId()}</Text>
<Text style={styles.textID}>ID: {MANAGER_USER.getCurrentUser().getId()}</Text>
</View>
</View>
</View>
@ -65,7 +79,7 @@ function Settings(props: { navigation: any; }) {
isDialogVisible={dialogPseudoVisible}
title="Inserer le nouveau pseudo"
hintInput ="Pseudo"
submitInput={ (inputText: string) => { setDialogPseudoVisible(false)} }
submitInput={ (inputText: string) => { changeUsername(inputText); setDialogPseudoVisible(false)} }
closeDialog={ () => {setDialogPseudoVisible(false)}}>
</DialogInput>
@ -73,8 +87,9 @@ function Settings(props: { navigation: any; }) {
isDialogVisible={dialogPasswordVisible}
title="Inserer le nouveau mot de passe"
hintInput ="Mot de passe"
submitInput={ (inputText: string) => {setDialogPasswordVisible(false)} }
submitInput={ (inputText: string) => { changePassword(inputText); setDialogPasswordVisible(false)} }
closeDialog={ () => {setDialogPasswordVisible(false)}}>
</DialogInput>
<Dialog.Container visible={dialogNationalityVisible}>

@ -1,50 +1,81 @@
import { StatusBar } from 'expo-status-bar'
import { View, Pressable, Text} from 'react-native'
import React, { useState } from 'react';
import { View, Pressable, Text, Alert} from 'react-native'
import React, { useCallback, useState } from 'react';
import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler';
import tabUS from "../constUser";
import styles from "./style/SignIn.style"
import styles from "./style/SignIn.style";
import { useDispatch, useSelector } from 'react-redux';
import { loginUser } from '../redux/features/currentUserSlice';
import { RootState } from '../redux/store';
import { updateIncorrectCredentials } from '../redux/features/credentialErrorsSlice';
import Dialog from "react-native-dialog";
import { MANAGER_USER } from '../../App';
import { useUserStore } from '../../userContext';
function SignIn(props: { navigation: any; }) {
const { navigation } = props
const setUser = useUserStore((state) => state.setUser);
const errorList = useSelector((state: RootState) => state.credentialErrors.loginErrorList);
{/*
const [pseudo, setPseudo] = useState('');
const [password, setPassword] = useState('');
const dispatch=useDispatch();
function userVerif(login: string, password: string, nav: any){
if((tabUS.map((User) => User.getUsername()).indexOf(login)) !== -1){
let id = (tabUS.map((User) => User.getUsername()).indexOf(login))
if ((tabUS.map((User) => User.getUsername()).indexOf(login) === id) && ( tabUS[id].getPassword() === password) ){
dispatch(loginUser(tabUS[id]));
nav.navigate('HomeTab');
if (errorList.incorrectCredentials){
Alert.alert("Pseudo ou Mot de passe incorrect");
dispatch(updateIncorrectCredentials(true));
}
*/}
const handleUserConnect = useCallback(async (pseudo: string, password: string) => {
const us =await MANAGER_USER.getLoaderUser().loadByUsernamePassword(pseudo, password).then((res) => {
if (res!=null){
MANAGER_USER.setCurrentUser(res);
navigation.navigate('HomeTab');
setUser(MANAGER_USER.getCurrentUser());
}
else{
console.log("wesh c'est null");
}
});
}, []);
function dispatch(arg0: { payload: boolean; type: string; }): void {
throw new Error('Function not implemented.');
}
*/}
return (
<View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}>
{/*
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' />
<Pressable style={styles.button} onPress={() => userVerif(pseudo, password, navigation)}>
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' secureTextEntry={true}/>
<Pressable style={styles.button} onPress={() => handleUserConnect(pseudo, password)}>
<Text style={styles.text}>Se connecter</Text>
</Pressable>
*/}
<Pressable onPress={() => navigation.navigate('SignUp')}>
<Text style={styles.signup}>Pas de compte? Inscrivez vous !</Text>
<Text style={styles.textLink}>Pas de compte? Inscrivez vous !</Text>
</Pressable>
</View>
<Dialog.Container visible={false}>
<Dialog.Title>Ce pseudo n'exsite pas</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
</Dialog.Container>
<Dialog.Container visible={false}>
<Dialog.Title>Mot de passe incorrect</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
</Dialog.Container>
</View>
);
}

@ -1,29 +1,140 @@
// import { StatusBar } from 'expo-status-bar'
// import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native'
// import React from 'react';
// import stylesScreen from './style/screens.style'
// import { TextInput } from 'react-native-gesture-handler';
// import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
// import styles from "./style/SignIn.style"
// function SignUp(props: { navigation: any; }) {
// const { navigation } = props
// return (
// <View style={stylesScreen.container}>
// <View style={stylesScreen.bodyCenter}>
// <CustomTextInput placeholder={""} text="Pseudo"/>
// <CustomTextInput placeholder={""} text="Mot de passe"/>
// <CustomTextInput placeholder={""} text="Mot de passe"/>
// <CustomTextInput placeholder={""} text="Nationalité"/>
// <CustomTextInput placeholder={""} text="Date de naisance"/>
// <CustomTextInput placeholder={""} text="Sexe"/>
// <Pressable style={styles.button} onPress={navigation.navigate('Home')}>
// <Text style={styles.text}>S'inscrire</Text>
// </Pressable>
// </View>
// </View>
// );
// }
// export default SignUp
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, ImageSourcePropType, Pressable, Text, Alert} from 'react-native'
import React, { useState } from 'react';
import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import styleScreen from "./style/screens.style";
import styles from "./style/SignUp.style";
import { useDispatch, useSelector } from 'react-redux';
import { checkNewUserValidity } from '../core/Auth/newUser';
import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker';
import RNPickerSelect from "react-native-picker-select";
import { PickerGreySmall } from '../components/PickerGreySmall';
import { loginUser } from '../redux/features/currentUserSlice';
import { RootState } from '../redux/store';
import { updateImpossibleBirthDate, updateInvalidPassword, updateInvalidPseudo, updateTooLongPseudo, updateTooShortPassword, updateUndefinedBirthDate, updateUndefinedNationality, updateUndefinedPassword, updateUndefinedPseudo, updateUndefinedSex } from '../redux/features/credentialErrorsSlice';
import { getSystemErrorMap } from 'util';
import RNDateTimePicker from '@react-native-community/datetimepicker';
function SignUp(props: { navigation: any; }) {
const { navigation } = props
const [pseudo, setPseudo] = useState('');
const [password, setPassword] = useState('');
const [date, setDate] = useState(new Date())
function onDateSelected(event : DateTimePickerEvent, value : Date | undefined) {
console.log(value);
if (value != undefined) {
setDate(value);
}
}
const [selectedSex, setSelectedSex] = useState('');
const [selectedNationality, setSelectedNationality] = useState('')
const errorList = useSelector((state: RootState) => state.credentialErrors.newUserErrorList);
const dispatch=useDispatch();
switch(true){
case (errorList.undefinedPseudo):
Alert.alert("Veuillez définir un pseudo");
dispatch(updateUndefinedPseudo(false));
break;
case (errorList.undefinedPassword):
Alert.alert("Veuillez définir un mot de passe");
dispatch(updateUndefinedPassword(false));
break;
case (errorList.undefinedBirthDate):
Alert.alert("Veuillez définir une date de naissance");
dispatch(updateUndefinedBirthDate(false));
break;
case (errorList.undefinedNationality):
Alert.alert("Veuillez définir une nationalité");
dispatch(updateUndefinedNationality(false))
break;
case (errorList.undefinedSex):
Alert.alert("Veuillez définir un sexe");
dispatch(updateUndefinedSex(false));
break;
case (errorList.tooLongPseudo):
Alert.alert("Votre pseudo ne doit pas dépasser 22 caractères");
dispatch(updateTooLongPseudo(false));
break;
case (errorList.invalidPseudo):
Alert.alert("Votre pseudo doit contenir uniquement des lettres des chiffres et des - ou _");
dispatch(updateInvalidPseudo(false));
break;
//ALREADY USED PSEUDO
case (errorList.tooShortPassword):
Alert.alert("Votre mot de passe doit faire au moins 8 caractères");
dispatch(updateTooShortPassword(false));
break;
case (errorList.invalidPassword):
Alert.alert("Votre pseudo doit contenir au moins une majuscule, une majuscule, un chiffre et un caractère spécial (#?!@$%^&*-)");
dispatch(updateInvalidPassword(false));
break;
case (errorList.impossibleBirthDate):
Alert.alert("Vous devez avoir au moins 13 ans");
dispatch(updateImpossibleBirthDate(false));
break;
}
return (
<View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Login</Text>
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Password</Text>
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' />
</View>
<View style={{width: '70%', alignItems: 'center'}}>
<Text style={styles.text}>Date de naissance</Text>
<View style={{width: 150, margin: 10}}>
<RNDateTimePicker onChange={(event, value) => onDateSelected(event, value)} mode='date' value={date} themeVariant='dark'/>
</View>
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Nationalité</Text>
<PickerGreySmall title='Choisir la Nationalité' valueChange={(value:string) =>
setSelectedNationality(value)} values={["Français", "Anglais"]} />
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Sexe</Text>
<PickerGreySmall title='Choisir le sexe' valueChange={(value:string) => setSelectedSex(value)} values={["Homme","Femme", "Autre"]} />
</View>
<Pressable style={styles.button} onPress={() => checkNewUserValidity(pseudo,password,date,selectedNationality,selectedSex, dispatch, navigation)}>
<Text style={styles.text}>S'inscrire</Text>
</Pressable>
<Pressable onPress={() => navigation.navigate('SignIn')}>
<Text style={styles.textLink}>J'ai déjà un compte</Text>
</Pressable>
</View>
</View>
);
}
export default SignUp

@ -14,7 +14,6 @@ import { ScreenIndicator } from '../components/ScreenIndicator';
function SkinList(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar

@ -7,6 +7,8 @@ import { BotBar } from '../components/BotBar';
import { FlatList } from 'react-native-gesture-handler';
import { SkinComponent } from '../components/Skin';
import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App';
function Store(props: { navigation: any; }) {

@ -29,8 +29,4 @@ export default StyleSheet.create({
margin: 15,
padding: 15,
},
RNPView: {
alignSelf: 'center',
padding: 20,
}
});

@ -19,14 +19,16 @@ export default StyleSheet.create({
letterSpacing: 0.25,
color: 'white',
},
signup:{
textLink:{
fontSize:15,
color:'white',
textDecorationLine:"underline",
},
textInput: {
width: '50%',
width: '80%',
height: '5%',
backgroundColor: 'white',
padding: 10,
marginVertical: 10,
}
});

@ -0,0 +1,35 @@
import { StyleSheet } from "react-native";
export default StyleSheet.create({
textInput: {
width: '100%',
height: '5%',
backgroundColor: 'white',
padding: 10,
marginTop: 10,
},
button: {
alignItems: 'center',
justifyContent: 'center',
height: 50,
width: 225,
margin:'10%',
borderRadius: 10,
elevation: 3,
backgroundColor: '#0085FF',
},
text: {
fontSize: 16,
lineHeight: 21,
fontWeight: 'bold',
letterSpacing: 0.25,
color: 'white',
},
textLink:{
fontSize:15,
color:'white',
textDecorationLine:"underline",
},
})

@ -24,4 +24,8 @@ export default StyleSheet.create({
justifyContent: 'center',
width: '100%',
},
RNPView: {
alignSelf: 'center',
padding: 20,
}
});

@ -7,17 +7,17 @@ export default interface ISaverUser{
* u the user we want to save
*/
saveUser(u:User): Promise<void>;
saveUser(u:User | null): Promise<void>;
/**
* deleteUser methode that delete a User in the data management system
* u the user we want to delete
*/
deleteUser(u:User):Promise<void>;
deleteUser(u:User | null):Promise<void>;
/**
* updateUser methode that update a User in the data management system
* u the user we want to update
*/
updateUser(u:User): Promise<void>;
updateUser(u:User | null): Promise<void>;
}

@ -1,4 +1,3 @@
import tabSkinApp from "../../constSkin";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
import ISaverUser from "./ISaverUser";

@ -1,6 +1,7 @@
import tabSkinApp from "../../constSkin";
import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match";
import { Skin } from "../../core/skin";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
@ -90,31 +91,21 @@ export default class LoaderUserApi implements ILoaderUser{
return null;
}
async loadByUsernamePassword(username: string, password: string): Promise<User | null> {
let test = new Test(true, 0, "wesh", 0);
try{
async loadByUsernamePassword(username: string, password: string): Promise<User | null>{
let user:User | null=null;
await this.axios({
method: 'get',
url: 'https://jsonplaceholder.typicode.com/todos/1',
params: {
name: "getUserForConnection",
username: username,
password: password,
name: "getAllUser",
//Les params genre nom de la fonction en php
}
})
.then(function (response: any) {
console.log(response.data);
Object.assign(test, response.data);
console.log(test.id);
user=new User("U0001", username, password, "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]);
});
}catch (error) {
console.error(error);
return user;
}
return null;
}
async loadUserByMatch(m: Match): Promise<User[]> {
throw new Error("Method not implemented.");

File diff suppressed because it is too large Load Diff

@ -1,108 +0,0 @@
#Drop all the tables
DROP TABLE Battle;
DROP TABLE Own;
DROP TABLE Message;
DROP TABLE Belong;
DROP TABLE ConvGroup;
DROP TABLE User;
DROP TABLE Skin;
DROP TABLE Game;
#Create the User table
CREATE TABLE User (
ID char(5) PRIMARY KEY,
Username varchar(20) NOT NULL,
Password varchar(20) NOT NULL,
Nationality varchar(20) NOT NULL,
Sex char(1) NOT NULL,
DateOfBirth date NOT NULL,
CurrentBobCoins bigint(255) DEFAULT 0,
TotalBobCoins bigint(255) DEFAULT 0,
NbGamePlayed bigint(255) DEFAULT 0
);
#Create the Skin table
CREATE TABLE Skin (
ID char(5) PRIMARY KEY,
Name varchar(20) UNIQUE NOT NULL,
Image varchar(20) UNIQUE NOT NULL
);
#Create the Own table
CREATE TABLE Own (
IDSkin char(5),
IDUser char(5),
CONSTRAINT FK_Skin FOREIGN KEY (IDSkin) REFERENCES User(ID),
CONSTRAINT FK_User FOREIGN KEY (IDUser) REFERENCES Skin(ID),
PRIMARY KEY (IDUser, IDSkin)
);
#Create the Game table
CREATE TABLE Game (
ID char(5) PRIMARY KEY,
Name varchar(20) UNIQUE NOT NULL
);
#Create the Match table
CREATE TABLE Battle (
ID char(5) PRIMARY KEY,
Winner char(5) NOT NULL,
Loser char(5) NOT NULL,
Game char(5) NOT NULL,
CONSTRAINT Fk_Winner FOREIGN KEY (Winner) REFERENCES User(ID),
CONSTRAINT Fk_Loser FOREIGN KEY (Loser) REFERENCES User(ID),
CONSTRAINT Fk_Game FOREIGN KEY (Game) REFERENCES Game(ID)
);
#Create the Group table
CREATE TABLE ConvGroup (
ID char(5) PRIMARY KEY,
Name varchar(20) NOT NULL
);
#Create the Message table
CREATE TABLE Message (
ID char(5) PRIMARY KEY,
Message text NOT NULL,
IDSender char(5) NOT NULL,
IDUserReceiver char(5),
IDGroupReceiver char(5),
CONSTRAINT Fk_Sender FOREIGN KEY (IDSender) REFERENCES User(ID),
CONSTRAINT Fk_UsRec FOREIGN KEY (IDUserReceiver) REFERENCES User(ID),
CONSTRAINT Fk_GrRec FOREIGN KEY (IDGroupReceiver) REFERENCES ConvGroup(ID)
);
#Create the Belong Table
CREATE TABLE Belong (
IDUser char(5),
IDGroup char(5),
CONSTRAINT Fk_UserID FOREIGN KEY (IDUser) REFERENCES User(ID),
CONSTRAINT Fk_Group FOREIGN KEY (IDGroup) REFERENCES ConvGroup(ID),
PRIMARY KEY (IDUser, IDGroup)
);
Loading…
Cancel
Save