From 0ea0c130afffb7ac3620750333f71c6c7bac523f Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Wed, 1 Feb 2023 13:28:10 +0100 Subject: [PATCH] APi create + auth spotify-controller/crypt.ts(tempory using auth implicit flow) --- Api/package.json | 3 + .../controller/spotify-controller/crypt.ts | 19 + .../spotify-controller/request/authReqBody.ts | 6 + .../spotify-controller/spotifyCtrl.ts | 233 +++++++++++ Api/src/middleware/exeption/httpExeption.ts | 13 + Api/src/server.ts | 6 +- FLAD/App.tsx | 12 +- FLAD/FakeData/data.ts | 2 +- .../Interface/IdataManager.tsx} | 0 FLAD/Model/Manager.tsx | 111 ++++++ FLAD/Model/Music.tsx | 13 + FLAD/Model/Spot.tsx | 8 + FLAD/Model/StubManager.tsx | 129 ++++++ FLAD/Model/User.tsx | 9 + FLAD/app.json | 1 + FLAD/assets/3869-8114-no-background-like.riv | Bin 0 -> 7466 bytes FLAD/assets/config-dev.ts | 5 + FLAD/assets/icons/Union-1.svg | 3 + FLAD/assets/icons/Union-2.svg | 6 + FLAD/assets/icons/Union.svg | 3 + FLAD/assets/icons/discovery.svg | 3 + FLAD/assets/icons/icon.ts | 7 + FLAD/assets/light_like.riv | Bin 0 -> 7522 bytes FLAD/components/Card.tsx | 11 +- FLAD/components/button/button.tsx | 49 +++ FLAD/components/input.tsx | 30 ++ FLAD/package-lock.json | 370 +++++++++++++++++- FLAD/package.json | 13 +- FLAD/pages/login.tsx | 136 +++++++ FLAD/pages/spot.tsx | 32 +- .../Auth/authentificationService.service.tsx | 33 ++ .../spotify/ApiSpotifyIdentification.tsx | 21 - FLAD/services/spotify/spotify.service.ts | 55 ++- FLAD/services/user/userService.service.tsx | 27 ++ 34 files changed, 1288 insertions(+), 81 deletions(-) create mode 100644 Api/src/controller/spotify-controller/crypt.ts create mode 100644 Api/src/controller/spotify-controller/request/authReqBody.ts create mode 100644 Api/src/controller/spotify-controller/spotifyCtrl.ts create mode 100644 Api/src/middleware/exeption/httpExeption.ts rename FLAD/{components/button.tsx => Model/Interface/IdataManager.tsx} (100%) create mode 100644 FLAD/Model/Manager.tsx create mode 100644 FLAD/Model/Music.tsx create mode 100644 FLAD/Model/Spot.tsx create mode 100644 FLAD/Model/StubManager.tsx create mode 100644 FLAD/Model/User.tsx create mode 100644 FLAD/assets/3869-8114-no-background-like.riv create mode 100644 FLAD/assets/config-dev.ts create mode 100644 FLAD/assets/icons/Union-1.svg create mode 100644 FLAD/assets/icons/Union-2.svg create mode 100644 FLAD/assets/icons/Union.svg create mode 100644 FLAD/assets/icons/discovery.svg create mode 100644 FLAD/assets/icons/icon.ts create mode 100644 FLAD/assets/light_like.riv create mode 100644 FLAD/components/button/button.tsx create mode 100644 FLAD/components/input.tsx create mode 100644 FLAD/pages/login.tsx create mode 100644 FLAD/services/Auth/authentificationService.service.tsx create mode 100644 FLAD/services/user/userService.service.tsx diff --git a/Api/package.json b/Api/package.json index 80aedb7..8267a4f 100644 --- a/Api/package.json +++ b/Api/package.json @@ -20,6 +20,9 @@ "typescript": "^4.9.4" }, "dependencies": { + "@types/crypto-js": "^4.1.1", + "@types/request": "^2.48.8", + "axios": "^1.2.6", "cors": "^2.8.5", "express-winston": "^4.2.0", "morgan": "^1.10.0", diff --git a/Api/src/controller/spotify-controller/crypt.ts b/Api/src/controller/spotify-controller/crypt.ts new file mode 100644 index 0000000..56378d3 --- /dev/null +++ b/Api/src/controller/spotify-controller/crypt.ts @@ -0,0 +1,19 @@ +export default class CryptString{ + + stringCrypt: string; + + constructor(length : number){ + this.stringCrypt = this.generateRandomString(length); + } + generateRandomString (length : number){ + var text = ''; + var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + for (var i = 0; i < length; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; + } +} + + diff --git a/Api/src/controller/spotify-controller/request/authReqBody.ts b/Api/src/controller/spotify-controller/request/authReqBody.ts new file mode 100644 index 0000000..6799b65 --- /dev/null +++ b/Api/src/controller/spotify-controller/request/authReqBody.ts @@ -0,0 +1,6 @@ +export type AuthReqBody = { + grant_type: string, + redirect_uri?: string, + code?: string, + refresh_token?: string, +} \ No newline at end of file diff --git a/Api/src/controller/spotify-controller/spotifyCtrl.ts b/Api/src/controller/spotify-controller/spotifyCtrl.ts new file mode 100644 index 0000000..4fff98f --- /dev/null +++ b/Api/src/controller/spotify-controller/spotifyCtrl.ts @@ -0,0 +1,233 @@ +import Controller from '../Icontroller'; +import { Router, Request, Response, NextFunction, RequestHandler } from 'express'; +import { AuthReqBody } from './request/authReqBody'; +import HttpException from '../../middleware/exeption/httpExeption'; +import axios from 'axios'; +import CryptString from './crypt'; +import AES from 'crypto-js' +import querystring from 'querystring'; + +class SpotifyController implements Controller { + public path = '/spotify'; + public router = Router(); + + constructor() { + console.log("useeeee"); + + this.initialiseRoutes(); + } + initialiseRoutes() { + // this.router.post(`${this.path}`,this.createTask); + this.router.get(`${this.path}/exchange`,this.login); + this.router.get(`${this.path}/callback`,this.getAccessToken); + // this.router.post(`${this.path}/refresh`,this.getRefreshToken); + this.router.get(`${this.path}/play/:musicId`, this.getMusic); + } + + // need to put in ENvironement file + // private readonly CLIENT_CALLBACK_URL = "http://localhost:8080/callback"; + private readonly API_URL = "https://accounts.spotify.com/api/token"; + private readonly CLIENT_ID = "1f1e34e4b6ba48b388469dba80202b10"; + private readonly CLIENT_SECRET = "779371c6d4994a68b8dd6e84b0873c82"; + private readonly CLIENT_CALLBACK_URL = "https://auth.expo.io/@thed47/FLAD//callback"; + private readonly CALLBACK_URL = "http://localhost:8080/api/spotify/callback"; + private readonly SCOPES ='user-read-private user-read-email user-read-playback-state user-read-currently-playing user-read-recently-played playlist-modify-public ugc-image-upload user-modify-playback-state'; + private readonly ENCRYPTION_SECRET = new CryptString(16); + + private login = async ( + req: Request, + res: Response, + next: NextFunction + ): Promise => { + + console.log("useeeee"); + try { + // const params = req.body; + // if (!params.refresh_token) { + // return res.json({ + // "error": "Parameter missing" + // }); + // } + + // this.spotifyRequest({ + // grant_type: "authorization_code", + // redirect_uri: this.CLIENT_CALLBACK_URL, + // // code: params.code + // }) + res.redirect('https://accounts.spotify.com/authorize?' + + querystring.stringify({ + response_type: 'code', + client_id: this.CLIENT_ID, + scope: this.SCOPES, + redirect_uri: this.CALLBACK_URL, + state: this.ENCRYPTION_SECRET.stringCrypt + })); + // .then(session => { + // let result = { + // "access_token": session.access_token, + // "expires_in": session.expires_in, + // "refresh_token": this.encrypt(session.refresh_token) + // }; + // return res.send(result); + // }) + // .catch(response => { + // return res.json(response); + // }); + } catch (error) { + next(new HttpException(400, 'Cannot create spot')); + } + + + }; + + // private getRefreshToken = async ( + // req: Request, + // res: Response, + // next: NextFunction + // ): Promise => { + + // console.log('UUse2'); + + // try { + // const params = req.body; + // if (!params.refresh_token) { + // return res.json({ + // "error": "Parameter missing" + // }); + // } + + // this.spotifyRequest({ + // grant_type: "refresh_token", + // refresh_token: this.decrypt(params.refresh_token) + // }) + // .then(session => { + // return res.send({ + // "access_token": session.access_token, + // "expires_in": session.expires_in + // }); + // }) + // .catch(response => { + // return res.json(response); + // }); + // console.log("errur"); + // } catch (error) { + // next(new HttpException(400, 'Cannot create post')); + // console.log("errur"); + + // } + + + // }; + + public getMusic(){ + + return null; + } + + // private spotifyRequest = (params : AuthReqBody) => { + // return new Promise(() => { + // console.log("============ on est laaaa sa mer"); + // var code = req.query.code || null; + // var state = req.query.state || null; + + // axios.post(this.API_URL, { + // form: params, + // headers: { + // "Authorization": "Basic " + new Buffer(this.CLIENT_ID + ":" + this.CLIENT_SECRET).toString('base64') + // }, + // json: true + // }); + // }).then(resp => { + // if (resp.statusCode != 200) { + // return Promise.reject({ + // statusCode: resp.statusCode, + // body: resp.body + // }); + // } + // return Promise.resolve(resp.body); + // }) + // .catch(err => { + // return Promise.reject({ + // statusCode: 500, + // body: err.stringify({}) + // }); + // }); + // }; + + private getAccessToken = async ( + req: Request, + res: Response, + next: NextFunction + ): Promise => { + + // console.log("heheh"); + // try { + // var code = req.query.code; + // var state = req.query.state; + // console.log("================================================================================================================================"); + // console.log(req); + // console.log("================================================================================================================================"); + + // if (state === null) { + // next(new HttpException(400, 'Cannot create twerk')); + // } else { + // const resp : any = await axios.post('https://accounts.spotify.com/api/token',{ + // form: { + // code: code, + // redirect_uri: this.CALLBACK_URL, + // // code_verifier : this.ENCRYPTION_SECRET.stringCrypt, + // grant_type: 'authorization_code' + // }, + // headers: { + // 'Authorization': 'Basic ' + (new Buffer(this.CLIENT_ID + ':' + this.CLIENT_SECRET).toString('base64')), + // },json: true} + // ); + // if (resp.statusCode != 200) { + // console.log(resp.statusCode, resp.body); + // } + // else{ + // console.log("error"); + // console.log(resp.statusCode, resp.body); + // } + + // } + // // }); + // } catch (error) { + // console.log(error); + // next(new HttpException(400, 'Cannot create spot')); + // } + + var code = req.query.code || null; + var state = req.query.state || null; + // var storedState = req.cookies ? req.cookies[stateKey] : null; + var authOptions = { + url: 'https://accounts.spotify.com/api/token', + form: { + code: code, + redirect_uri: this.CALLBACK_URL, + grant_type: 'authorization_code' + }, + headers: { + 'Authorization': 'Basic ' + (new Buffer(this.CLIENT_ID + ':' + this.CLIENT_SECRET).toString('base64')) + }, + json: true + }; + + + }; + + + + + private encrypt(text :any){ + return CryptoJS.AES.encrypt(text, this.ENCRYPTION_SECRET.stringCrypt).toString(); + }; + + private decrypt(text: any) { + console.log("errer"); + var bytes = CryptoJS.AES.decrypt(text, this.ENCRYPTION_SECRET.stringCrypt); + return bytes.toString(CryptoJS.enc.Utf8); + }; + +} +export default SpotifyController; diff --git a/Api/src/middleware/exeption/httpExeption.ts b/Api/src/middleware/exeption/httpExeption.ts new file mode 100644 index 0000000..ae972b5 --- /dev/null +++ b/Api/src/middleware/exeption/httpExeption.ts @@ -0,0 +1,13 @@ +class HttpException extends Error { + public status: number; + public message: string; + + constructor(status: number, message: string) { + super(message); + this.status = status; + this.message = message; + } +} +// en fontion de l'exeption firebas,etc une bonne exeption + +export default HttpException; \ No newline at end of file diff --git a/Api/src/server.ts b/Api/src/server.ts index 9c86e7c..87e362b 100644 --- a/Api/src/server.ts +++ b/Api/src/server.ts @@ -1,11 +1,15 @@ import App from "./app"; +import SpotifyController from "./controller/spotify-controller/spotifyCtrl"; import PingController from "./controller/TestCtrl"; const app = new App( - [new PingController()], + [new PingController(), new SpotifyController()], Number(8080) // Number(process.env.PORT) ); app.listen(); + + + diff --git a/FLAD/App.tsx b/FLAD/App.tsx index 5e576c2..04b9b76 100644 --- a/FLAD/App.tsx +++ b/FLAD/App.tsx @@ -3,6 +3,7 @@ import { StatusBar } from 'expo-status-bar'; import { useState, useTransition } from 'react'; import { Animated, Dimensions, ImageBackground, StyleSheet, Text, View } from 'react-native'; import Card from './components/Card'; +import Login from './pages/login'; import Spot from './pages/spot'; @@ -29,9 +30,11 @@ export default function App() { const {width : wWidht} = Dimensions.get("window"); return ( + - + + Laylow + + {/* */} - - @@ -83,9 +86,10 @@ const {width : wWidht} = Dimensions.get("window"); const styles = StyleSheet.create({ container: { flex: 1, - backgroundColor: '#fff', + backgroundColor: '#000', alignItems: 'center', justifyContent: 'center', + }, card: { borderRadius : 8, diff --git a/FLAD/FakeData/data.ts b/FLAD/FakeData/data.ts index 24013a7..805a6e5 100644 --- a/FLAD/FakeData/data.ts +++ b/FLAD/FakeData/data.ts @@ -1,6 +1,6 @@ export const cards = [{ name : "blue", - sourceUrl : "https://images.unsplash.com/photo-1484589065579-248aad0d8b13?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1359&q=80", + sourceUrl : "https://cdns-images.dzcdn.net/images/artist/399e7e760d8fedf3cc2891e9c0c41658/200x200-000000-80-0-0.jpg", index : 3 }, { diff --git a/FLAD/components/button.tsx b/FLAD/Model/Interface/IdataManager.tsx similarity index 100% rename from FLAD/components/button.tsx rename to FLAD/Model/Interface/IdataManager.tsx diff --git a/FLAD/Model/Manager.tsx b/FLAD/Model/Manager.tsx new file mode 100644 index 0000000..e137aa1 --- /dev/null +++ b/FLAD/Model/Manager.tsx @@ -0,0 +1,111 @@ +// import { useState } from "react"; +// import SpotifyService from "../services/spotify/spotify.service"; + +// class Manager{ + +// // injection de dépences +// spotifyService = new SpotifyService(); +// userService = new userService(); + +// private currentUser = useState(null); + +// constructor() { +// } + +// // spotify methods +// apiAuthorization(url : string) { +// spotifyService.apiAuthorization(url); +// } + +// getCompleteMusic = async (id : string) :Promise =>{ +// // Map info = await spotifyService.getTrackInfo(id); +// // return Music(id, info['name'], info['artist'], info['cover']); +// } + +// removeFromPlaylist(id : string) { +// this.spotifyService.removeFromPlaylist(id); +// } + + +// addToPlaylist(id : string) { +// this.spotifyService.addToPlaylist(id); +// } + +// playTrack(id : string) { +// this.spotifyService.playTrack(id); +// } +// //////////////////////////////////////////// + +// // private readonly getTaskById: RequestHandler = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { +// // const id = req.params.taskId; +// // const userId = req.params.userId; + +// // const data = await this.Taskservice.getTaskById(id, userId); +// // res.status(201).send(data); + +// // } +// // catch(error){ +// // next(new HttpException(400, 'Cannot create post')); +// // } + +// // } + + +// // private delete = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { +// // const id = req.params.taskId; +// // const userId = req.params.userId; +// // await this.Taskservice.DeleteTask(id, userId); +// // return res.status(200).send({ status: "Success", msg: "Data Removed" }); +// // } catch (error) { +// // next(new HttpException(400, 'Cannot create post')); +// // } +// // }; + +// // private updateTask = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { + +// // const taskId = req.params.taskId; +// // const userId = req.params.userId; +// // const reqBody:CreateTaskReqBody = Object.assign({}, req.body); + +// // const updatedTask = await this.Taskservice.UpdateTask( +// // // req.auth!.uid, +// // taskId, +// // userId, +// // // firebase.auth().currentUser.getIdToken() +// // reqBody.nom, +// // reqBody.description, +// // reqBody.logo, +// // reqBody.duration, +// // reqBody.done, +// // // reqBody.tags, +// // reqBody.repepat, +// // reqBody.deb, +// // reqBody.fin +// // ); +// // // res.send('Success add'); +// // // res.status(201).json({ task }); +// // res.status(204).send(`Update a new contact: ${updatedTask}`); +// // } catch (error) { +// // console.log(error); +// // next(new HttpException(403, 'Cannot create post')); +// // } +// // }; + +// } + +// export default Manager; \ No newline at end of file diff --git a/FLAD/Model/Music.tsx b/FLAD/Model/Music.tsx new file mode 100644 index 0000000..fe933c9 --- /dev/null +++ b/FLAD/Model/Music.tsx @@ -0,0 +1,13 @@ +class Music { + private id : string; + private name : string; + private artist : string; + private linkCover : string; // Image.source + + constructor(id : string, name : string, artist : string, linkCover : string){ + this.id = id; + this.name = name; + this.artist = artist; + this.linkCover = linkCover; + } +} diff --git a/FLAD/Model/Spot.tsx b/FLAD/Model/Spot.tsx new file mode 100644 index 0000000..53d37d0 --- /dev/null +++ b/FLAD/Model/Spot.tsx @@ -0,0 +1,8 @@ +class Spot { + private userId : string; + public music : Music;; + constructor(userId : string, music : Music){ + this.userId = userId; + this.music = music; + } +} \ No newline at end of file diff --git a/FLAD/Model/StubManager.tsx b/FLAD/Model/StubManager.tsx new file mode 100644 index 0000000..10caca9 --- /dev/null +++ b/FLAD/Model/StubManager.tsx @@ -0,0 +1,129 @@ +// import { useState } from "react"; +// import SpotifyService from "../services/spotify/spotify.service"; +// import { makeRedirectUri, useAuthRequest } from 'expo-auth-session'; + +// class StubManager{ + +// // injection de dépences +// spotifyService = new SpotifyService(); +// // userService = new userService(); + +// private currentUser = useState(null); +// private discovery = { +// authorizationEndpoint: 'https://accounts.spotify.com/authorize', +// tokenEndpoint: 'https://accounts.spotify.com/api/token', +// }; +// constructor() { +// } + +// // spotify methods +// apiAuthorization(url : string){ +// const [, response, promptAsync] = useAuthRequest( +// { +// clientId: '1f1e34e4b6ba48b388469dba80202b10', +// scopes: ['user-read-email', 'playlist-modify-public'], +// // In order to follow the "Authorization Code Flow" to fetch token after authorizationEndpoint +// // this must be set to false +// usePKCE: false, +// redirectUri: makeRedirectUri({ +// scheme: 'flad' +// }), +// }, +// this.discovery +// ); + + +// } + +// getCompleteMusic = async (id : string) :Promise =>{ +// // Map info = await spotifyService.getTrackInfo(id); +// // return Music(id, info['name'], info['artist'], info['cover']); +// } + +// removeFromPlaylist(id : string) { +// this.spotifyService.removeFromPlaylist(id); +// } + + +// addToPlaylist(id : string) { +// this.spotifyService.addToPlaylist(id); +// } + +// playTrack(id : string) { +// this.spotifyService.playTrack(id); +// } +// //////////////////////////////////////////// + +// // private readonly getTaskById: RequestHandler = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { +// // const id = req.params.taskId; +// // const userId = req.params.userId; + +// // const data = await this.Taskservice.getTaskById(id, userId); +// // res.status(201).send(data); + +// // } +// // catch(error){ +// // next(new HttpException(400, 'Cannot create post')); +// // } + +// // } + + +// // private delete = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { +// // const id = req.params.taskId; +// // const userId = req.params.userId; +// // await this.Taskservice.DeleteTask(id, userId); +// // return res.status(200).send({ status: "Success", msg: "Data Removed" }); +// // } catch (error) { +// // next(new HttpException(400, 'Cannot create post')); +// // } +// // }; + +// // private updateTask = async ( +// // req: Request, +// // res: Response, +// // next: NextFunction +// // ): Promise => { +// // try { + +// // const taskId = req.params.taskId; +// // const userId = req.params.userId; +// // const reqBody:CreateTaskReqBody = Object.assign({}, req.body); + +// // const updatedTask = await this.Taskservice.UpdateTask( +// // // req.auth!.uid, +// // taskId, +// // userId, +// // // firebase.auth().currentUser.getIdToken() +// // reqBody.nom, +// // reqBody.description, +// // reqBody.logo, +// // reqBody.duration, +// // reqBody.done, +// // // reqBody.tags, +// // reqBody.repepat, +// // reqBody.deb, +// // reqBody.fin +// // ); +// // // res.send('Success add'); +// // // res.status(201).json({ task }); +// // res.status(204).send(`Update a new contact: ${updatedTask}`); +// // } catch (error) { +// // console.log(error); +// // next(new HttpException(403, 'Cannot create post')); +// // } +// // }; + +// } + +// export default StubManager; \ No newline at end of file diff --git a/FLAD/Model/User.tsx b/FLAD/Model/User.tsx new file mode 100644 index 0000000..39fad6d --- /dev/null +++ b/FLAD/Model/User.tsx @@ -0,0 +1,9 @@ +class User { + //attributes from DAFL + private idDafl : any;; + private idSpotify : any; + //constructors + constructor(){ + + } + } \ No newline at end of file diff --git a/FLAD/app.json b/FLAD/app.json index 1769d52..9ff2f71 100644 --- a/FLAD/app.json +++ b/FLAD/app.json @@ -11,6 +11,7 @@ "resizeMode": "contain", "backgroundColor": "#1d2129" }, + "scheme": "flad", "updates": { "fallbackToCacheTimeout": 0 }, diff --git a/FLAD/assets/3869-8114-no-background-like.riv b/FLAD/assets/3869-8114-no-background-like.riv new file mode 100644 index 0000000000000000000000000000000000000000..6deffd5e098f7bf267f88569dfd33648083095b7 GIT binary patch literal 7466 zcmc&(dr(x@89x`eppjj6H_NlmvY5askXXA_u$8@+UAaIbCL)Norp_iT;(&37M@+~x z&{!WaCKziPzz2w$7&LZTqd0X&5Hqb)b z{Z2ng6cZdbZ>;j!TEyQ%)Jpy_>IDR;hKAPFXOyb?B+=r$-mxQ)jt^oN_XvfA^o%aJ-jNs}_ls!- z2;cM0hP%GV2pl9jx_y0m+H>OlJazQfkEi!|7Nz?nm`kxL6l{Y@1TmRSsMB^iZCJA7 z!-6G9A_JUmD=#`P*$cZ*Q$tCn73ML+*>LMvARQlo>P2Be!>v37lvPki01*?2hhd@W z-JZNR&mc}Zden1ay$g}ik;gM}*Q6u8 zCLQTDla(#49icWc-2t0ZviGn|qSI}q?^a88e9)xUo|LD@iA^lB-TV3~$-eSxo#YlsvRIt`N$$%Nb@MKF z%Jqa?^RJt@__eVHl*j{OaaP^#X@BkKO;gfZaPt!p{OduLLx{UvbC^JfG1b8??h^`s zwfW#^-qv{!O)R)=a|a%9RA2JLtS`Y|!F%t(4xwx05PRuH&4FXFpGsbkUZqkGtjm3L z$835c*d7v{xIs#^9!hLpuNQha{|&W=QnMaPV|ys&dY}%*9vtG!LcZJW?g2Ols08OV zX`Tvad-Il#kSNeI51@onYrQ(LQWPlJ43r!TO6EXO2OiW9*|Bzr2lY7;*M@^_EpWm; zo!ychA1bEXV~23DD{YmNaAo0xE_PLRc<}Og-G^z_a((!fT6rDbjSVQlPN>T28N4im zadNDF6BQuSQ}HE)vsDN_ym&8X1eB#tcJ^83q~|4+D*yErwb%47Fw$ zXk>m|>ui@i5TH*<#pehGC-_1{xU;1C5+5hM*aSpcw`l84m-EoGpeX zGYm~;7-(cX3^a1K7+TCQw3uO_k?}Cl$k}2Dn_&o>VW5%mFwn@^V(2u(&}oK&M#jTH zBWH`D%M3%883q~|4+D*y8G~JXB_3~f18;V7y!jfv|B*L;L?z_S*BK``#YEy1li@cP zeiry;z|RH00{9iduLORTBugw>Ovv4GCJbo;(0Z0w0;Vtu5(qsq69{T5H4_Td8HFL4 z%qR1urkWr4@B zyE28cS^21}vjt;X-Vc*QVd)rhOHwMH32qIyhL+zINVYeD?X zr^Dyz^F;x){ixlKQlFsEoUXtrHpFiWNOVAeOp7rSIKa|q>9i5#)I>otY;241+d;p!HKzQ)qx7Rm}EQL68j!P-p{!va6t1hT&TR0M1!zk880+EX-Z` zXlGRbVyv;2;=@l}g|;MCYcF?yE(ZGh zaks$!`#;sr_BI%o2TlgtBtMQ?o*0Y1JOj8q=&l6bE8><|5jJ5du*%h!`rdQd5aOb>aLvl#D6hnmN1dh|IBh+kxpZ+$QqxHsug3= zYtc1Ecjf-m%eWPZSPH@)`Jq;=u@>}oZq3i}LXNH#W6^8T)u**`A3w;|idfF(=T1Pa zjZw9pd!Yj7aE8;%TliY^^nSXtDz+B2Obm439A>au^bS1^i`=saSGAYzip)P9XNxQ- z&1uhTTSD_5Zg(5KKUjE3_pa#+e;bOimyEzX*m5WER6Eoglf6k4 zsw4Iyp|LwUpVY~{NIz{e>2U^BJqX}xPmqgd#^jr;aHQtbV4b-#y z(MVr&XorB!3U)@N8rAa{JaI6ndJY4qj3lpPKs}@Q2p2M*69LE@I?dT(^rp^o^C?J; z91K2LMw*1thh#e$GQ(@4tIh6N`>BU=_5!5J5hUo z!O0rYUthf3q(|$uNgu)d;A(txQS&f8dv9UyRe@9r$N~Xu#Wlvnpwl{GI>5oemvN2Q zBXkE(Y%D^F5D$%MjL0{}pPEQxs-9~MR7Nh;8$&%~LXDl!1}BqI&{A&lqV-yhlSr0G zd}=Tt)_9d=V`r@}Ivb}qWOD_;)ySwUv8rc$s<9HQ!Ki0(bPZ0=)c{u`AL%tv&)7)g zSG1kc>D39Nw{>={P*==AuFRWpEAwX5%Dfq~YOKI|U{`<4UB&6S9`H^w@PXa~>KPko zEXQgvl6xq6o;W>M16&mYzv(ql&)7|4ZL~#pB3~m~uhpPO4|5s#TFnDH3iXVwHCDs> z_N-27c+J6DFixugcLSv{SH@_}l@S`cGCmWlwmltcgKZoAovX7OOqTI`mVUNod!ue( z?el=%oyJcv^?h1>BQ}2evHZCJ<2{(tNrI2znD~AlS7O`3^J|URsj2 zwj + + diff --git a/FLAD/assets/icons/Union-2.svg b/FLAD/assets/icons/Union-2.svg new file mode 100644 index 0000000..e61196d --- /dev/null +++ b/FLAD/assets/icons/Union-2.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/FLAD/assets/icons/Union.svg b/FLAD/assets/icons/Union.svg new file mode 100644 index 0000000..1efd231 --- /dev/null +++ b/FLAD/assets/icons/Union.svg @@ -0,0 +1,3 @@ + + + diff --git a/FLAD/assets/icons/discovery.svg b/FLAD/assets/icons/discovery.svg new file mode 100644 index 0000000..cfc5c6e --- /dev/null +++ b/FLAD/assets/icons/discovery.svg @@ -0,0 +1,3 @@ + + + diff --git a/FLAD/assets/icons/icon.ts b/FLAD/assets/icons/icon.ts new file mode 100644 index 0000000..35b3a1f --- /dev/null +++ b/FLAD/assets/icons/icon.ts @@ -0,0 +1,7 @@ + +const Icons = { + discovery: require('./icon_discovery.png'), + // riveLike : require('./light_like.riv'), +} + +export default Icons; diff --git a/FLAD/assets/light_like.riv b/FLAD/assets/light_like.riv new file mode 100644 index 0000000000000000000000000000000000000000..8326bd450cc816279205dedac13293eb1f8144fe GIT binary patch literal 7522 zcmc&(ZBSI#89o=dsF7WE2?|RcSTwMTCYatTT4C?93#$|`K>@!eRT5XxU|?{KF_|h8 zYc$40V@)Dz1kqH3#xz<#rp^drrWGr#Gfmqc=@jFnnSR8Moh0ovwnN|dz31LNcbC2L zqtiNb59hpJ&vQQRdG3x2D(cHeG1e(D{FlKb70h&=7!dlEJ0?D z1MM!=iH&V&Xj8z>*z*CFkd#ujW_4rO9a^<2^i)`u9CdZSR-M?`+RkNNu|M+rZGM(0 zC!`JBsPa0VmVc`{v9YBOmG;?hX0PtcNM%WKVtV)Ucl_h9VQKQqQr-~!i=?gp%^lT= zjcs~&hTs0j{$f9+C7aTAn$m7~ZPyxG{Px~89U8_MQ}8Q1I3X!%Zd3C{AU-Aemg>aD z*4=&Lf}Q>Sf&vUugbCHxji062lVn@^_3+lfIBb|x-X#?<)^=gy^>AWYI?^nDt?W>cobM+S^7w z+shnsq2u1Ss#Is$)mqgpv1EC=>(iW9`)bEt-r%ca?3%y6@8UOm7GaM~lBZ|ZZXfb5 z_+r(dx)8$rOosS6Fl903F4Y72FrY^ZaLRk6f?uuPcOiG(*oXTj-g3ADlhP_K`C&(9 z;6t3X{Y#U7KnFYvUZ;K3Q=s<-_1a*U9-z~-{Kgytcqsk9X=K?7>N>%53Yn>;q?iPu+5KLQh?UJ#=EGuNLFAOsrwb z#IpUWk=dhV#&W2!;!tD7fimN9pv;kSsJG%!Z^eN!<8h$Ok#bmO#bKEh2g;1cfig$R zVTBck6;>Q5Gad)Z94Uv86^D=&2g;1cfig$RVXYO1wN@M`Gad)Z94UupD-O+894Ip$ z2g)2Nhp-iguoVZ&jK_g8N6KN76^Bh$94Ip$2g)2Nhs{%gwE1|4p`}uHVTXdT)9GUq*aUT8?pCj_wfYZUHlg%3%Yr}Z zz`wue_4QmCMALWLm!WA)27FmgP*=^jmH1BWP}S12zq>}EGcT3+D!w}zo$SMvCBEyA zJdSNQ-m`^QDKm9W*5C!iC@|g6$@%8Qr?tU){H`yT_y!-MY99NWeMenjFCU$*sOP5iXW2lSYDa57`{V>SRPN( zN0795aBvVEkfe28N+l$vArjL;paY@MLKL(+CHnIU`~fnsFfJt*avb1#SprsXOTod< zB^8Eyad=n?+Prl*yoy8MoHzjA`B^iZLc+|izw!zR`#-J_6VBj9x|EFjF?&e^fI_6!a6Nl*cz~}I4?fC=@P45813o;^-p<+npRirZ zW|+GTDAC4u;psSmE8n_Zxe6Y8tf&9yF9!I2@SNbkdOr8@MDQ4=qDwM)T*|T-toIQs z@QbNf(Tqi&oSBtzu+Tj`7I|DseGJw~#L9VMU+lcdb2=}l4|0r`0N9_c`6V+4}abJcxZ=%Pgq=+1kO2Ioy zBi@I5aB}2M{Xuz$lRfqcvR}R+)?)8N7V^VPLs0--rLhPv> zFZjTXFQtVWumd|Z2tQhArM2?`l^ z&vA^WH}S!fGfn#w@#MFBf{JLIh2v7Nw__acPxLz)<#8$D7%aGiVX1a+z|}L(0%4J- zw~3t}9t+*zG48nt7I|Dsa|{-~YQdx%dt&PwWwV zUBS`UZ3wti!{_>44&j1)^H8qdJd}$!hQ??&ms%N$o-||`^G+G6JOM`V`NAXfv=P^2 zMH`tU`M+2)qO`cG@8MxDfLRDSYqAR}tJ!rag(Q9+V(k%yHEKNy7=pf}E(KVwMzA=KTne2k5 znK8_7Oaue%IYsik=4V5#02cj&S^P0fzj+P0BW{tOmg4U@y1+@QX*=OJoOb%O&lmAi zCZ{N=Vr5h4KEU)Vd?di6yE-rzVf;jl1)foqx-i@j4!Nrvo@!k4OvwExo3m5m%K$xH z;Mr{GS2b)3wL(P68&V=GeM?F>EUjd755j+n`p}kuHm2JSNfM3|F+f5$4cUGvrBln2 LFhZpq=4Jl@p_85r literal 0 HcmV?d00001 diff --git a/FLAD/components/Card.tsx b/FLAD/components/Card.tsx index 290c300..65d9691 100644 --- a/FLAD/components/Card.tsx +++ b/FLAD/components/Card.tsx @@ -75,6 +75,8 @@ const Card = ({ title, image, onSwipe} : CardProps) => { ( translateX.value, [-SCREEN_WIDTH / 4, 0, SCREEN_WIDTH / 2], [1, 0, 0]); + + return { opacity : opacityl, }; @@ -84,7 +86,7 @@ const Card = ({ title, image, onSwipe} : CardProps) => { const opacityl = interpolate ( translateX.value, [-SCREEN_WIDTH / 2, 0, SCREEN_WIDTH / 4], - [0.75, 1, 0.75]); + [0.85, 1, 1]); return { opacity : opacityl, @@ -93,7 +95,7 @@ const Card = ({ title, image, onSwipe} : CardProps) => { const opacDStyle = useAnimatedStyle(() => { const opacityl = interpolate ( translateY.value, - [-SCREEN_HEIGHT / 4, 0, SCREEN_HEIGHT / 2], + [-SCREEN_HEIGHT / 4, 0, SCREEN_HEIGHT / 4], [0, 0, 1]); return { opacity : opacityl, @@ -133,7 +135,7 @@ const Card = ({ title, image, onSwipe} : CardProps) => { - + { + const riveRef = React.useRef(null); + + const handlePlay = () => { riveRef.current?.play() }; + return ( + + + + ); + }; + +const styles = StyleSheet.create({ + button : { + justifyContent : 'center', + alignItems : 'center', + }, + image : { + borderRadius : 24, + resizeMode: 'cover', + width: 65, + height: 65, + backgroundColor: 'black', +} +}) + +export default FladButton; + + + + diff --git a/FLAD/components/input.tsx b/FLAD/components/input.tsx new file mode 100644 index 0000000..3de3b78 --- /dev/null +++ b/FLAD/components/input.tsx @@ -0,0 +1,30 @@ +import { useState } from 'react'; +import { View, Text, Image, Animated ,PanResponder, Dimensions, StyleSheet, ImageBackground, Button, Pressable, TextInput } from 'react-native' + +interface InputProps { + name : string; + placeholder : string; +} + +const FladInput = ({name, placeholder} : InputProps) => { + const [focused, setFocused] = useState(false); + + return ( + + + + + + + ); + }; + +const styles = StyleSheet.create({ + input : { + justifyContent : 'center', + alignItems : 'center', + placeholder : "placeholde" + }, +}) + +export default FladInput; \ No newline at end of file diff --git a/FLAD/package-lock.json b/FLAD/package-lock.json index 2073ca9..c90b1db 100644 --- a/FLAD/package-lock.json +++ b/FLAD/package-lock.json @@ -10,10 +10,14 @@ "dependencies": { "@react-navigation/native": "^6.1.2", "@react-navigation/native-stack": "^6.9.8", + "axios": "^1.2.6", "expo": "~47.0.12", + "expo-auth-session": "~3.8.0", "expo-cli": "^6.1.0", "expo-haptics": "~12.0.1", "expo-linear-gradient": "~12.0.1", + "expo-random": "~13.0.0", + "expo-secure-store": "~12.0.0", "expo-status-bar": "~1.4.2", "react": "18.1.0", "react-dom": "18.1.0", @@ -22,7 +26,8 @@ "react-native-reanimated": "~2.12.0", "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", - "react-native-web": "~0.18.9" + "react-native-web": "~0.18.9", + "rive-react-native": "^3.0.41" }, "devDependencies": { "@babel/core": "^7.12.9", @@ -5018,6 +5023,11 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz", "integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==" }, + "node_modules/@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + }, "node_modules/@types/react": { "version": "18.0.27", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz", @@ -5754,11 +5764,26 @@ } }, "node_modules/axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz", + "integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==", "dependencies": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" } }, "node_modules/babel-core": { @@ -7251,6 +7276,59 @@ "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" }, + "node_modules/compare-urls": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/compare-urls/-/compare-urls-2.0.0.tgz", + "integrity": "sha512-eCJcWn2OYFEIqbm70ta7LQowJOOZZqq1a2YbbFCFI1uwSvj+TWMwXVn7vPR1ceFNcAIt5RSTDbwdlX82gYLTkA==", + "dependencies": { + "normalize-url": "^2.0.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/compare-urls/node_modules/normalize-url": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-2.0.1.tgz", + "integrity": "sha512-D6MUW4K/VzoJ4rJ01JFKxDrtY1v9wrgzCX5f2qj/lzH1m/lW6MhUZFKerVsnyjOhOsYzI9Kqqak+10l4LvLpMw==", + "dependencies": { + "prepend-http": "^2.0.0", + "query-string": "^5.0.1", + "sort-keys": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/compare-urls/node_modules/prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/compare-urls/node_modules/query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "dependencies": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/compare-urls/node_modules/strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/compare-versions": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", @@ -9168,6 +9246,38 @@ "url-parse": "^1.5.9" } }, + "node_modules/expo-auth-session": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/expo-auth-session/-/expo-auth-session-3.8.0.tgz", + "integrity": "sha512-pQ8GryTTZL/JKHvifUGD4GGlZWo7RrcoQlvQ0O5m5edYfoa7fMHCg20MBX4Da4P3eVgJlqWZWCHfBC2fZxcRfA==", + "dependencies": { + "expo-constants": "~14.0.0", + "expo-crypto": "~12.0.0", + "expo-linking": "~3.3.0", + "expo-web-browser": "~12.0.0", + "invariant": "^2.2.4", + "qs": "6.9.1" + }, + "peerDependencies": { + "expo-random": "*" + }, + "peerDependenciesMeta": { + "expo-random": { + "optional": true + } + } + }, + "node_modules/expo-auth-session/node_modules/qs": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.1.tgz", + "integrity": "sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA==", + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/expo-cli": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/expo-cli/-/expo-cli-6.1.0.tgz", @@ -9931,6 +10041,14 @@ "expo": "*" } }, + "node_modules/expo-crypto": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-12.0.0.tgz", + "integrity": "sha512-2KC52eLYsXndDZOVFyr+K3Zs9wDgpqZ7F7fwAiUg+yNbE21CJrHKDFvo/Br0FAaDf/w9pUks5/qi1azB5sDzvg==", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-error-recovery": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/expo-error-recovery/-/expo-error-recovery-4.0.1.tgz", @@ -9986,6 +10104,18 @@ "expo": "*" } }, + "node_modules/expo-linking": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/expo-linking/-/expo-linking-3.3.0.tgz", + "integrity": "sha512-wXPzI2kijnql2L2F6i8zP1zINTkYlcRXyh1iV3P6Bt57v6yZiiniZBnb6grJVj19LOmluNs0PYrbX1ZsHBChCg==", + "dependencies": { + "@types/qs": "^6.5.3", + "expo-constants": "~14.0.0", + "invariant": "^2.2.4", + "qs": "^6.9.1", + "url-parse": "^1.5.9" + } + }, "node_modules/expo-modules-autolinking": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-1.0.2.tgz", @@ -10311,11 +10441,41 @@ "node": ">= 10.0.0" } }, + "node_modules/expo-random": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/expo-random/-/expo-random-13.0.0.tgz", + "integrity": "sha512-aGb0vtUmFFuW0TF1rdOgsz89zEVD/RXUPUnnZy5+i3jJeQ2PerJ4uo72/EuWqHpCBNto8/qT+aCzFinmQDeTAA==", + "dependencies": { + "base64-js": "^1.3.0" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-secure-store": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-12.0.0.tgz", + "integrity": "sha512-Rz5lYr2NxrnFvIPwuWcseUSbdUjFxNZG0oVulqM9puuK7t5lDG3/SAy+J22ELBhaltuci2VVO6hCdFwRoRiG/Q==", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-status-bar": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-1.4.2.tgz", "integrity": "sha512-ZWjO6D4ARGYfAd3SWDD3STNudHDhyBZDZjhhseqoEmsf7bS9ykny8KKOhlzJW24qIQNPhkgdvHhaw9fQwMJy3Q==" }, + "node_modules/expo-web-browser": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-12.0.0.tgz", + "integrity": "sha512-7/RUuE0sv5kf+mTw5/SOnks0Am1ctoxvT1Xi53Nom2EuXTKBV+b2Kf5xAw3ItoW5W4MHJUX3FdNI6qc9sS9+Pw==", + "dependencies": { + "compare-urls": "^2.0.0" + }, + "peerDependencies": { + "expo": "*" + } + }, "node_modules/express": { "version": "4.16.4", "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", @@ -12750,6 +12910,14 @@ "node": ">=8" } }, + "node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -17033,6 +17201,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -18252,6 +18425,15 @@ "inherits": "^2.0.1" } }, + "node_modules/rive-react-native": { + "version": "3.0.41", + "resolved": "https://registry.npmjs.org/rive-react-native/-/rive-react-native-3.0.41.tgz", + "integrity": "sha512-N4BQuQwsPK98n8AITrMh/iG/AjCikKm6f1Wt+EMJa6hl987h68mM2z/4vul+CuigkMreiiIH6kUSOAMKMK98KA==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/router-ips": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/router-ips/-/router-ips-1.0.0.tgz", @@ -18978,6 +19160,17 @@ "node": ">=0.8.0" } }, + "node_modules/sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha512-/dPCrG1s3ePpWm6yBbxZq5Be1dXGLyLn9Z791chDC3NFrpkVbWGzkBwPN1knaciexFXgRJ7hzdnwZ4stHSDmjg==", + "dependencies": { + "is-plain-obj": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -22751,6 +22944,14 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/xdl/node_modules/axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "dependencies": { + "follow-redirects": "^1.10.0" + } + }, "node_modules/xdl/node_modules/body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -26924,6 +27125,11 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz", "integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==" }, + "@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + }, "@types/react": { "version": "18.0.27", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz", @@ -27546,11 +27752,25 @@ "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==" }, "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz", + "integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==", "requires": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } } }, "babel-core": { @@ -28698,6 +28918,46 @@ "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" }, + "compare-urls": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/compare-urls/-/compare-urls-2.0.0.tgz", + "integrity": "sha512-eCJcWn2OYFEIqbm70ta7LQowJOOZZqq1a2YbbFCFI1uwSvj+TWMwXVn7vPR1ceFNcAIt5RSTDbwdlX82gYLTkA==", + "requires": { + "normalize-url": "^2.0.1" + }, + "dependencies": { + "normalize-url": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-2.0.1.tgz", + "integrity": "sha512-D6MUW4K/VzoJ4rJ01JFKxDrtY1v9wrgzCX5f2qj/lzH1m/lW6MhUZFKerVsnyjOhOsYzI9Kqqak+10l4LvLpMw==", + "requires": { + "prepend-http": "^2.0.0", + "query-string": "^5.0.1", + "sort-keys": "^2.0.0" + } + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==" + }, + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "requires": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==" + } + } + }, "compare-versions": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", @@ -30196,6 +30456,26 @@ "url-parse": "^1.5.9" } }, + "expo-auth-session": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/expo-auth-session/-/expo-auth-session-3.8.0.tgz", + "integrity": "sha512-pQ8GryTTZL/JKHvifUGD4GGlZWo7RrcoQlvQ0O5m5edYfoa7fMHCg20MBX4Da4P3eVgJlqWZWCHfBC2fZxcRfA==", + "requires": { + "expo-constants": "~14.0.0", + "expo-crypto": "~12.0.0", + "expo-linking": "~3.3.0", + "expo-web-browser": "~12.0.0", + "invariant": "^2.2.4", + "qs": "6.9.1" + }, + "dependencies": { + "qs": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.1.tgz", + "integrity": "sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA==" + } + } + }, "expo-cli": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/expo-cli/-/expo-cli-6.1.0.tgz", @@ -30849,6 +31129,12 @@ "uuid": "^3.3.2" } }, + "expo-crypto": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-12.0.0.tgz", + "integrity": "sha512-2KC52eLYsXndDZOVFyr+K3Zs9wDgpqZ7F7fwAiUg+yNbE21CJrHKDFvo/Br0FAaDf/w9pUks5/qi1azB5sDzvg==", + "requires": {} + }, "expo-error-recovery": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/expo-error-recovery/-/expo-error-recovery-4.0.1.tgz", @@ -30890,6 +31176,18 @@ "integrity": "sha512-TMl/wBTVQOliL4S3DS5Aa3UFfVySr0mdJEHLG6kfBdMCLkr+tfLI2rGyJ+scS7xgMsvhTIaurhf1+Z0sL3aLCg==", "requires": {} }, + "expo-linking": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/expo-linking/-/expo-linking-3.3.0.tgz", + "integrity": "sha512-wXPzI2kijnql2L2F6i8zP1zINTkYlcRXyh1iV3P6Bt57v6yZiiniZBnb6grJVj19LOmluNs0PYrbX1ZsHBChCg==", + "requires": { + "@types/qs": "^6.5.3", + "expo-constants": "~14.0.0", + "invariant": "^2.2.4", + "qs": "^6.9.1", + "url-parse": "^1.5.9" + } + }, "expo-modules-autolinking": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-1.0.2.tgz", @@ -31130,11 +31428,33 @@ } } }, + "expo-random": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/expo-random/-/expo-random-13.0.0.tgz", + "integrity": "sha512-aGb0vtUmFFuW0TF1rdOgsz89zEVD/RXUPUnnZy5+i3jJeQ2PerJ4uo72/EuWqHpCBNto8/qT+aCzFinmQDeTAA==", + "requires": { + "base64-js": "^1.3.0" + } + }, + "expo-secure-store": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-12.0.0.tgz", + "integrity": "sha512-Rz5lYr2NxrnFvIPwuWcseUSbdUjFxNZG0oVulqM9puuK7t5lDG3/SAy+J22ELBhaltuci2VVO6hCdFwRoRiG/Q==", + "requires": {} + }, "expo-status-bar": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-1.4.2.tgz", "integrity": "sha512-ZWjO6D4ARGYfAd3SWDD3STNudHDhyBZDZjhhseqoEmsf7bS9ykny8KKOhlzJW24qIQNPhkgdvHhaw9fQwMJy3Q==" }, + "expo-web-browser": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-12.0.0.tgz", + "integrity": "sha512-7/RUuE0sv5kf+mTw5/SOnks0Am1ctoxvT1Xi53Nom2EuXTKBV+b2Kf5xAw3ItoW5W4MHJUX3FdNI6qc9sS9+Pw==", + "requires": { + "compare-urls": "^2.0.0" + } + }, "express": { "version": "4.16.4", "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", @@ -32989,6 +33309,11 @@ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==" }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==" + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -36417,6 +36742,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -37353,6 +37683,12 @@ "inherits": "^2.0.1" } }, + "rive-react-native": { + "version": "3.0.41", + "resolved": "https://registry.npmjs.org/rive-react-native/-/rive-react-native-3.0.41.tgz", + "integrity": "sha512-N4BQuQwsPK98n8AITrMh/iG/AjCikKm6f1Wt+EMJa6hl987h68mM2z/4vul+CuigkMreiiIH6kUSOAMKMK98KA==", + "requires": {} + }, "router-ips": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/router-ips/-/router-ips-1.0.0.tgz", @@ -37951,6 +38287,14 @@ } } }, + "sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha512-/dPCrG1s3ePpWm6yBbxZq5Be1dXGLyLn9Z791chDC3NFrpkVbWGzkBwPN1knaciexFXgRJ7hzdnwZ4stHSDmjg==", + "requires": { + "is-plain-obj": "^1.0.0" + } + }, "source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -40973,6 +41317,14 @@ "color-convert": "^2.0.1" } }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", diff --git a/FLAD/package.json b/FLAD/package.json index cac7a54..7b56a2f 100644 --- a/FLAD/package.json +++ b/FLAD/package.json @@ -11,19 +11,24 @@ "dependencies": { "@react-navigation/native": "^6.1.2", "@react-navigation/native-stack": "^6.9.8", + "axios": "^1.2.6", "expo": "~47.0.12", + "expo-auth-session": "~3.8.0", "expo-cli": "^6.1.0", + "expo-haptics": "~12.0.1", + "expo-linear-gradient": "~12.0.1", + "expo-random": "~13.0.0", "expo-status-bar": "~1.4.2", "react": "18.1.0", "react-dom": "18.1.0", "react-native": "0.70.5", + "react-native-gesture-handler": "~2.8.0", + "react-native-reanimated": "~2.12.0", "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", "react-native-web": "~0.18.9", - "expo-linear-gradient": "~12.0.1", - "react-native-reanimated": "~2.12.0", - "react-native-gesture-handler": "~2.8.0", - "expo-haptics": "~12.0.1" + "rive-react-native": "^3.0.41", + "expo-secure-store": "~12.0.0" }, "devDependencies": { "@babel/core": "^7.12.9", diff --git a/FLAD/pages/login.tsx b/FLAD/pages/login.tsx new file mode 100644 index 0000000..c140153 --- /dev/null +++ b/FLAD/pages/login.tsx @@ -0,0 +1,136 @@ +import { View, Text, Image, Animated ,PanResponder, Dimensions, StyleSheet, ImageBackground, Button, Pressable, Touchable, TouchableOpacity, Modal, SafeAreaView, TextInput, Platform } from 'react-native' +import React, { useCallback, useEffect, useRef, useState, useTransition } from 'react' +import { LinearGradient } from 'expo-linear-gradient'; +import * as Haptics from 'expo-haptics'; +import * as AuthSession from 'expo-auth-session'; + +import Card from '../components/Card'; +import axios from 'axios'; +import { cards as cardArray } from '../FakeData/data' +import FladButton from '../components/button/button'; +import * as WebBrowser from 'expo-web-browser'; +import { makeRedirectUri, useAuthRequest } from 'expo-auth-session'; + +const SCREEN_WIDTH = Dimensions.get('window').width + +import * as SecureStore from 'expo-secure-store'; + +interface LoginProps { +} +interface Params { + [key: string]: string; + } + + interface Profile { + display_name: string; + email: string; + id: string; + } +//generate random string + const MY_SECURE_AUTH_STATE_KEY = 'MySecureAuthStateKey'; + + WebBrowser.maybeCompleteAuthSession(); + +// Endpoint +const discovery = { + authorizationEndpoint: 'https://accounts.spotify.com/authorize', + tokenEndpoint: 'https://accounts.spotify.com/api/token', +}; + + +async function save(key : string, value : string) { + await SecureStore.setItemAsync(key, value); +} + +export default function Login() { + // const [advice, setAdvice] = useState("dd"); + const [request, response, promptAsync] = useAuthRequest( + { + responseType: AuthSession.ResponseType.Token, + clientId: '1f1e34e4b6ba48b388469dba80202b10', + scopes: ['user-read-private','user-read-email','user-read-playback-state','user-read-currently-playing','user-read-recently-played','playlist-modify-public','ugc-image-upload','user-modify-playback-state'], + redirectUri: makeRedirectUri({ + scheme: 'flad' + }), + }, + discovery + ); + + const getAdvice = async () => { axios.get("http://localhost:8080/api/spotify/exchange") + .then(response => { + console.log(response.data.message); + + // setAdvice(response.data.message); + }).catch(function (error) { + console.log(error); + }); + }; + React.useEffect(() => { + if (response && response.type === 'success') { + const auth = response.params.access_token; + const storageValue = JSON.stringify(auth); + + if (Platform.OS !== 'web') { + // Securely store the auth on your device + save(MY_SECURE_AUTH_STATE_KEY, storageValue); + } + } + }, [response]); + + return ( + + Hello flad test logIn + */} + ))} @@ -68,7 +88,6 @@ const Spot: React.FC = () => { ); }; - const styles = StyleSheet.create({ spot : { flex: 1, @@ -77,4 +96,3 @@ const Spot: React.FC = () => { } }) - export default Spot; \ No newline at end of file diff --git a/FLAD/services/Auth/authentificationService.service.tsx b/FLAD/services/Auth/authentificationService.service.tsx new file mode 100644 index 0000000..420130f --- /dev/null +++ b/FLAD/services/Auth/authentificationService.service.tsx @@ -0,0 +1,33 @@ +export class AuthentificationService { + + constructor(private auth: Auth, private http: HttpClient) { } + name = "toto"; + + async register({ email, password }) { + try { + const user = await createUserWithEmailAndPassword(this.auth, email, password); + return user; + } catch (e) { + return null; + } + } + async login({ email, password }) { + // should for all method use a cloud function to creata user + try { + const user = await signInWithEmailAndPassword(this.auth, email, password); + return user; + } catch (e) { + return null; + } + } + + logout() { + return signOut(this.auth); + } + + +} + + + + diff --git a/FLAD/services/spotify/ApiSpotifyIdentification.tsx b/FLAD/services/spotify/ApiSpotifyIdentification.tsx index 0e8904f..e69de29 100644 --- a/FLAD/services/spotify/ApiSpotifyIdentification.tsx +++ b/FLAD/services/spotify/ApiSpotifyIdentification.tsx @@ -1,21 +0,0 @@ - -// export class ApiSpotifyIdentification { - -// private state : string; -// private codeVerifier : string; -// private codeChallenge : string; -// private encodedLogs : string; -// constructor(){ -// // this.state = _generateRandomString(16); -// // this.codeVerifier = _generateRandomString(_generateRandomInt(43, 128)); -// // this.codeChallenge = _generateCodeChallenge(); -// // this.encodedLogs = base64.encode(utf8.encode("$clientId:$_clientSecret")); -// } - -// setCode(url : string){ -// throw new Error("Not implemented"); -// } -// createToken(url : string){ -// throw new Error("Not implemented"); -// } -// } diff --git a/FLAD/services/spotify/spotify.service.ts b/FLAD/services/spotify/spotify.service.ts index 9573c73..3500dd8 100644 --- a/FLAD/services/spotify/spotify.service.ts +++ b/FLAD/services/spotify/spotify.service.ts @@ -1,30 +1,25 @@ -// import { ApiSpotifyIdentification } from "./ApiSpotifyIdentification"; -// import { SpotifyRequest } from "./spotifyRequestHandler/spotifyRequest"; - - -// export class SpotifyService { - -// private identification : ApiSpotifyIdentification; -// public request : SpotifyRequest; - -// constructor() { -// this.identification= new ApiSpotifyIdentification(); -// this.request = new SpotifyRequest(); -// } - -// get id(){ -// return this.identification; -// } - -// async apiAuth(url : string) { -// await this.identification.setCode(url); -// this.request = ApiSpotifyRequests(await this.identification.createToken()); -// } - -// async getSpotifyCredentials() { -// const res = await axios.get('/api/spotify-credentials') -// const spotifyCredentials = res.data -// return spotifyCredentials -// } - -// } +import axios from "axios"; + + +export default class SpotifyService { + private readonly API_URL = "http://localhost:8080/api/spotify/exchange"; + + constructor() { + + } + // get id(){ + // return this.identification; + // } + + // async apiAuth(url : string) { + // await this.identification.setCode(url); + // // this.request = ApiSpotifyRequests(await this.identification.createToken()); + // } + async getSpotifyCredentials() { + const res = await axios.get(this.API_URL) + // then verify error + const spotifyCredentials = res.data; + return spotifyCredentials + } + +} diff --git a/FLAD/services/user/userService.service.tsx b/FLAD/services/user/userService.service.tsx new file mode 100644 index 0000000..92d7968 --- /dev/null +++ b/FLAD/services/user/userService.service.tsx @@ -0,0 +1,27 @@ +import { AuthentificationService } from "../Auth/authentificationService.service"; + +export class UserService { + + constructor(private auth: AuthentificationService) {} + + getUserProfile() { + const user = this.auth.currentUser; + const userDocRef = doc(this.firestore, `User/${user.uid}`); + return docData(userDocRef); + } + async uploadName(name: string, email : string) { + const user = this.auth.currentUser; + try { + const userDocRef = doc(this.firestore, `User/${user.uid}`); + await setDoc(userDocRef, { + name, + email + }); + return true; + } catch (e) { + return null; + } + } + + +}