component little quote

componentQuote
Leni BEAULATON 2 months ago
parent cce7424a23
commit 2fae6eb9ad

@ -0,0 +1,67 @@
package com.example.what_the_fantasy.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.ui.theme.gradienBox
@Composable
fun LittleQuoteComponent(imageQuote : String, textQuote : String, dateText : String, TypeText : String, titleText : String, CharacterText : String){
Row(
modifier = Modifier
.fillMaxWidth(0.9f)
.clip(RoundedCornerShape(16.dp))
.background(gradienBox)
) {
val sizeTextInfoQuote = 13
val lineHeightText = 12
val sizeTextQuote = 16
AsyncImage(
model = imageQuote,
contentDescription = "Quote picture",
modifier = Modifier
.size(130.dp)
.clip(RoundedCornerShape(16.dp))
)
Column(modifier = Modifier.padding(10.dp)) {
TextInfoQuote(
textQuote,
sizeTextQuote,
lineHeightText
)
SpaceHeightComponent(40)
TextInfoQuote("${stringResource(R.string.dateQuote)} : $dateText", sizeTextInfoQuote, lineHeightText)
TextInfoQuote("$TypeText : $titleText", sizeTextInfoQuote, lineHeightText)
TextInfoQuote("${stringResource(R.string.CharacterQuote)}: $CharacterText", sizeTextInfoQuote, lineHeightText)
}
}
}
@Composable
fun TextInfoQuote(text : String, fontSizeText : Int, lineHeightText : Int){
Text(text,
color = Color.White,
fontSize = fontSizeText.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
lineHeight = lineHeightText.sp)
}

@ -1,25 +1,37 @@
package com.example.what_the_fantasy.ui.screens package com.example.what_the_fantasy.ui.screens
import androidx.annotation.StringRes
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.example.what_the_fantasy.R import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.services.IServices import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.ui.components.LittleQuoteComponent
import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.SpaceHeightComponent 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.components.TitlePageComponent
@ -40,33 +52,37 @@ fun FavoritePage(
navControllerProfil = navProfil, navControllerProfil = navProfil,
navControllerQuiz = navQuiz navControllerQuiz = navQuiz
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.background(colorBackground), .background(colorBackground),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
){ ){
Column { LazyColumn(
Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.background(Color(0xFF100C1B)), .background(Color(0xFF100C1B))
contentAlignment = Alignment.Center .padding(top=40.dp),
contentPadding = PaddingValues(horizontal = 20.dp)
) { ) {
Row( item{
modifier = Modifier LittleQuoteComponent(
.fillMaxWidth(0.9f) "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg",
.padding(20.dp) "La citation qui doit être raccourci par des 3 points pour ne pas trop dépasser.",
.clip(RoundedCornerShape(16.dp)) "2000",
.background(gradienBox) "Film",
.padding(20.dp), "Les aventures de M Rat",
) { "Le rat"
Text("Une image") )
Text("Une citation d'un personnage")
SpaceHeightComponent(30)
}
}
} }
} }
} }
} }
}

@ -156,7 +156,6 @@ fun validLogin(identifiant : String, passwd : String, users : List<User>, navCon
users.forEachIndexed { index, user -> users.forEachIndexed { index, user ->
val hashPassWd = hashPassword(passwd) val hashPassWd = hashPassword(passwd)
if (user.username == identifiant && user.password == hashPassWd) { if (user.username == identifiant && user.password == hashPassWd) {
// Utilise l'index pour naviguer à la position correspondante
navController(index) // Passer l'index à la fonction navController navController(index) // Passer l'index à la fonction navController
return true return true
} }

@ -34,4 +34,9 @@
<string name="ButtonSaveprofile">Sauvegarder</string> <string name="ButtonSaveprofile">Sauvegarder</string>
<string name="ErrorEmailprofile">L\'adress email est invalide</string> <string name="ErrorEmailprofile">L\'adress email est invalide</string>
<string name="Errorpasswdprofile">Les mots de passe ne correspondent pas</string> <string name="Errorpasswdprofile">Les mots de passe ne correspondent pas</string>
//Component quote
<string name="dateQuote">Date</string>
<string name="CharacterQuote">Personnage</string>
</resources> </resources>

@ -34,4 +34,8 @@
<string name="ErrorEmailprofile">Invalid email address</string> <string name="ErrorEmailprofile">Invalid email address</string>
<string name="Errorpasswdprofile">Passwords do not match</string> <string name="Errorpasswdprofile">Passwords do not match</string>
//Component quote
<string name="dateQuote">Date</string>
<string name="CharacterQuote">Character</string>
</resources> </resources>
Loading…
Cancel
Save