From 2fae6eb9ad51636bd364f8df86fe60ed9dedae22 Mon Sep 17 00:00:00 2001 From: beaulaton Date: Thu, 6 Mar 2025 15:11:15 +0100 Subject: [PATCH] component little quote --- .../ui/components/LittleQuoteComponent.kt | 67 +++++++++++++++++++ .../ui/screens/FavoritePage.kt | 48 ++++++++----- .../what_the_fantasy/ui/screens/LoginPage.kt | 1 - .../app/src/main/res/values-fr/strings.xml | 5 ++ .../app/src/main/res/values/strings.xml | 4 ++ 5 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/LittleQuoteComponent.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/LittleQuoteComponent.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/LittleQuoteComponent.kt new file mode 100644 index 0000000..8921b0b --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/LittleQuoteComponent.kt @@ -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) +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt index 9a3438c..826e2e3 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt @@ -1,25 +1,37 @@ package com.example.what_the_fantasy.ui.screens +import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer 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.lazy.LazyColumn +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.CornerRadius 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.sp +import coil.compose.AsyncImage import com.example.what_the_fantasy.R 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.SpaceHeightComponent import com.example.what_the_fantasy.ui.components.TitlePageComponent @@ -40,33 +52,37 @@ fun FavoritePage( navControllerProfil = navProfil, navControllerQuiz = navQuiz ) { + Box( modifier = Modifier .fillMaxSize() .background(colorBackground), contentAlignment = Alignment.Center ){ - Column { - Box( + LazyColumn( modifier = Modifier .fillMaxSize() - .background(Color(0xFF100C1B)), - contentAlignment = Alignment.Center + .background(Color(0xFF100C1B)) + .padding(top=40.dp), + contentPadding = PaddingValues(horizontal = 20.dp) + ) { - Row( - modifier = Modifier - .fillMaxWidth(0.9f) - .padding(20.dp) - .clip(RoundedCornerShape(16.dp)) - .background(gradienBox) - .padding(20.dp), - ) { - Text("Une image") - Text("Une citation d'un personnage") + item{ + LittleQuoteComponent( + "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg", + "La citation qui doit être raccourci par des 3 points pour ne pas trop dépasser.", + "2000", + "Film", + "Les aventures de M Rat", + "Le rat" + ) + + SpaceHeightComponent(30) + } - } } } } } -} \ No newline at end of file + + diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt index 153a535..7ba3364 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt @@ -156,7 +156,6 @@ fun validLogin(identifiant : String, passwd : String, users : List, navCon users.forEachIndexed { index, user -> val hashPassWd = hashPassword(passwd) if (user.username == identifiant && user.password == hashPassWd) { - // Utilise l'index pour naviguer à la position correspondante navController(index) // Passer l'index à la fonction navController return true } 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 6485726..a30ccbc 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 @@ -34,4 +34,9 @@ Sauvegarder L\'adress email est invalide Les mots de passe ne correspondent pas + + + //Component quote + Date + Personnage \ No newline at end of file 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 254d478..cf5680d 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -34,4 +34,8 @@ Invalid email address Passwords do not match + //Component quote + Date + Character + \ No newline at end of file