modification des couleurs en fonct'ion du thème android

UI-Style
Maxime ROCHER 1 month ago
commit 9b661c389c

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

@ -61,6 +61,7 @@ fun ProfilPage(index: Int,
navAccueil: (Int) -> Unit, navAccueil: (Int) -> Unit,
navQuiz: (Int) -> Unit, navQuiz: (Int) -> Unit,
navUnLog: () -> Unit, navUnLog: () -> Unit,
navSubmitQuote: () -> Unit,
services: IServices services: IServices
) { ) {
val user = services.getUserById(index) ?: return val user = services.getUserById(index) ?: return
@ -84,13 +85,13 @@ fun ProfilPage(index: Int,
.fillMaxWidth(0.9f) .fillMaxWidth(0.9f)
.padding(20.dp) .padding(20.dp)
.clip(RoundedCornerShape(16.dp)) .clip(RoundedCornerShape(16.dp))
.background(MaterialTheme.colorScheme.primary) .background(MaterialTheme.colorScheme.onPrimary)
.padding(20.dp), .padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
// Titre // Titre
TitlePageComponent(R.string.titleProfile, MaterialTheme.colorScheme.onPrimary) TitlePageComponent(R.string.titleProfile, Color.White)
SpaceHeightComponent(16) SpaceHeightComponent(16)
// Image de profil // Image de profil
@ -207,12 +208,12 @@ fun DisplayEmail(email: String, onEdit: () -> Unit) {
text = email, text = email,
fontSize = 18.sp, fontSize = 18.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onPrimary color = MaterialTheme.colorScheme.primary
) )
Icon( Icon(
imageVector = Icons.Default.Edit, imageVector = Icons.Default.Edit,
contentDescription = "Modifier", contentDescription = "Modifier",
tint = MaterialTheme.colorScheme.onPrimary, tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(16.dp).padding(start = 8.dp) modifier = Modifier.size(16.dp).padding(start = 8.dp)
) )
} }
@ -250,7 +251,7 @@ fun UsernameEditingField(
value = username, value = username,
onValueChange = onUsernameChange, onValueChange = onUsernameChange,
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp), textStyle = TextStyle(color = MaterialTheme.colorScheme.primary, fontSize = 18.sp),
singleLine = true, singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy( keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Done imeAction = ImeAction.Done
@ -276,12 +277,12 @@ fun DisplayUsername(username: String, onEdit: () -> Unit) {
text = username, text = username,
fontSize = 18.sp, fontSize = 18.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onPrimary color = MaterialTheme.colorScheme.primary
) )
Icon( Icon(
imageVector = Icons.Default.Edit, imageVector = Icons.Default.Edit,
contentDescription = "Modifier", contentDescription = "Modifier",
tint = MaterialTheme.colorScheme.onPrimary, tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(16.dp).padding(start = 8.dp) modifier = Modifier.size(16.dp).padding(start = 8.dp)
) )
} }
@ -387,7 +388,7 @@ fun PasswordTextField(
onValueChange = onValueChange, onValueChange = onValueChange,
label = { Text(label) }, label = { Text(label) },
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp), textStyle = TextStyle(color = MaterialTheme.colorScheme.primary, fontSize = 18.sp),
singleLine = true, singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy( keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Password, keyboardType = KeyboardType.Password,
@ -473,3 +474,18 @@ fun ButtonLanguage(textResId : Int, size :Int, colorTexte : Color, colorButton :
Text("${text} (${currentLangage.value})", fontSize = size.sp, color = MaterialTheme.colorScheme.primary) 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)
}
}

@ -7,8 +7,10 @@ import androidx.compose.foundation.layout.Column
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.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Check
import androidx.compose.material3.Button import androidx.compose.material3.Button
@ -51,7 +53,8 @@ fun SignUpPage(navControllerLogin: () -> Unit, services : IServices) {
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.background(colorBackground), .background(colorBackground)
.verticalScroll(rememberScrollState()),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
){ ){
Column( Column(
@ -191,17 +194,19 @@ fun ConnexionButtonSign(
var emailError by remember { mutableStateOf(false) } var emailError by remember { mutableStateOf(false) }
var passwordError by remember { mutableStateOf(false) } var passwordError by remember { mutableStateOf(false) }
var passwordErrorEmpty 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) } var usernameErrorExist by remember { mutableStateOf(false) }
val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex()
Button( Button(
onClick = { onClick = {
emailError = !isValidEmail(email) emailError = !isValidEmail(email)
passwordError = !arePasswordsMatching(password, confirmPassword) passwordError = !arePasswordsMatching(password, confirmPassword)
usernameErrorEmpty = username.isBlank() usernameError = username.isBlank() && !username.matches(invalidRegex)
passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank() passwordErrorEmpty = password.isBlank() || confirmPassword.isBlank()
if (!emailError && !passwordError && !usernameErrorEmpty && !passwordErrorEmpty) { if (!emailError && !passwordError && !usernameError && !passwordErrorEmpty) {
usernameErrorExist = !service.CreateUser(username, email, password, service) usernameErrorExist = !service.CreateUser(username, email, password, service)
if(!usernameErrorExist){ if(!usernameErrorExist){
navController() // retour à la page login navController() // retour à la page login
@ -215,8 +220,8 @@ fun ConnexionButtonSign(
} }
// Afficher erreurs // Afficher erreurs
if (usernameErrorEmpty) { if (usernameError) {
ErrorMessageProfileComponent(R.string.ErrorUserEmptySignUp) ErrorMessageProfileComponent(R.string.ErrorUserSignUp)
} }
if (usernameErrorExist) { if (usernameErrorExist) {

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

@ -29,7 +29,7 @@
<string name="EmailSignUp">Email*</string> <string name="EmailSignUp">Email*</string>
<string name="ErrorEmailSignUp">Email invalide</string> <string name="ErrorEmailSignUp">Email invalide</string>
<string name="ErrorPasswordSignUp">Les mots de passe ne correspondent pas</string> <string name="ErrorPasswordSignUp">Les mots de passe ne correspondent pas</string>
<string name="ErrorUserEmptySignUp">Le nom d\'utilisateur ne peut pas être vide</string> <string name="ErrorUserSignUp">Le nom d\'utilisateur n\'est pas correct</string>
<string name="ErrorUserExistSignUp">Le nom d\'utilisateur ou l\'email ne sont pas disponibles</string> <string name="ErrorUserExistSignUp">Le nom d\'utilisateur ou l\'email ne sont pas disponibles</string>
<string name="ErrorPasswordEmpty">Vous devez mettre un mot de passe</string> <string name="ErrorPasswordEmpty">Vous devez mettre un mot de passe</string>
@ -57,12 +57,15 @@
<string name="TitleHomeDailyQuote">▶ Citation du jour ◀</string> <string name="TitleHomeDailyQuote">▶ Citation du jour ◀</string>
<string name="TitleHomeSuggestion">▶ Suggestions ◀</string> <string name="TitleHomeSuggestion">▶ Suggestions ◀</string>
<string name="titleSubmitQuote">Submit Quote</string>
<string name="titleButtonSubmit">Submit</string> //Page SubmitQuote
<string name="titleButtonBack">Profil</string> <string name="titleSubmitQuote">Proposez Une Citation</string>
<string name="quote">Quote</string> <string name="titleButtonSubmit">Proposez</string>
<string name="character">Character</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="timeCode">Time Code</string>
<string name="year">Year</string> <string name="year">Année</string>
<string name="ErrorSubmitQuote"> Invalid Fields </string> <string name="ErrorSubmitQuote">Champs Invalides</string>
</resources> </resources>

@ -28,7 +28,7 @@
<string name="EmailSignUp">Your email*</string> <string name="EmailSignUp">Your email*</string>
<string name="ErrorEmailSignUp">Invalid email</string> <string name="ErrorEmailSignUp">Invalid email</string>
<string name="ErrorPasswordSignUp">Passwords do not match</string> <string name="ErrorPasswordSignUp">Passwords do not match</string>
<string name="ErrorUserEmptySignUp">Username cannot be empty</string> <string name="ErrorUserSignUp">Username invalid</string>
<string name="ErrorUserExistSignUp">Username or email are not available</string> <string name="ErrorUserExistSignUp">Username or email are not available</string>
<string name="ErrorPasswordEmpty">You must put a password</string> <string name="ErrorPasswordEmpty">You must put a password</string>
@ -60,6 +60,7 @@
<string name="titleButtonBack">Profil</string> <string name="titleButtonBack">Profil</string>
<string name="quote">Quote</string> <string name="quote">Quote</string>
<string name="character">Character</string> <string name="character">Character</string>
<string name="source2">Source</string>
<string name="timeCode">Time Code</string> <string name="timeCode">Time Code</string>
<string name="year">Year</string> <string name="year">Year</string>
<string name="ErrorSubmitQuote"> Invalid Fields </string> <string name="ErrorSubmitQuote"> Invalid Fields </string>

Loading…
Cancel
Save