From 3b51e3568d43cece7600aecb9e97147927dbc9c8 Mon Sep 17 00:00:00 2001 From: beaulaton Date: Fri, 21 Feb 2025 15:16:58 +0100 Subject: [PATCH] Ajout IServices avec ServicesStub et ServicesApi --- .../data/services/IServices.kt | 16 ++++++++++ .../data/services/ServicesAPI.kt | 31 +++++++++++++++++++ .../data/services/ServicesStub.kt | 31 +++++++++++++++++++ .../what_the_fantasy/ui/screens/LoginPage.kt | 2 -- .../what_the_fantasy/ui/screens/ProfilPage.kt | 21 ++++++------- 5 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt 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 new file mode 100644 index 0000000..df15ebd --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/IServices.kt @@ -0,0 +1,16 @@ +package com.example.what_the_fantasy.data.services + +interface IServices { + fun EditUsername(username : String) + fun EditEmail(email : String) + fun EditPasswd(passwd : String, passwdValid : String) + fun EditImage(imageURL : String) + + fun CreateUser(username : String, email : String, passwd : String, imageURL: String) + fun getFavorite(username: String) + + fun SearchQuote(quote : String) + + + +} \ No newline at end of file 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 new file mode 100644 index 0000000..9743f68 --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesAPI.kt @@ -0,0 +1,31 @@ +package com.example.what_the_fantasy.data.services + +class ServicesAPI : IServices { + override fun EditUsername(username: String) { + TODO("Not yet implemented") + } + + override fun EditEmail(email: String) { + TODO("Not yet implemented") + } + + override fun EditPasswd(passwd: String, passwdValid: String) { + TODO("Not yet implemented") + } + + override fun EditImage(imageURL: String) { + TODO("Not yet implemented") + } + + override fun CreateUser(username: String, email: String, passwd: String, imageURL: String) { + TODO("Not yet implemented") + } + + override fun SearchQuote(quote: String) { + TODO("Not yet implemented") + } + + override fun getFavorite(username: String) { + TODO("Not yet implemented") + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..8c84176 --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/services/ServicesStub.kt @@ -0,0 +1,31 @@ +package com.example.what_the_fantasy.data.services + +class ServicesStub : IServices { + override fun EditUsername(username: String) { + TODO("Not yet implemented") + } + + override fun EditEmail(email: String) { + TODO("Not yet implemented") + } + + override fun EditPasswd(passwd: String, passwdValid: String) { + TODO("Not yet implemented") + } + + override fun EditImage(imageURL: String) { + TODO("Not yet implemented") + } + + override fun CreateUser(username: String, email: String, passwd: String, imageURL: String) { + TODO("Not yet implemented") + } + + override fun SearchQuote(quote: String) { + TODO("Not yet implemented") + } + + override fun getFavorite(username: String) { + TODO("Not yet implemented") + } +} \ 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 d5d3fd7..47309cc 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 @@ -79,8 +79,6 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni } - - @Composable fun IdentifiantTextField(textIdentifiantResId : Int) : String{ val textIdentifiant = stringResource(id = textIdentifiantResId) 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 c2c0702..98e7838 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 @@ -65,16 +65,13 @@ import com.example.what_the_fantasy.ui.components.ErrorMessageProfileComponent 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.What_The_FantasyTheme +import com.example.what_the_fantasy.ui.theme.gradienBox @Composable fun ProfilPage(index: Int, navController: NavController) { - val gradient = 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 user = UserStub.allUsers - //val index = 2 // Pour changer l'utilisateur pour le moment + + val userList = UserStub.allUsers + val user = userList[index] Box( modifier = Modifier @@ -87,7 +84,7 @@ fun ProfilPage(index: Int, navController: NavController) { .fillMaxWidth(0.9f) .padding(20.dp) .clip(RoundedCornerShape(16.dp)) - .background(gradient) + .background(gradienBox) .padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally ) { @@ -97,13 +94,13 @@ fun ProfilPage(index: Int, navController: NavController) { SpaceHeightComponent(16) // Image de profil - ImageProfil(user[index].imgUrl, 120, 2, Color.White) + ImageProfil(user.imgUrl, 120) SpaceHeightComponent(16) - EditUsername(user[index].username)// Édition du Username + EditUsername(user.username)// Édition du Username SpaceHeightComponent(16) - EditEmail(user[index].email)// Édition du Email + EditEmail(user.email)// Édition du Email Spacer(modifier = Modifier.height(8.dp)) EditPasswd() @@ -122,7 +119,7 @@ fun ProfilPage(index: Int, navController: NavController) { @Composable -fun ImageProfil(imgProfil : String, size :Int, sizeBorber : Int, colorBorder : Color){ +fun ImageProfil(imgProfil : String, size :Int){ AsyncImage( model = imgProfil,