diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt index 3603478..d882bb7 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/navigations/AppNavigator.kt @@ -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 } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt index 1d19705..0797d5f 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/ProfilPage.kt @@ -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) + } } \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/RecapSubmitPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/RecapSubmitPage.kt index 4d906c4..bfdf9e0 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/RecapSubmitPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/RecapSubmitPage.kt @@ -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( diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SubmitQuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SubmitQuotePage.kt index 35edd2f..675dfac 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SubmitQuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SubmitQuotePage.kt @@ -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 } 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 02b41a5..9cdf238 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 @@ -56,4 +56,16 @@ //Page Accueil ▶ Citation du jour ◀ ▶ Suggestions ◀ + + + //Page SubmitQuote + Proposez Une Citation + Proposez + Profile + Citation + Personnage + Source + Time Code + Année + Champs Invalides \ 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 191ee6f..29d2f72 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -60,7 +60,7 @@ Profil Quote Character - Source + Source Time Code Year Invalid Fields