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 95118ef..27546de 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 @@ -124,6 +124,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 a503c32..46893a8 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 @@ -61,6 +61,7 @@ fun ProfilPage(index: Int, navAccueil: (Int) -> Unit, navQuiz: (Int) -> Unit, navUnLog: () -> Unit, + navSubmitQuote: () -> Unit, services: IServices ) { val user = services.getUserById(index) ?: return @@ -84,13 +85,13 @@ fun ProfilPage(index: Int, .fillMaxWidth(0.9f) .padding(20.dp) .clip(RoundedCornerShape(16.dp)) - .background(MaterialTheme.colorScheme.primary) + .background(MaterialTheme.colorScheme.onPrimary) .padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally ) { // Titre - TitlePageComponent(R.string.titleProfile, MaterialTheme.colorScheme.onPrimary) + TitlePageComponent(R.string.titleProfile, Color.White) SpaceHeightComponent(16) // Image de profil @@ -207,12 +208,12 @@ fun DisplayEmail(email: String, onEdit: () -> Unit) { text = email, fontSize = 18.sp, fontWeight = FontWeight.Bold, - color = MaterialTheme.colorScheme.onPrimary + color = MaterialTheme.colorScheme.primary ) Icon( imageVector = Icons.Default.Edit, contentDescription = "Modifier", - tint = MaterialTheme.colorScheme.onPrimary, + tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp).padding(start = 8.dp) ) } @@ -250,7 +251,7 @@ fun UsernameEditingField( value = username, onValueChange = onUsernameChange, modifier = Modifier.fillMaxWidth(), - textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp), + textStyle = TextStyle(color = MaterialTheme.colorScheme.primary, fontSize = 18.sp), singleLine = true, keyboardOptions = KeyboardOptions.Default.copy( imeAction = ImeAction.Done @@ -276,12 +277,12 @@ fun DisplayUsername(username: String, onEdit: () -> Unit) { text = username, fontSize = 18.sp, fontWeight = FontWeight.Bold, - color = MaterialTheme.colorScheme.onPrimary + color = MaterialTheme.colorScheme.primary ) Icon( imageVector = Icons.Default.Edit, contentDescription = "Modifier", - tint = MaterialTheme.colorScheme.onPrimary, + tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp).padding(start = 8.dp) ) } @@ -387,7 +388,7 @@ fun PasswordTextField( onValueChange = onValueChange, label = { Text(label) }, modifier = Modifier.fillMaxWidth(), - textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp), + textStyle = TextStyle(color = MaterialTheme.colorScheme.primary, fontSize = 18.sp), singleLine = true, keyboardOptions = KeyboardOptions.Default.copy( keyboardType = KeyboardType.Password, @@ -472,4 +473,19 @@ fun ButtonLanguage(textResId : Int, size :Int, colorTexte : Color, colorButton : ) { Text("${text} (${currentLangage.value})", fontSize = size.sp, color = MaterialTheme.colorScheme.primary) } +} + +@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/SignUpPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt index 0e39df4..cce938e 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SignUpPage.kt @@ -7,8 +7,10 @@ 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.material.icons.Icons import androidx.compose.material.icons.filled.Check import androidx.compose.material3.Button @@ -51,7 +53,8 @@ fun SignUpPage(navControllerLogin: () -> Unit, services : IServices) { Box( modifier = Modifier .fillMaxSize() - .background(colorBackground), + .background(colorBackground) + .verticalScroll(rememberScrollState()), contentAlignment = Alignment.Center ){ Column( @@ -191,17 +194,19 @@ fun ConnexionButtonSign( var emailError by remember { mutableStateOf(false) } var passwordError by remember { mutableStateOf(false) } var passwordErrorEmpty by remember { mutableStateOf(false) } - var usernameErrorEmpty by remember { mutableStateOf(false) } + var usernameError by remember { mutableStateOf(false) } var usernameErrorExist by remember { mutableStateOf(false) } + val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex() + Button( onClick = { emailError = !isValidEmail(email) passwordError = !arePasswordsMatching(password, confirmPassword) - usernameErrorEmpty = username.isBlank() + usernameError = username.isBlank() && !username.matches(invalidRegex) passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank() - if (!emailError && !passwordError && !usernameErrorEmpty && !passwordErrorEmpty) { + if (!emailError && !passwordError && !usernameError && !passwordErrorEmpty) { usernameErrorExist = !service.CreateUser(username, email, password, service) if(!usernameErrorExist){ navController() // retour à la page login @@ -215,8 +220,8 @@ fun ConnexionButtonSign( } // Afficher erreurs - if (usernameErrorEmpty) { - ErrorMessageProfileComponent(R.string.ErrorUserEmptySignUp) + if (usernameError) { + ErrorMessageProfileComponent(R.string.ErrorUserSignUp) } if (usernameErrorExist) { 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 09bce33..0bd5230 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 @@ -29,7 +29,7 @@ Email* Email invalide Les mots de passe ne correspondent pas - Le nom d\'utilisateur ne peut pas être vide + Le nom d\'utilisateur n\'est pas correct Le nom d\'utilisateur ou l\'email ne sont pas disponibles Vous devez mettre un mot de passe @@ -57,12 +57,15 @@ ▶ Citation du jour ◀ ▶ Suggestions ◀ - Submit Quote - Submit - Profil - Quote - Character + + //Page SubmitQuote + Proposez Une Citation + Proposez + Profile + Citation + Personnage + Source Time Code - Year - Invalid Fields + 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 463d429..8e12c0e 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -28,7 +28,7 @@ Your email* Invalid email Passwords do not match - Username cannot be empty + Username invalid Username or email are not available You must put a password @@ -60,6 +60,7 @@ Profil Quote Character + Source Time Code Year Invalid Fields