From 2f57ac9d826d221058ac5ef2b54b1f5b7b678458 Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Fri, 7 Mar 2025 12:01:15 +0100 Subject: [PATCH 1/4] debut mvvm et commentaire --- .../data/mvvm/AppViewModel.kt | 9 +++++++ .../what_the_fantasy/ui/screens/QuotePage.kt | 27 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt new file mode 100644 index 0000000..2a845ae --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt @@ -0,0 +1,9 @@ +package com.example.what_the_fantasy.data.mvvm + +import androidx.lifecycle.ViewModel +import com.example.what_the_fantasy.data.model.Quiz +import com.example.what_the_fantasy.data.model.Quote + +class AppViewModel: ViewModel() { + +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt index 16dcfac..2a6aa15 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt @@ -20,6 +20,10 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -41,6 +45,8 @@ import com.example.what_the_fantasy.ui.theme.iconText import com.example.what_the_fantasy.ui.theme.likeIcon import com.example.what_the_fantasy.ui.theme.whiteBackcgroundText +var isCommentVisible by mutableStateOf(false) + @Composable fun QuotePage( quoteId : Int, @@ -51,6 +57,7 @@ fun QuotePage( navQuiz: (Int) -> Unit, navProfil:(Int) -> Unit) { + // utiliser ViewModel var quote = service.getQuote(quoteId) ?: return val context = LocalContext.current NavBar(onProfile = true, @@ -118,6 +125,13 @@ fun QuotePage( } } } + if(isCommentVisible){ + Box(modifier = Modifier.fillMaxWidth().background(Color.White)){ + Column { + + } + } + } } } @@ -175,7 +189,14 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ ) } IconButton( - onClick = { }, //Go to comment + onClick = { + if(isCommentVisible){ + isCommentVisible = false + } + else{ + isCommentVisible = true + } + }, //Go to comment modifier = Modifier.padding(start = 20.dp) ){ Icon( @@ -251,4 +272,6 @@ fun LikeInfo(likes : Int){ contentDescription = stringResource(R.string.favorite), tint = iconText, ) -} \ No newline at end of file +} + + From d554b87ab8b04b2c20720ddf09b08a464d472704 Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Mon, 17 Mar 2025 11:41:29 +0100 Subject: [PATCH 2/4] commentaire entity + stub / ajout get comment service / affichage ajout commentaire + liste commentaire / animation apparition commentaire --- .../data/local/CommentStub.kt | 39 +++++ .../what_the_fantasy/data/model/Comment.kt | 8 ++ .../data/services/IServices.kt | 3 +- .../data/services/ServicesAPI.kt | 5 + .../data/services/ServicesStub.kt | 4 + .../what_the_fantasy/ui/screens/QuotePage.kt | 135 +++++++++++++++--- .../app/src/main/res/values-fr/strings.xml | 1 + .../app/src/main/res/values/strings.xml | 1 + 8 files changed, 179 insertions(+), 17 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/local/CommentStub.kt create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/model/Comment.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/local/CommentStub.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/local/CommentStub.kt new file mode 100644 index 0000000..0009b0c --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/local/CommentStub.kt @@ -0,0 +1,39 @@ +package com.example.what_the_fantasy.data.local + +import com.example.what_the_fantasy.data.model.Comment +import com.example.what_the_fantasy.data.model.User + +object CommentStub { + val comments: MutableList = mutableListOf( + Comment("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Trop bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("encore un Test","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Je suis la ","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'en ai rien a foutre de la citation","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Android c'est bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("je sais plus quoi mettre donc ca va être le bordel","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Et un test de plus","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("La bombe à été activer","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'aime pas les *****","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Test","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Trop bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("encore un Test","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Je suis la ","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'en ai rien a foutre de la citation","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Android c'est bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("je sais plus quoi mettre donc ca va être le bordel","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Et un test de plus","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("La bombe à été activer","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'aime pas les *****","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Test","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Trop bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("encore un Test","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Je suis la ","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'en ai rien a foutre de la citation","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Android c'est bien","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("je sais plus quoi mettre donc ca va être le bordel","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("Et un test de plus","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("La bombe à été activer","Dev","21-12-2005", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"), + Comment("J'aime pas les *****","Dev","21-12-2005", "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/data/model/Comment.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/model/Comment.kt new file mode 100644 index 0000000..2289d09 --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/model/Comment.kt @@ -0,0 +1,8 @@ +package com.example.what_the_fantasy.data.model + +data class Comment( + val content : String, + val user : String, + val date : String, + val img : String +) \ No newline at end of file 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 620ba60..8598128 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 @@ -1,5 +1,6 @@ package com.example.what_the_fantasy.data.services +import com.example.what_the_fantasy.data.model.Comment import com.example.what_the_fantasy.data.model.Quote import com.example.what_the_fantasy.data.model.User @@ -12,7 +13,7 @@ interface IServices { fun CreateUser(username : String, email : String, passwd : String, services : IServices) : Boolean fun getFavorite(username: String) fun getAllUsers(): List - + fun getComment(quoteId : Int) : List fun getUserById(id: Int): User? fun SearchQuote(quote : String) 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 facc895..5f85555 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 @@ -1,5 +1,6 @@ package com.example.what_the_fantasy.data.services +import com.example.what_the_fantasy.data.model.Comment import com.example.what_the_fantasy.data.model.Quote import com.example.what_the_fantasy.data.model.User import com.example.what_the_fantasy.ui.navigations.Destination @@ -45,6 +46,10 @@ class ServicesAPI : IServices { TODO("Not yet implemented") } + override fun getComment(quoteId: Int): List { + TODO("Not yet implemented") + } + override fun getUserById(id: Int): User? { 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 995918e..354b228 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,7 +5,9 @@ import android.util.Log 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.data.local.CommentStub.comments import com.example.what_the_fantasy.data.local.QuoteStub +import com.example.what_the_fantasy.data.model.Comment import com.example.what_the_fantasy.data.model.Quote import com.example.what_the_fantasy.data.model.SrcLanguage import com.example.what_the_fantasy.ui.components.hashPassword @@ -64,6 +66,8 @@ class ServicesStub : IServices { override fun getAllUsers(): List = users + override fun getComment(quoteId: Int): List = comments + override fun getUserById(id: Int): User? { return (users.find { it.id == id+1 }) } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt index 2a6aa15..91448c4 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt @@ -2,16 +2,30 @@ package com.example.what_the_fantasy.ui.screens import android.content.Context import android.content.Intent +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.expandVertically +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkVertically +import androidx.compose.animation.slideInVertically +import androidx.compose.animation.slideOutVertically import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row 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.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.Send import androidx.compose.material.icons.filled.Favorite import androidx.compose.material.icons.filled.FavoriteBorder import androidx.compose.material.icons.filled.MailOutline @@ -19,6 +33,7 @@ import androidx.compose.material.icons.filled.Share import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -37,6 +52,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.example.what_the_fantasy.R import coil.compose.AsyncImage +import com.example.what_the_fantasy.data.model.Comment 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.theme.colorBackground @@ -58,7 +74,7 @@ fun QuotePage( navProfil:(Int) -> Unit) { // utiliser ViewModel - var quote = service.getQuote(quoteId) ?: return + val quote = service.getQuote(quoteId) ?: return val context = LocalContext.current NavBar(onProfile = true, index = index, @@ -125,13 +141,27 @@ fun QuotePage( } } } - if(isCommentVisible){ - Box(modifier = Modifier.fillMaxWidth().background(Color.White)){ + AnimatedVisibility( + visible = isCommentVisible, + enter = expandVertically( + expandFrom = Alignment.CenterVertically + ) + fadeIn( + initialAlpha = 0.3f + ) + slideInVertically( + initialOffsetY = { -40 } + ), + exit = slideOutVertically() + shrinkVertically() + fadeOut() + ) { + Box(modifier = Modifier.fillMaxWidth().background(gradienBox).fillMaxSize()){ Column { - + AddComment(index) + LstComment(service.getComment(quoteId)) } } } + if(isCommentVisible){ + + } } } @@ -170,13 +200,13 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ val sendIntent = Intent().apply { action = Intent.ACTION_SEND // lien a changer quand le site sra deployer - putExtra(Intent.EXTRA_TEXT, "http://wfWebsite/quote/" + id.toString() ) + putExtra(Intent.EXTRA_TEXT, "http://wfWebsite/quote/$id") type = "text/plain" - addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // Ajout pour compatibilité + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } val shareIntent = Intent.createChooser(sendIntent, null) - shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // Ajout aussi ici + shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(shareIntent) }, @@ -190,13 +220,8 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ } IconButton( onClick = { - if(isCommentVisible){ - isCommentVisible = false - } - else{ - isCommentVisible = true - } - }, //Go to comment + isCommentVisible = !isCommentVisible + }, modifier = Modifier.padding(start = 20.dp) ){ Icon( @@ -208,7 +233,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ if(isFavorite){ IconButton( - onClick = { }, //Go to comment + onClick = { }, //sup fav modifier = Modifier.padding(start = 20.dp) ){ Icon( @@ -221,7 +246,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ } else{ IconButton( - onClick = { }, //Go to comment + onClick = { }, //add fav modifier = Modifier.padding(start = 50.dp) ){ Icon( @@ -274,4 +299,82 @@ fun LikeInfo(likes : Int){ ) } +@Composable +fun AddComment(userId : Int){ + var text by remember { mutableStateOf("") } + Row{ + IconButton( + onClick = { isCommentVisible = !isCommentVisible}, + ){ + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = stringResource(R.string.send), + tint = iconText + ) + } + TextField( + value = text, + onValueChange = { text = it }, + label = { Text(stringResource(R.string.comment)) }, + modifier = Modifier.drawBehind { + drawRoundRect( + Color.White, + cornerRadius = CornerRadius(15.dp.toPx()) + ) + } + .width(300.dp) + ) + IconButton( + onClick = { }, //send comment + ){ + Icon( + Icons.AutoMirrored.Filled.Send, + contentDescription = stringResource(R.string.send), + tint = iconText + ) + } + } +} + +@Composable +fun LstComment(lst : List){ + LazyColumn( + verticalArrangement = Arrangement.spacedBy(4.dp), + ) { + items( + items = lst, + ) { + Column( + modifier = Modifier.padding(5.dp) + .fillMaxSize() + .drawBehind { + drawRoundRect( + Color.White, + cornerRadius = CornerRadius(15.dp.toPx()) + ) + } + ) { + Row { + AsyncImage( + model = it.img, + contentDescription = stringResource(R.string.profilePict), + modifier = Modifier + .size(50.dp) + .clip(RoundedCornerShape(50)) + ) + Text( + text = it.user + " " + it.date, + modifier = Modifier.padding(start = 15.dp) + ) + } + Row { + Text( + text = it.content, + modifier = Modifier.padding(15.dp), + ) + } + } + } + } +} diff --git a/What_The_Fantasy/app/src/main/res/values-fr/strings.xml b/What_The_Fantasy/app/src/main/res/values-fr/strings.xml index 47d0063..680c90d 100644 --- a/What_The_Fantasy/app/src/main/res/values-fr/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values-fr/strings.xml @@ -13,6 +13,7 @@ Favoris Likes Image de profil + Envoyer //Page Login Connexion au compte diff --git a/What_The_Fantasy/app/src/main/res/values/strings.xml b/What_The_Fantasy/app/src/main/res/values/strings.xml index 0771fb9..dd450d6 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -12,6 +12,7 @@ favorite likes Profile picture + Send //Page Login Account login From afd5ca2a99d87a3fc0ac45f28cd1476e2847966b Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Wed, 19 Mar 2025 14:11:30 +0100 Subject: [PATCH 3/4] =?UTF-8?q?ajout=20des=20methode(pas=20encore=20implem?= =?UTF-8?q?enter)=20n=C3=A9c=C3=A9saire=20pour=20la=20fin=20de=20la=20page?= =?UTF-8?q?=20quote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/services/IServices.kt | 4 +++- .../data/services/ServicesAPI.kt | 12 ++++++++++ .../data/services/ServicesStub.kt | 13 +++++++++++ .../what_the_fantasy/ui/components/NavBar.kt | 2 +- .../what_the_fantasy/ui/screens/QuotePage.kt | 23 +++++++++---------- .../app/src/main/res/values/strings.xml | 6 ++--- 6 files changed, 43 insertions(+), 17 deletions(-) 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 8598128..d2d317a 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,9 @@ interface IServices { fun EditEmail(email : String, index : Int) fun EditPasswd(passwd : String, index : Int) fun EditImage(imageURL : String, index : Int) - + fun AddFav(userId: Int, QuoteId : Int) + fun SupFav(userId: Int, QuoteId : Int) + fun AddComment(content : String) 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 5f85555..9aee3ba 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 @@ -22,6 +22,18 @@ class ServicesAPI : IServices { TODO("Not yet implemented") } + override fun AddFav(userId: Int, QuoteId: Int) { + TODO("Not yet implemented") + } + + override fun SupFav(userId: Int, QuoteId: Int) { + TODO("Not yet implemented") + } + + override fun AddComment(content: String) { + TODO("Not yet implemented") + } + 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 354b228..b51c15f 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 @@ -45,6 +45,19 @@ class ServicesStub : IServices { TODO("Not yet implemented") } + override fun AddFav(userId: Int, QuoteId: Int) { + TODO("Not yet implemented") + } + + override fun SupFav(userId: Int, QuoteId: Int) { + TODO("Not yet implemented") + } + + override fun AddComment(content: String) { + TODO("Not yet implemented") + //comments.add(Comment(content = content,)) + } + override fun CreateUser(username: String, email: String, passwd: String, services : IServices) : Boolean { val date =dateDuJour() val passwordhash = hashPassword(passwd) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt index 8d89f41..391bb36 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt @@ -146,7 +146,7 @@ fun ButtonIconPainterInt(img : Painter, name : String, nav : (Int)->Unit,index: Icon(img, contentDescription = name, modifier = Modifier - .fillMaxSize() + .size(50.dp) ) } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt index 91448c4..094431b 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt @@ -108,9 +108,11 @@ fun QuotePage( // --/!\-- a modifier --/!\-- // isFavorite = service.isFavorite(id) // -------------------------- - true, + false, + userId = index, id = quoteId, - context = context + context = context, + service = service ) QuoteText( text = '"' + quote.content + '"' @@ -154,14 +156,11 @@ fun QuotePage( ) { Box(modifier = Modifier.fillMaxWidth().background(gradienBox).fillMaxSize()){ Column { - AddComment(index) + AddComment(index, service) LstComment(service.getComment(quoteId)) } } } - if(isCommentVisible){ - - } } } @@ -190,7 +189,7 @@ fun ImageQuote(imageUrl : String){ } @Composable -fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ +fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Context, service: IServices){ Row(modifier = Modifier .fillMaxWidth() ) { @@ -233,7 +232,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ if(isFavorite){ IconButton( - onClick = { }, //sup fav + onClick = { service.SupFav(userId = userId, QuoteId = id)}, //sup fav modifier = Modifier.padding(start = 20.dp) ){ Icon( @@ -246,7 +245,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ } else{ IconButton( - onClick = { }, //add fav + onClick = { service.AddFav(userId = userId, QuoteId = id)}, //add fav modifier = Modifier.padding(start = 50.dp) ){ Icon( @@ -300,9 +299,9 @@ fun LikeInfo(likes : Int){ } @Composable -fun AddComment(userId : Int){ +fun AddComment(userId : Int, service: IServices){ var text by remember { mutableStateOf("") } - Row{ + Row(modifier = Modifier.padding(bottom = 15.dp, top = 15.dp)){ IconButton( onClick = { isCommentVisible = !isCommentVisible}, ){ @@ -325,7 +324,7 @@ fun AddComment(userId : Int){ .width(300.dp) ) IconButton( - onClick = { }, //send comment + onClick = { service.AddComment(text)}, //send comment ){ Icon( Icons.AutoMirrored.Filled.Send, diff --git a/What_The_Fantasy/app/src/main/res/values/strings.xml b/What_The_Fantasy/app/src/main/res/values/strings.xml index dd450d6..f54602e 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -8,9 +8,9 @@ Character Source Share - comment - favorite - likes + Comment + Favorite + Likes Profile picture Send From eae5f8e085a4ef983acf2c73c8c9f4f3b1ba4db9 Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Mon, 24 Mar 2025 10:22:49 +0100 Subject: [PATCH 4/4] =?UTF-8?q?fin=20page=20quote=20(l=C3=A9g=C3=A8re=20mo?= =?UTF-8?q?dif=20=C3=A0=20faire=20avec=20les=20viewModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/what_the_fantasy/data/mvvm/AppViewModel.kt | 9 --------- .../what_the_fantasy/data/services/ServicesStub.kt | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt deleted file mode 100644 index 2a845ae..0000000 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.what_the_fantasy.data.mvvm - -import androidx.lifecycle.ViewModel -import com.example.what_the_fantasy.data.model.Quiz -import com.example.what_the_fantasy.data.model.Quote - -class AppViewModel: ViewModel() { - -} \ 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 index b51c15f..a546727 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 @@ -46,11 +46,11 @@ class ServicesStub : IServices { } override fun AddFav(userId: Int, QuoteId: Int) { - TODO("Not yet implemented") + return } override fun SupFav(userId: Int, QuoteId: Int) { - TODO("Not yet implemented") + return } override fun AddComment(content: String) {