resolution merge

pull/39/head
brongniart 2 months ago
commit 1d53d2665d

@ -0,0 +1,16 @@
package com.example.what_the_fantasy.Logs
import android.util.Log
import com.example.what_the_fantasy.data.model.User
class LogsUsers{
fun logDebugDisplayUsers(users : List<User>, titleLog : String){
for(user in users){
Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.imgUrl}")
}
}
fun logDebugDisplayUser(user : User, titleLog : String){
Log.e(titleLog, "User created: ${user.username} => ${user.email}")
}
}

@ -9,7 +9,7 @@ interface IServices {
fun EditPasswd(passwd : String, index : Int) fun EditPasswd(passwd : String, index : Int)
fun EditImage(imageURL : String, index : Int) fun EditImage(imageURL : String, index : Int)
fun CreateUser(username : String, email : String, passwd : String, imageURL: String, services : IServices) : Boolean fun CreateUser(username : String, email : String, passwd : String, services : IServices) : Boolean
fun getFavorite(username: String) fun getFavorite(username: String)
fun getAllUsers(): List<User> fun getAllUsers(): List<User>

@ -19,7 +19,7 @@ class ServicesAPI : IServices {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun CreateUser(username: String, email: String, passwd: String, imageURL: String, services: IServices) : Boolean { override fun CreateUser(username: String, email: String, passwd: String, services: IServices) : Boolean {
TODO("Not yet implemented") TODO("Not yet implemented")
} }

@ -5,17 +5,19 @@ import android.util.Log
import com.example.what_the_fantasy.data.local.UserStub import com.example.what_the_fantasy.data.local.UserStub
import com.example.what_the_fantasy.data.local.UserStub.users import com.example.what_the_fantasy.data.local.UserStub.users
import com.example.what_the_fantasy.data.model.User import com.example.what_the_fantasy.data.model.User
import com.example.what_the_fantasy.Logs.LogsUsers
import com.example.what_the_fantasy.ui.components.hashPassword import com.example.what_the_fantasy.ui.components.hashPassword
import java.time.LocalDate import java.time.LocalDate
class ServicesStub : IServices { class ServicesStub : IServices {
val logsUser = LogsUsers() //gestion des logs pour les utilisateurs
override fun EditUsername(username: String, index : Int) { override fun EditUsername(username: String, index : Int) {
val user = getUserById(index) val user = getUserById(index)
user?.username = username user?.username = username
//Afficher tous les users //Afficher tous les users
debugDisplayUser(getAllUsers(), "UsernameUpdate") logsUser.logDebugDisplayUsers(getAllUsers(), "UsernameUpdate")
} }
override fun EditEmail(email: String,index : Int) { override fun EditEmail(email: String,index : Int) {
@ -23,7 +25,7 @@ class ServicesStub : IServices {
user?.email = email user?.email = email
//Afficher tous les users //Afficher tous les users
debugDisplayUser(getAllUsers(), "EmailUpdate") logsUser.logDebugDisplayUsers(getAllUsers(), "EmailUpdate")
} }
override fun EditPasswd(passwd: String,index : Int) { override fun EditPasswd(passwd: String,index : Int) {
@ -32,14 +34,14 @@ class ServicesStub : IServices {
user?.password = passwordhash user?.password = passwordhash
//Afficher tous les users en log //Afficher tous les users en log
debugDisplayUser(getAllUsers(), "PasswordUpdate") logsUser.logDebugDisplayUsers(getAllUsers(), "PasswordUpdate")
} }
override fun EditImage(imageURL: String,index : Int) { override fun EditImage(imageURL: String,index : Int) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun CreateUser(username: String, email: String, passwd: String, imageURL: String, services : IServices) : Boolean { override fun CreateUser(username: String, email: String, passwd: String, services : IServices) : Boolean {
val date =dateDuJour() val date =dateDuJour()
val passwordhash = hashPassword(passwd) val passwordhash = hashPassword(passwd)
@ -50,11 +52,11 @@ class ServicesStub : IServices {
return false return false
} }
} }
val user = User(nbUser+1,username, email, imageURL, date, passwordhash) val user = User(nbUser+1,username, email, date,randomImage(userStub), passwordhash)
users.add(user)//ajout au stub users.add(user)//ajout au stub
//Afficher tous les users //Afficher tous les users
debugDisplayUser(users, "CreateUser") logsUser.logDebugDisplayUsers(users, "CreateUser")
return true return true
} }
@ -80,10 +82,7 @@ class ServicesStub : IServices {
return date.toString() return date.toString()
} }
fun randomImage(usersImage : List<User>) : String{
private fun debugDisplayUser(users : List<User>, titleLog : String){ return "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"
for(user in users){
Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.password}")
}
} }
} }

@ -3,16 +3,28 @@ package com.example.what_the_fantasy.ui.screens
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.services.IServices import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.SpaceHeightComponent
import com.example.what_the_fantasy.ui.components.TitlePageComponent
import com.example.what_the_fantasy.ui.theme.colorBackground import com.example.what_the_fantasy.ui.theme.colorBackground
import com.example.what_the_fantasy.ui.theme.gradienBox
@Composable @Composable
fun FavoritePage( fun FavoritePage(
@ -35,7 +47,25 @@ fun FavoritePage(
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
){ ){
Column { Column {
Text("Favorite", color = Color.White, fontSize = 20.sp) Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFF100C1B)),
contentAlignment = Alignment.Center
) {
Row(
modifier = Modifier
.fillMaxWidth(0.9f)
.padding(20.dp)
.clip(RoundedCornerShape(16.dp))
.background(gradienBox)
.padding(20.dp),
) {
Text("Une image")
Text("Une citation d'un personnage")
}
}
} }
} }
} }

@ -74,10 +74,8 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
) { ) {
TitlePageComponent(R.string.titleLogin, 20,Color.White) TitlePageComponent(R.string.titleLogin, 20,Color.White)
val identifiant =IdentifiantTextField(R.string.IdentifiantLogin)
val passwd = PassWdTextField(R.string.PasswdLogin)
SpaceHeightComponent(16) SpaceHeightComponent(16)
ConnexionButtonLogin(users,identifiant, passwd, R.string.ButtonLogin,18, Color.White, Color.Black,navControllerProfil) ConnexionButtonLogin(users,IdentifiantTextField(R.string.IdentifiantLogin), PassWdTextField(R.string.PasswdLogin), R.string.ButtonLogin,18, Color.White, Color.Black,navControllerProfil)
SpaceHeightComponent(16) SpaceHeightComponent(16)
CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp) CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp)
} }
@ -100,7 +98,7 @@ fun IdentifiantTextField(textIdentifiantResId : Int) : String{
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp), .padding(top = 8.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
shape = RoundedCornerShape(16.dp) // 🔹 Bords arrondis shape = RoundedCornerShape(16.dp) // Bords arrondis
) )
} }
return identifiant; return identifiant;
@ -146,8 +144,8 @@ fun ConnexionButtonLogin(userStub : List<User>, id : String, passwd : String, ti
Text(title, fontSize = size.sp, color = colorText) Text(title, fontSize = size.sp, color = colorText)
} }
if( showError){ if(showError){
ErrorMessage() ErrorMessageProfileComponent(R.string.ErrorLogin)
} }
} }
@ -162,20 +160,11 @@ fun validLogin(identifiant : String, passwd : String, users : List<User>, navCon
navController(index) // Passer l'index à la fonction navController navController(index) // Passer l'index à la fonction navController
return true return true
} }
} }
return false return false
} }
@Composable
fun ErrorMessage() {
Text(
text = "Username or Password does not exist.",
color = Color.Red,
modifier = Modifier.padding(top = 8.dp)
)
}
@Composable @Composable
fun CreateAccountButton(titleResId : Int, size : Int, color : Color, navController: () -> Unit) { fun CreateAccountButton(titleResId : Int, size : Int, color : Color, navController: () -> Unit) {
val title = stringResource(id = titleResId) val title = stringResource(id = titleResId)

@ -26,7 +26,9 @@ import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.rounded.Face
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@ -105,13 +107,13 @@ fun ProfilPage(index: Int,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
// Titre // Titre
TitlePageComponent(R.string.titleProfile, 20, Color.White) TitlePageComponent(R.string.titleProfile, 20, Color.White)
SpaceHeightComponent(16) SpaceHeightComponent(16)
// Image de profil // Image de profil
ImageProfil(user.imgUrl, 120) ImageProfil(user.imgUrl, 120)
SpaceHeightComponent(16) SpaceHeightComponent(16)
EditUsername(user.username, index, services)// Édition du Username EditUsername(user.username, index, services)// Édition du Username
SpaceHeightComponent(16) SpaceHeightComponent(16)
@ -122,12 +124,12 @@ fun ProfilPage(index: Int,
EditPasswd(index, services) EditPasswd(index, services)
SpaceHeightComponent(16) SpaceHeightComponent(16)
// Bouton // Bouton
ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie //ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
SpaceHeightComponent(16) //SpaceHeightComponent(16)
ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
SpaceHeightComponent(16) SpaceHeightComponent(16)
ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White, navUnLog) ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White, navUnLog)
} }
} }
@ -199,7 +201,7 @@ fun EmailEditingField(
), ),
trailingIcon = { trailingIcon = {
IconButton(onClick = { if (!emailError) onDone() }) { IconButton(onClick = { if (!emailError) onDone() }) {
Icon(imageVector = Icons.Default.Check, contentDescription = "Valider") Icon(imageVector = Icons.Default.CheckCircle, contentDescription = "Valider")
} }
}, },
isError = emailError isError = emailError
@ -275,7 +277,7 @@ fun UsernameEditingField(
), ),
trailingIcon = { trailingIcon = {
IconButton(onClick = { onDone() }) { IconButton(onClick = { onDone() }) {
Icon(imageVector = Icons.Default.Check, contentDescription = "Valider") Icon(imageVector = Icons.Default.CheckCircle, contentDescription = "Valider")
} }
} }
) )
@ -315,7 +317,7 @@ fun EditPasswd(index: Int, service: IServices) {
// Fonction pour finaliser l'édition du mot de passe et appeler la méthode EditPasswd2 // Fonction pour finaliser l'édition du mot de passe et appeler la méthode EditPasswd2
fun onDoneEditing() { fun onDoneEditing() {
// Appeler EditPasswd2 pour mettre à jour le mot de passe de l'utilisateur // Appeler EditPasswd pour mettre à jour le mot de passe de l'utilisateur
service.EditPasswd(newPassword, index) service.EditPasswd(newPassword, index)
isEditingPassword = false isEditingPassword = false
} }
@ -456,11 +458,6 @@ fun DisplayPassword(onEdit: () -> Unit) {
} }
} }
@Composable @Composable
fun ButtonProfile(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){ fun ButtonProfile(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){
val text = stringResource(id = textResId) val text = stringResource(id = textResId)

@ -215,11 +215,10 @@ fun ConnexionButtonSign(
passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank() passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank()
if (!emailError && !passwordError && !usernameErrorEmpty && !passwordErrorEmpty) { if (!emailError && !passwordError && !usernameErrorEmpty && !passwordErrorEmpty) {
usernameErrorExist = !service.CreateUser(username, email, password, "https://img.freepik.com/vecteurs-libre/personnage-magicien-malefique-fantaisie_1045-193.jpg?size=338&ext=jpg", service) usernameErrorExist = !service.CreateUser(username, email, password, service)
if(!usernameErrorExist){ if(!usernameErrorExist){
navController() // retour à la page login navController() // retour à la page login
} }
} }
}, },
colors = ButtonDefaults.buttonColors(containerColor = colorButton), colors = ButtonDefaults.buttonColors(containerColor = colorButton),
@ -253,9 +252,6 @@ fun ConnexionButtonSign(
} }
@Composable @Composable
fun ReturnLogin(titleResId: Int, size: Int, color: Color, navController: () -> Unit) { fun ReturnLogin(titleResId: Int, size: Int, color: Color, navController: () -> Unit) {
val title = stringResource(id = titleResId) val title = stringResource(id = titleResId)

@ -3,6 +3,7 @@ package com.example.what_the_fantasy.ui.theme
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import com.example.what_the_fantasy.R
val Purple80 = Color(0xFFD0BCFF) val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC) val PurpleGrey80 = Color(0xFFCCC2DC)
@ -11,6 +12,7 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4) val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71) val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260) val Pink40 = Color(0xFF7D5260)
val gradienBox = Brush.linearGradient( val gradienBox = Brush.linearGradient(
colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)), // Violet clair → Violet foncé colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)), // Violet clair → Violet foncé
start = Offset(0f, 1000f), // Départ en bas à gauche start = Offset(0f, 1000f), // Départ en bas à gauche

@ -5,6 +5,10 @@
<color name="purple_700">#FF3700B3</color> <color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color> <color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="black">#FF100C1B</color>
<color name="light_purple">#FF7B1FA2</color>
<color name="dark_blue">#FF311B92</color>
</resources> </resources>
Loading…
Cancel
Save