modif quote pour cohérence avec master

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

@ -6,7 +6,7 @@ import com.example.what_the_fantasy.data.model.Favorite
object FavoriteStub { object FavoriteStub {
val favorites: MutableList<Favorite> = mutableListOf( val favorites: MutableList<Favorite> = mutableListOf(
Favorite(users[0], mutableListOf(quotes[0], quotes[0], quotes[0])), // Aragorn123 aime ces citations Favorite(users[0], mutableListOf(quotes[0], quotes[1], quotes[12])), // Aragorn123 aime ces citations
Favorite(users[1], mutableListOf(quotes[5], quotes[6], quotes[7])), // Legolas456 aime ces citations Favorite(users[1], mutableListOf(quotes[5], quotes[6], quotes[7])), // Legolas456 aime ces citations
Favorite(users[2], mutableListOf(quotes[8], quotes[9], quotes[10])), // Gandalf789 aime ces citations Favorite(users[2], mutableListOf(quotes[8], quotes[9], quotes[10])), // Gandalf789 aime ces citations
Favorite(users[3], mutableListOf(quotes[11], quotes[12], quotes[13])), // FrodoBaggins aime ces citations Favorite(users[3], mutableListOf(quotes[11], quotes[12], quotes[13])), // FrodoBaggins aime ces citations

@ -25,7 +25,7 @@ interface IServices {
fun getQuote( id : Int): Quote? fun getQuote( id : Int): Quote?
fun isFavorite(id : Int): Boolean fun isFavorite(id : Int, user: User): Boolean
fun getAllFavorite(): List<Favorite> fun getAllFavorite(): List<Favorite>
fun getAllQuote(): List<Quote> fun getAllQuote(): List<Quote>
} }

@ -55,7 +55,7 @@ class ServicesAPI : IServices {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun isFavorite(id: Int): Boolean { override fun isFavorite(id: Int, user: User): Boolean {
TODO("Not yet implemented") TODO("Not yet implemented")
} }

@ -76,6 +76,7 @@ class ServicesStub : IServices {
} }
override fun AddComment(content: String) { override fun AddComment(content: String) {
return
TODO("Not yet implemented") TODO("Not yet implemented")
//comments.add(Comment(content = content,)) //comments.add(Comment(content = content,))
} }
@ -100,7 +101,7 @@ class ServicesStub : IServices {
override fun getFavorite(user: User): List<Quote> { override fun getFavorite(user: User): List<Quote> {
val favorite = favorites val favorite = favorites
return favorite[0].quote return favorite[user.id-1].quote
//return emptyList() //return emptyList()
} }
@ -119,11 +120,12 @@ class ServicesStub : IServices {
} }
override fun getQuote(id: Int): Quote? { override fun getQuote(id: Int): Quote? {
return (quotes.find { it.id == id+1 }) return (quotes.find { it.id == id })
} }
override fun isFavorite(id: Int): Boolean { override fun isFavorite(id: Int, user: User): Boolean {
TODO("Not yet implemented") var quote = getFavorite(user)
return quote.find{ it.id == id } != null
} }

@ -32,6 +32,7 @@ import androidx.compose.material.icons.filled.MailOutline
import androidx.compose.material.icons.filled.Share import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -76,7 +77,10 @@ fun QuotePage(
// utiliser ViewModel // utiliser ViewModel
val quote = service.getQuote(quoteId) ?: return val quote = service.getQuote(quoteId) ?: return
val context = LocalContext.current val context = LocalContext.current
NavBar(onProfile = true, val user = service.getUserById(index) ?: return
val favorite by remember { mutableStateOf(service.isFavorite(id = quoteId, user = user)) }
NavBar(
index = index, index = index,
navControllerFavorite = navFavorite, navControllerFavorite = navFavorite,
navControllerAccueil = navAccueil, navControllerAccueil = navAccueil,
@ -86,17 +90,15 @@ fun QuotePage(
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.background(colorBackground), .background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Column(modifier = Modifier Column(modifier = Modifier
.padding(15.dp) .padding(15.dp)
.drawBehind { .background(
drawRoundRect( color = MaterialTheme.colorScheme.primary,
gradienBox, shape = RoundedCornerShape(15.dp)
cornerRadius = CornerRadius(15.dp.toPx()), )
)
}
) { ) {
Row(modifier = Modifier.padding(15.dp)) { Row(modifier = Modifier.padding(15.dp)) {
ImageQuote( ImageQuote(
@ -105,10 +107,7 @@ fun QuotePage(
Column { Column {
FunctionalIcon( FunctionalIcon(
// --/!\-- a modifier --/!\-- isFavorite = favorite,
// isFavorite = service.isFavorite(id)
// --------------------------
false,
userId = index, userId = index,
id = quoteId, id = quoteId,
context = context, context = context,
@ -154,7 +153,7 @@ fun QuotePage(
), ),
exit = slideOutVertically() + shrinkVertically() + fadeOut() exit = slideOutVertically() + shrinkVertically() + fadeOut()
) { ) {
Box(modifier = Modifier.fillMaxWidth().background(gradienBox).fillMaxSize()){ Box(modifier = Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.primary).fillMaxSize()){
Column { Column {
AddComment(index, service) AddComment(index, service)
LstComment(service.getComment(quoteId)) LstComment(service.getComment(quoteId))
@ -173,7 +172,7 @@ fun QuoteText(text: String ){
modifier = Modifier.padding(start = 10.dp, top = 15.dp), modifier = Modifier.padding(start = 10.dp, top = 15.dp),
fontWeight = FontWeight(1000), fontWeight = FontWeight(1000),
fontSize = 20.sp, fontSize = 20.sp,
color = iconText color = MaterialTheme.colorScheme.onPrimary
) )
} }
@ -214,7 +213,7 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
Icon( Icon(
Icons.Default.Share, Icons.Default.Share,
contentDescription = stringResource(R.string.share), contentDescription = stringResource(R.string.share),
tint = iconText, tint = MaterialTheme.colorScheme.onPrimary,
) )
} }
IconButton( IconButton(
@ -226,7 +225,7 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
Icon( Icon(
Icons.Default.MailOutline, Icons.Default.MailOutline,
contentDescription = stringResource(R.string.comment), contentDescription = stringResource(R.string.comment),
tint = iconText, tint = MaterialTheme.colorScheme.onPrimary,
) )
} }
@ -238,7 +237,7 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
Icon( Icon(
Icons.Default.Favorite, Icons.Default.Favorite,
contentDescription = stringResource(R.string.favorite), contentDescription = stringResource(R.string.favorite),
tint = likeIcon, tint = MaterialTheme.colorScheme.onPrimary,
) )
} }
@ -251,7 +250,7 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
Icon( Icon(
Icons.Default.FavoriteBorder, Icons.Default.FavoriteBorder,
contentDescription = stringResource(R.string.favorite), contentDescription = stringResource(R.string.favorite),
tint = iconText tint = MaterialTheme.colorScheme.onPrimary
) )
} }
} }
@ -265,22 +264,20 @@ fun InfoQuoteText(nameId : Int, text : String){
text = stringResource(id = nameId), text = stringResource(id = nameId),
fontSize = 18.sp, fontSize = 18.sp,
fontWeight = FontWeight(500), fontWeight = FontWeight(500),
color = iconText color = MaterialTheme.colorScheme.onPrimary
) )
Text( Text(
text = text, text = text,
color = whiteBackcgroundText, color = MaterialTheme.colorScheme.onBackground,
fontSize = 16.sp, fontSize = 16.sp,
fontWeight = FontWeight(400), fontWeight = FontWeight(400),
modifier = Modifier modifier = Modifier
.drawBehind { .background(
drawRoundRect( color = MaterialTheme.colorScheme.background,
Color(255,255,255), shape = RoundedCornerShape(15.dp)
cornerRadius = CornerRadius(15.dp.toPx()) )
) .padding(5.dp)
}
.padding(5.dp),
) )
} }
} }
@ -289,12 +286,12 @@ fun InfoQuoteText(nameId : Int, text : String){
fun LikeInfo(likes : Int){ fun LikeInfo(likes : Int){
Text( Text(
text = likes.toString(), text = likes.toString(),
color = iconText color = MaterialTheme.colorScheme.onPrimary
) )
Icon( Icon(
Icons.Default.Favorite, Icons.Default.Favorite,
contentDescription = stringResource(R.string.favorite), contentDescription = stringResource(R.string.favorite),
tint = iconText, tint = MaterialTheme.colorScheme.onPrimary,
) )
} }
@ -308,19 +305,14 @@ fun AddComment(userId : Int, service: IServices){
Icon( Icon(
Icons.AutoMirrored.Filled.ArrowBack, Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(R.string.send), contentDescription = stringResource(R.string.send),
tint = iconText tint = MaterialTheme.colorScheme.onPrimary
) )
} }
TextField( TextField(
value = text, value = text,
onValueChange = { text = it }, onValueChange = { text = it },
label = { Text(stringResource(R.string.comment)) }, label = { Text(stringResource(R.string.comment)) },
modifier = Modifier.drawBehind { modifier = Modifier
drawRoundRect(
Color.White,
cornerRadius = CornerRadius(15.dp.toPx())
)
}
.width(300.dp) .width(300.dp)
) )
IconButton( IconButton(
@ -329,7 +321,7 @@ fun AddComment(userId : Int, service: IServices){
Icon( Icon(
Icons.AutoMirrored.Filled.Send, Icons.AutoMirrored.Filled.Send,
contentDescription = stringResource(R.string.send), contentDescription = stringResource(R.string.send),
tint = iconText tint = MaterialTheme.colorScheme.onPrimary
) )
} }
} }
@ -346,12 +338,10 @@ fun LstComment(lst : List<Comment>){
Column( Column(
modifier = Modifier.padding(5.dp) modifier = Modifier.padding(5.dp)
.fillMaxSize() .fillMaxSize()
.drawBehind { .background(
drawRoundRect( color = MaterialTheme.colorScheme.onPrimary,
Color.White, shape = RoundedCornerShape(15.dp)
cornerRadius = CornerRadius(15.dp.toPx()) )
)
}
) { ) {
Row { Row {
AsyncImage( AsyncImage(

Loading…
Cancel
Save