merge fin page quote

pull/49/head
kevin.modejar 4 weeks ago
commit 3af8f722b6

@ -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<Comment> = 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"),
)
}

@ -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
)

@ -1,6 +1,7 @@
package com.example.what_the_fantasy.data.services
import com.example.what_the_fantasy.data.model.Favorite
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
@ -11,10 +12,13 @@ interface IServices {
fun EditImage(imageURL : String, index : Int)
fun ChangeLangage(user: User)
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(user: User): List<Quote>
fun getAllUsers(): List<User>
fun getComment(quoteId : Int) : List<Comment>
fun getUserById(id: Int): User?
fun SearchQuote(quote : String)

@ -1,64 +1,81 @@
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.Favorite
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
//class ServicesAPI : IServices {
// override fun EditUsername(username: String, index : Int) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun EditEmail(email: String, index : Int) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun EditPasswd(passwd: String, index : Int) {
// TODO("Not yet implemented")
// }
//
// override fun EditImage(imageURL: String, index : Int) {
// TODO("Not yet implemented")
// }
//
// override fun ChangeLangage(user: User) {
// TODO("Not yet implemented")
// }
//
// override fun CreateUser(username: String, email: String, passwd: String, services: IServices) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun SearchQuote(quote: String) {
// TODO("Not yet implemented")
// }
//
// override fun getQuote(id: Int): Quote? {
// TODO("Not yet implemented")
// }
//
// override fun isFavorite(id: Int): Boolean {
// TODO("Not yet implemented")
// }
//
// override fun getAllFavorite(): List<Favorite> {
// TODO("Not yet implemented")
// }
// override fun getAllQuote(): List<Quote> {
// TODO("Not yet implemented")
// }
//
// override fun getFavorite(user: User): Favorite {
// TODO("Not yet implemented")
// }
//
// override fun getAllUsers(): List<User> {
// TODO("Not yet implemented")
// }
//
// override fun getUserById(id: Int): User? {
// TODO("Not yet implemented")
// }
//
//}
class ServicesAPI : IServices {
override fun EditUsername(username: String, index : Int): Boolean {
TODO("Not yet implemented")
}
override fun EditEmail(email: String, index : Int): Boolean {
TODO("Not yet implemented")
}
override fun EditPasswd(passwd: String, index : Int) {
TODO("Not yet implemented")
}
override fun EditImage(imageURL: String, index : Int) {
TODO("Not yet implemented")
}
override fun ChangeLangage(user: User) {
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")
}
override fun getFavorite(user: User): List<Quote> {
TODO("Not yet implemented")
}
override fun SearchQuote(quote: String) {
TODO("Not yet implemented")
}
override fun getQuote(id: Int): Quote? {
TODO("Not yet implemented")
}
override fun isFavorite(id: Int): Boolean {
TODO("Not yet implemented")
}
override fun getAllFavorite(): List<Favorite> {
TODO("Not yet implemented")
}
override fun getAllQuote(): List<Quote> {
TODO("Not yet implemented")
}
override fun getAllUsers(): List<User> {
TODO("Not yet implemented")
}
override fun getComment(quoteId: Int): List<Comment> {
TODO("Not yet implemented")
}
override fun getUserById(id: Int): User? {
TODO("Not yet implemented")
}
}

@ -1,12 +1,16 @@
package com.example.what_the_fantasy.data.services
import android.annotation.SuppressLint
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.FavoriteStub.favorites
import com.example.what_the_fantasy.data.local.QuoteStub.quotes
import com.example.what_the_fantasy.data.model.Favorite
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
@ -63,6 +67,19 @@ class ServicesStub : IServices {
logsUser.logDebugUserLangage(user, "ChangeLangue")
}
override fun AddFav(userId: Int, QuoteId: Int) {
return
}
override fun SupFav(userId: Int, QuoteId: Int) {
return
}
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)
@ -91,6 +108,8 @@ class ServicesStub : IServices {
override fun getAllQuote(): List<Quote> = quotes
override fun getAllUsers(): List<User> = users
override fun getComment(quoteId: Int): List<Comment> = comments
override fun getUserById(id: Int): User? {
return (users.find { it.id == id+1 })
}

@ -147,7 +147,7 @@ fun ButtonIconPainterInt(img : Painter, name : String, nav : (Int)->Unit,index:
Icon(img,
contentDescription = name,
modifier = Modifier
.fillMaxSize()
.size(50.dp)
)
}
}

@ -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,7 +33,12 @@ 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
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
@ -33,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
@ -41,6 +61,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,7 +73,8 @@ fun QuotePage(
navQuiz: (Int) -> Unit,
navProfil:(Int) -> Unit)
{
var quote = service.getQuote(quoteId) ?: return
// utiliser ViewModel
val quote = service.getQuote(quoteId) ?: return
val context = LocalContext.current
NavBar(onProfile = true,
index = index,
@ -85,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 + '"'
@ -118,6 +143,24 @@ fun QuotePage(
}
}
}
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, service)
LstComment(service.getComment(quoteId))
}
}
}
}
}
@ -146,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()
) {
@ -156,13 +199,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)
},
@ -175,7 +218,9 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){
)
}
IconButton(
onClick = { }, //Go to comment
onClick = {
isCommentVisible = !isCommentVisible
},
modifier = Modifier.padding(start = 20.dp)
){
Icon(
@ -187,7 +232,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){
if(isFavorite){
IconButton(
onClick = { }, //Go to comment
onClick = { service.SupFav(userId = userId, QuoteId = id)}, //sup fav
modifier = Modifier.padding(start = 20.dp)
){
Icon(
@ -200,7 +245,7 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){
}
else{
IconButton(
onClick = { }, //Go to comment
onClick = { service.AddFav(userId = userId, QuoteId = id)}, //add fav
modifier = Modifier.padding(start = 50.dp)
){
Icon(
@ -252,3 +297,83 @@ fun LikeInfo(likes : Int){
tint = iconText,
)
}
@Composable
fun AddComment(userId : Int, service: IServices){
var text by remember { mutableStateOf("") }
Row(modifier = Modifier.padding(bottom = 15.dp, top = 15.dp)){
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 = { service.AddComment(text)}, //send comment
){
Icon(
Icons.AutoMirrored.Filled.Send,
contentDescription = stringResource(R.string.send),
tint = iconText
)
}
}
}
@Composable
fun LstComment(lst : List<Comment>){
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),
)
}
}
}
}
}

@ -13,6 +13,7 @@
<string name="favorite">Favoris</string>
<string name="like">Likes</string>
<string name="profilePict">Image de profil</string>
<string name="send">Envoyer</string>
//Page Login
<string name="titleLogin">Connexion au compte</string>

@ -8,10 +8,11 @@
<string name="charac">Character</string>
<string name="source">Source</string>
<string name="share">Share</string>
<string name="comment">comment</string>
<string name="favorite">favorite</string>
<string name="like">likes</string>
<string name="comment">Comment</string>
<string name="favorite">Favorite</string>
<string name="like">Likes</string>
<string name="profilePict">Profile picture</string>
<string name="send">Send</string>
//Page Login
<string name="titleLogin">Account login</string>

Loading…
Cancel
Save