From afd5ca2a99d87a3fc0ac45f28cd1476e2847966b Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Wed, 19 Mar 2025 14:11:30 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20des=20methode(pas=20encore=20implemente?= =?UTF-8?q?r)=20n=C3=A9c=C3=A9saire=20pour=20la=20fin=20de=20la=20page=20q?= =?UTF-8?q?uote?= 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