From 1c4c27bff6898b3a0142d91b7ffc7457e0eac6e4 Mon Sep 17 00:00:00 2001 From: beaulaton Date: Wed, 5 Mar 2025 15:12:28 +0100 Subject: [PATCH] Modifications --- .../what_the_fantasy/Logs/LogsUsers.kt | 16 ++++++++++++++ .../data/services/IServices.kt | 2 +- .../data/services/ServicesAPI.kt | 2 +- .../data/services/ServicesStub.kt | 22 +++++++++---------- .../what_the_fantasy/ui/screens/LoginPage.kt | 21 +++++------------- .../what_the_fantasy/ui/screens/ProfilPage.kt | 17 ++++++-------- .../what_the_fantasy/ui/screens/SignUpPage.kt | 6 +---- .../what_the_fantasy/ui/theme/Color.kt | 4 ++-- .../app/src/main/res/values/colors.xml | 6 ++++- 9 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/Logs/LogsUsers.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/Logs/LogsUsers.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/Logs/LogsUsers.kt new file mode 100644 index 0000000..2e16aa8 --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/Logs/LogsUsers.kt @@ -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, 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}") + } +} diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt index 5f8ab42..1b66358 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt @@ -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 diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt index bf6d27e..25cd320 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt @@ -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") } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt index f87ede9..192de77 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt @@ -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, titleLog : String){ - for(user in users){ - Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.password}") - } + fun randomImage(usersImage : List) : String{ + return "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg" } } \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt index 913795b..153a535 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt @@ -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, 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, 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) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt index 02d00bc..6d6a2b9 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt @@ -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) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt index bb51217..84e592b 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt @@ -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) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt index 880122c..dcced89 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt @@ -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 \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/res/values/colors.xml b/What_The_Fantasy/app/src/main/res/values/colors.xml index f8c6127..86395c4 100644 --- a/What_The_Fantasy/app/src/main/res/values/colors.xml +++ b/What_The_Fantasy/app/src/main/res/values/colors.xml @@ -5,6 +5,10 @@ #FF3700B3 #FF03DAC5 #FF018786 - #FF000000 #FFFFFFFF + + + #FF100C1B + #FF7B1FA2 + #FF311B92 \ No newline at end of file