Modifications

pull/37/head
Leni BEAULATON 2 months ago
parent dc4b501aea
commit 1c4c27bff6

@ -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 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 getAllUsers(): List<User>

@ -19,7 +19,7 @@ class ServicesAPI : IServices {
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")
}

@ -5,16 +5,19 @@ import android.util.Log
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.model.User
import com.example.what_the_fantasy.Logs.LogsUsers
import com.example.what_the_fantasy.ui.components.hashPassword
import java.time.LocalDate
class ServicesStub : IServices {
val logsUser = LogsUsers() //gestion des logs pour les utilisateurs
override fun EditUsername(username: String, index : Int) {
val user = getUserById(index)
user?.username = username
//Afficher tous les users
debugDisplayUser(getAllUsers(), "UsernameUpdate")
logsUser.logDebugDisplayUsers(getAllUsers(), "UsernameUpdate")
}
@ -23,7 +26,7 @@ class ServicesStub : IServices {
user?.email = email
//Afficher tous les users
debugDisplayUser(getAllUsers(), "EmailUpdate")
logsUser.logDebugDisplayUsers(getAllUsers(), "EmailUpdate")
}
override fun EditPasswd(passwd: String,index : Int) {
@ -32,14 +35,14 @@ class ServicesStub : IServices {
user?.password = passwordhash
//Afficher tous les users en log
debugDisplayUser(getAllUsers(), "PasswordUpdate")
logsUser.logDebugDisplayUsers(getAllUsers(), "PasswordUpdate")
}
override fun EditImage(imageURL: String,index : Int) {
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 passwordhash = hashPassword(passwd)
@ -50,11 +53,11 @@ class ServicesStub : IServices {
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
//Afficher tous les users
debugDisplayUser(users, "CreateUser")
logsUser.logDebugDisplayUsers(users, "CreateUser")
return true
}
@ -80,10 +83,7 @@ class ServicesStub : IServices {
return date.toString()
}
private fun debugDisplayUser(users : List<User>, titleLog : String){
for(user in users){
Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.password}")
}
fun randomImage(usersImage : List<User>) : String{
return "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"
}
}

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

@ -26,7 +26,9 @@ import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
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.rounded.Face
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
@ -123,8 +125,8 @@ fun ProfilPage(index: Int,
SpaceHeightComponent(16)
// Bouton
ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
SpaceHeightComponent(16)
//ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
//SpaceHeightComponent(16)
ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
SpaceHeightComponent(16)
ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White, navUnLog)
@ -199,7 +201,7 @@ fun EmailEditingField(
),
trailingIcon = {
IconButton(onClick = { if (!emailError) onDone() }) {
Icon(imageVector = Icons.Default.Check, contentDescription = "Valider")
Icon(imageVector = Icons.Default.CheckCircle, contentDescription = "Valider")
}
},
isError = emailError
@ -275,7 +277,7 @@ fun UsernameEditingField(
),
trailingIcon = {
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
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)
isEditingPassword = false
}
@ -456,11 +458,6 @@ fun DisplayPassword(onEdit: () -> Unit) {
}
}
@Composable
fun ButtonProfile(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){
val text = stringResource(id = textResId)

@ -215,11 +215,10 @@ fun ConnexionButtonSign(
passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank()
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){
navController() // retour à la page login
}
}
},
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
@ -253,9 +252,6 @@ fun ConnexionButtonSign(
}
@Composable
fun ReturnLogin(titleResId: Int, size: Int, color: Color, navController: () -> Unit) {
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.graphics.Brush
import androidx.compose.ui.graphics.Color
import com.example.what_the_fantasy.R
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
@ -11,13 +12,12 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val gradienBox = Brush.linearGradient(
colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)), // Violet clair → Violet foncé
start = Offset(0f, 1000f), // Départ en bas à gauche
end = Offset(1000f, 0f) // Fin en haut à droite
)
val colorBackground = Color(0xFF100C1B)
val colorNavBar = Color(0xFF2F0E62)
val colorButtonNav = Color.Cyan

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