verification suggest quote robuste + ajout de la naviguation et correction erreur Tommy

UI-Style
parent 716491d31f
commit d1d2ae24a8

@ -123,6 +123,7 @@ fun AppNavigator() {
navFavorite = { navController.navigate(Favorite(profil.userIndex)) },
navAccueil = { navController.navigate(Accueil(profil.userIndex)) },
navQuiz = { navController.navigate(QuizMenu(profil.userIndex)) },
navSubmitQuote = { navController.navigate(SubmitQuote(profil.userIndex)) },
navUnLog = {
navController.navigate(Login) {
popUpTo(profil) { inclusive = true }

@ -60,6 +60,7 @@ fun ProfilPage(index: Int,
navAccueil: (Int) -> Unit,
navQuiz: (Int) -> Unit,
navUnLog: () -> Unit,
navSubmitQuote: () -> Unit,
services: IServices
) {
val user = services.getUserById(index) ?: return
@ -106,8 +107,8 @@ fun ProfilPage(index: Int,
SpaceHeightComponent(16)
// Bouton
//ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
//SpaceHeightComponent(16)
ButtonProfil(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navSubmitQuote)
SpaceHeightComponent(16)
ButtonLanguage(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,services, user)
SpaceHeightComponent(16)
ButtonUnLog(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White,navUnLog)
@ -471,4 +472,19 @@ fun ButtonLanguage(textResId : Int, size :Int, colorTexte : Color, colorButton :
) {
Text("${text} (${currentLangage.value})", fontSize = size.sp, color = colorTexte)
}
}
@Composable
fun ButtonProfil(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){
val text = stringResource(id = textResId)
Button(
onClick = {
navController()
},
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
modifier = Modifier.fillMaxWidth(),
) {
Text(text, fontSize = size.sp, color = colorTexte)
}
}

@ -98,11 +98,11 @@ fun RecapSubmitPage(
}
) {
Row(modifier = Modifier.padding(15.dp)) {
ImageQuote(
SubmitImageQuote(
imageUrl = "https://img.freepik.com/vecteurs-libre/personnage-guerrier-fantaisie_1045-185.jpg?size=338&ext=jpg"
)
Column {
QuoteText(
SubmitQuoteText(
text = '"' + quoteContent + '"'
)
}
@ -111,12 +111,13 @@ fun RecapSubmitPage(
.padding(15.dp)
.fillMaxWidth()
) {
InfoQuoteText(
SubmitInfoQuoteText(
nameId = R.string.source,
text = source
)
Text(
text = "Character : $character"
SubmitInfoQuoteText(
nameId = R.string.character,
text = character
)
}
}
@ -127,7 +128,7 @@ fun RecapSubmitPage(
}
@Composable
fun QuoteText(text: String ){
fun SubmitQuoteText(text: String ){
Text(
text = text,
modifier = Modifier.padding(start = 10.dp, top = 15.dp),
@ -138,7 +139,7 @@ fun QuoteText(text: String ){
}
@Composable
fun ImageQuote(imageUrl : String){
fun SubmitImageQuote(imageUrl : String){
AsyncImage(
model = imageUrl,
contentDescription = "exemple",
@ -149,7 +150,7 @@ fun ImageQuote(imageUrl : String){
}
@Composable
fun InfoQuoteText(nameId : Int, text : String){
fun SubmitInfoQuoteText(nameId : Int, text : String){
Column(modifier = Modifier.padding(bottom = 20.dp)){
Text(

@ -2,13 +2,16 @@ package com.example.what_the_fantasy.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.OutlinedTextField
@ -53,7 +56,8 @@ fun SubmitQuotePage(
Box(
modifier = Modifier
.fillMaxSize()
.background(colorBackground),
.background(colorBackground)
.verticalScroll(rememberScrollState()),
contentAlignment = Alignment.Center
){
Column(
@ -229,12 +233,18 @@ fun goToRecap(quote: String,
}
fun validSubmitQuote(quote : String, character : String, source: String, timeCode: String, year: String): Boolean{
val isNotBlank = quote.isNotBlank() &&
character.isNotBlank() &&
source.isNotBlank() &&
timeCode.isNotBlank() &&
year.isNotBlank() &&
year.all { it.isDigit() }
val quoteRegex = """^[A-Za-zÀ-ÿ0-9\s\-\.,!?'"()]+$""".toRegex()
val timeCodeRegex = """^\d{1}:\d{2}:\d{2}$""".toRegex()
val movieTitleRegex = """^[A-Za-z0-9\s\-\(\):]+$""".toRegex()
val characterRegex = """^[A-Za-zÀ-ÿ\s\-']+$""".toRegex()
val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex()
val isNotBlank = quote.isNotBlank() && quote.matches(quoteRegex) && !quote.matches(invalidRegex) && quote.length in 3..100 &&
character.isNotBlank() && character.matches(characterRegex) && character.length in 3..50 && !character.matches(invalidRegex) &&
source.isNotBlank() && source.matches(movieTitleRegex) && source.length in 3..50 && !source.matches(invalidRegex) &&
timeCode.isNotBlank() && timeCode.matches(timeCodeRegex) &&
year.isNotBlank() && year.all { it.isDigit() } && year.length == 4 && year.toInt() in 1900..2025
return isNotBlank
}

@ -56,4 +56,16 @@
//Page Accueil
<string name="TitleHomeDailyQuote">▶ Citation du jour ◀</string>
<string name="TitleHomeSuggestion">▶ Suggestions ◀</string>
//Page SubmitQuote
<string name="titleSubmitQuote">Proposez Une Citation</string>
<string name="titleButtonSubmit">Proposez</string>
<string name="titleButtonBack">Profile</string>
<string name="quote">Citation</string>
<string name="character">Personnage</string>
<string name="source2">Source</string>
<string name="timeCode">Time Code</string>
<string name="year">Année</string>
<string name="ErrorSubmitQuote">Champs Invalides</string>
</resources>

@ -60,7 +60,7 @@
<string name="titleButtonBack">Profil</string>
<string name="quote">Quote</string>
<string name="character">Character</string>
<string name="source">Source</string>
<string name="source2">Source</string>
<string name="timeCode">Time Code</string>
<string name="year">Year</string>
<string name="ErrorSubmitQuote"> Invalid Fields </string>

Loading…
Cancel
Save