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)) },
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 }

@ -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,
@ -473,3 +474,18 @@ 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)
}
}

@ -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) {

@ -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
}

@ -29,7 +29,7 @@
<string name="EmailSignUp">Email*</string>
<string name="ErrorEmailSignUp">Email invalide</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="ErrorPasswordEmpty">Vous devez mettre un mot de passe</string>
@ -57,12 +57,15 @@
<string name="TitleHomeDailyQuote">▶ Citation du jour ◀</string>
<string name="TitleHomeSuggestion">▶ Suggestions ◀</string>
<string name="titleSubmitQuote">Submit Quote</string>
<string name="titleButtonSubmit">Submit</string>
<string name="titleButtonBack">Profil</string>
<string name="quote">Quote</string>
<string name="character">Character</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">Year</string>
<string name="ErrorSubmitQuote"> Invalid Fields </string>
<string name="year">Année</string>
<string name="ErrorSubmitQuote">Champs Invalides</string>
</resources>

@ -28,7 +28,7 @@
<string name="EmailSignUp">Your email*</string>
<string name="ErrorEmailSignUp">Invalid email</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="ErrorPasswordEmpty">You must put a password</string>
@ -60,6 +60,7 @@
<string name="titleButtonBack">Profil</string>
<string name="quote">Quote</string>
<string name="character">Character</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