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

UI-Style
Maxime ROCHER 1 month ago
parent 716491d31f
commit 6e5ae309a2

@ -19,6 +19,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonColors
import androidx.compose.material3.IconToggleButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -55,7 +56,7 @@ fun NavBar(onProfile : Boolean = false ,
NavigationBar(
modifier = Modifier
.fillMaxWidth(),
containerColor = colorNavBar
containerColor = MaterialTheme.colorScheme.onPrimary
) {
Row(
modifier = Modifier
@ -75,7 +76,7 @@ fun NavBar(onProfile : Boolean = false ,
else R.drawable.light_mode_toggle_icon),
contentDescription = "Dark mode",
modifier = Modifier.fillMaxSize(),
tint = Color.White
tint = MaterialTheme.colorScheme.primary
)
}
@ -88,7 +89,7 @@ fun NavBar(onProfile : Boolean = false ,
BottomAppBar (modifier = Modifier
.fillMaxSize(),
containerColor = colorNavBar
containerColor = MaterialTheme.colorScheme.onPrimary
) {
Row(modifier = Modifier
.fillMaxSize(),
@ -120,8 +121,8 @@ fun NavBar(onProfile : Boolean = false ,
fun ButtonIconVectorInt(img : ImageVector, name : String, nav : (Int)->Unit ,index: Int,onPage : Boolean){
IconButton(onClick = {nav(index)},
enabled = !onPage,
colors = IconButtonColors(Color.Transparent, colorButtonNav,//couleur quand il n'est pas selectionné
Color.Transparent, colorButtonNavSelected),//couleur quand il est selectionné
colors = IconButtonColors(Color.Transparent, MaterialTheme.colorScheme.onBackground,//couleur quand il n'est pas selectionné
Color.Transparent, MaterialTheme.colorScheme.primary),//couleur quand il est selectionné
modifier = Modifier
.size(60.dp)
) {
@ -138,8 +139,8 @@ fun ButtonIconVectorInt(img : ImageVector, name : String, nav : (Int)->Unit ,ind
fun ButtonIconPainterInt(img : Painter, name : String, nav : (Int)->Unit,index: Int,onPage : Boolean){
IconButton(onClick = {nav(index)},
enabled = !onPage,
colors = IconButtonColors(Color.Transparent,colorButtonNav,//couleur quand il n'est pas selectionné
Color.Transparent, colorButtonNavSelected),//couleur quand il est selectionné
colors = IconButtonColors(Color.Transparent,MaterialTheme.colorScheme.onBackground,//couleur quand il n'est pas selectionné
Color.Transparent, MaterialTheme.colorScheme.primary),//couleur quand il est selectionné
modifier = Modifier
.size(60.dp)
) {

@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@ -35,7 +36,7 @@ fun QuoteLittle(quote: Quote, modifier: Modifier = Modifier) {
.fillMaxWidth()
.padding(8.dp)
.clip(RoundedCornerShape(16.dp))
.background(colorBackground)
.background(MaterialTheme.colorScheme.background)
) {
Image(
painter = rememberAsyncImagePainter(quote.imgUrl),
@ -63,12 +64,12 @@ fun QuoteLittle(quote: Quote, modifier: Modifier = Modifier) {
bottomEnd = 12.dp
)
)
.background(gradienBox)
.background(MaterialTheme.colorScheme.primary)
.padding(12.dp)
) {
Text(
text = quote.content,
color = Color.White,
color = MaterialTheme.colorScheme.onPrimary,
fontSize = 16.sp,
maxLines = 2,
overflow = TextOverflow.Ellipsis
@ -77,14 +78,14 @@ fun QuoteLittle(quote: Quote, modifier: Modifier = Modifier) {
Text(
text = "${quote.type} : ${quote.source}",
color = Color.White,
color = MaterialTheme.colorScheme.onPrimary,
fontSize = 12.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Text(
text = "${Character}: ${quote.character}",
color = Color.White,
color = MaterialTheme.colorScheme.onPrimary,
fontSize = 12.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis

@ -3,6 +3,7 @@ package com.example.what_the_fantasy.ui.navigations
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@ -65,7 +66,7 @@ fun AppNavigator() {
Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = colorNavBar
containerColor = MaterialTheme.colorScheme.onPrimary
) { paddingValues ->
Box(modifier = Modifier.padding(paddingValues)) {
NavHost(navController, startDestination = Login) {

@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@ -51,14 +52,14 @@ fun AccueilPage(
Column(
modifier = Modifier
.fillMaxSize()
.background(colorBackground)
.background(MaterialTheme.colorScheme.background)
) {
LazyColumn(modifier = Modifier.weight(1f)) {
item{
Column {
Text(
text = titleDalyQuote,
color = Color.White,
color = MaterialTheme.colorScheme.onBackground,
fontSize = 24.sp,
modifier = Modifier
.fillMaxWidth()
@ -70,7 +71,7 @@ fun AccueilPage(
}
Text(
text = titleSuggestion,
color = Color.White,
color = MaterialTheme.colorScheme.onBackground,
fontSize = 24.sp,
modifier = Modifier
.fillMaxWidth()

@ -5,6 +5,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@ -43,14 +44,14 @@ fun FavoritePage(
Box(
modifier = Modifier
.fillMaxSize()
.background(colorBackground),
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.TopCenter
){
LazyColumn {
item{
Text(
text = TitlePage,
color = Color.White,
color = MaterialTheme.colorScheme.onBackground,
fontSize = 24.sp,
modifier = Modifier
.fillMaxWidth()

@ -12,6 +12,7 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@ -47,7 +48,7 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
Box(
modifier = Modifier
.fillMaxSize()
.background(colorBackground),
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.Center
){
Column(
@ -55,16 +56,16 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
.fillMaxWidth(0.9f)
.padding(20.dp)
.clip(RoundedCornerShape(16.dp))
.background(gradienBox)
.background(MaterialTheme.colorScheme.onPrimary)
.padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
TitlePageComponent(R.string.titleLogin, Color.White)
TitlePageComponent(R.string.titleLogin, MaterialTheme.colorScheme.primary)
SpaceHeightComponent(20)
ConnexionButtonLogin(users,IdentifiantTextField(R.string.IdentifiantLogin), PassWdTextField(R.string.PasswdLogin), R.string.ButtonLogin,18, Color.White, Color.Black,navControllerProfil)
SpaceHeightComponent(16)
CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp)
CreateAccountButton(R.string.ButtonCreateLogin,12, MaterialTheme.colorScheme.primary, navControllerSignUp)
}
}
}
@ -75,7 +76,7 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
@Composable
fun IdentifiantTextField(textIdentifiantResId : Int) : String{
val textIdentifiant = stringResource(id = textIdentifiantResId)
var identifiant by remember { mutableStateOf("") } // Stocke la valeur du champ
var identifiant by remember { mutableStateOf("") }
Column(modifier = Modifier.padding(top = 16.dp)) {
OutlinedTextField(
value = identifiant,
@ -85,7 +86,7 @@ fun IdentifiantTextField(textIdentifiantResId : Int) : String{
.fillMaxWidth()
.padding(top = 8.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
shape = RoundedCornerShape(16.dp) // Bords arrondis
shape = RoundedCornerShape(16.dp)
)
}
return identifiant;
@ -94,8 +95,8 @@ fun IdentifiantTextField(textIdentifiantResId : Int) : String{
@Composable
fun PassWdTextField(textpasswdResId : Int) : String{
val textpasswd = stringResource(id = textpasswdResId)
var passwd by remember { mutableStateOf("") } // Stocke la valeur du champ
var passwordVisible by remember { mutableStateOf(false) } // État pour afficher/masquer
var passwd by remember { mutableStateOf("") }
var passwordVisible by remember { mutableStateOf(false) }
Column(modifier = Modifier.padding(top = 10.dp, bottom = 30.dp)) {
OutlinedTextField(
value = passwd,
@ -110,7 +111,7 @@ fun PassWdTextField(textpasswdResId : Int) : String{
IconButton(onClick = { passwordVisible = !passwordVisible }) {
}
},
shape = RoundedCornerShape(16.dp) // Bords arrondis
shape = RoundedCornerShape(16.dp)
)
}
return passwd;
@ -124,11 +125,11 @@ fun ConnexionButtonLogin(userStub : List<User>, id : String, passwd : String, ti
Button(
onClick = { showError = !validLogin(id, passwd, userStub, navController)
},
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.background),
modifier = Modifier
.fillMaxWidth(),
) {
Text(title, fontSize = size.sp, color = colorText)
Text(title, fontSize = size.sp, color = MaterialTheme.colorScheme.onBackground)
}
if(showError){
@ -143,7 +144,7 @@ fun validLogin(identifiant : String, passwd : String, users : List<User>, navCon
users.forEachIndexed { index, user ->
val hashPassWd = hashPassword(passwd)
if (user.username == identifiant && user.password == hashPassWd) {
navController(index) // Passer l'index à la fonction navController
navController(index)
logsUser.logInformationUserConnect(user, "UserConnect")
return true
}
@ -157,9 +158,9 @@ fun CreateAccountButton(titleResId : Int, size : Int, color : Color, navControll
Text(
text = title,
fontSize = size.sp,
color = color,
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.clickable {
navController()// rediriger vers la page de création de compte
navController()
}
)
}

@ -23,6 +23,7 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@ -75,7 +76,7 @@ fun ProfilPage(index: Int,
Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFF100C1B)),
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.Center
) {
Column(
@ -83,13 +84,13 @@ fun ProfilPage(index: Int,
.fillMaxWidth(0.9f)
.padding(20.dp)
.clip(RoundedCornerShape(16.dp))
.background(gradienBox)
.background(MaterialTheme.colorScheme.primary)
.padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
// Titre
TitlePageComponent(R.string.titleProfile, Color.White)
TitlePageComponent(R.string.titleProfile, MaterialTheme.colorScheme.onPrimary)
SpaceHeightComponent(16)
// Image de profil
@ -108,9 +109,9 @@ fun ProfilPage(index: Int,
// Bouton
//ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
//SpaceHeightComponent(16)
ButtonLanguage(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,services, user)
ButtonLanguage(R.string.ButtonLanguageprofile, 18, MaterialTheme.colorScheme.onPrimary, MaterialTheme.colorScheme.background,services, user)
SpaceHeightComponent(16)
ButtonUnLog(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White,navUnLog)
ButtonUnLog(R.string.ButtonUnlogprofile, 18, MaterialTheme.colorScheme.onPrimary, MaterialTheme.colorScheme.background,navUnLog)
@ -173,7 +174,7 @@ fun EmailEditingField(
value = email,
onValueChange = onEmailChange,
modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(color = Color.White, fontSize = 18.sp),
textStyle = TextStyle(color = MaterialTheme.colorScheme.primary, fontSize = 18.sp),
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Email,
@ -206,12 +207,12 @@ fun DisplayEmail(email: String, onEdit: () -> Unit) {
text = email,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
color = Color.White
color = MaterialTheme.colorScheme.onPrimary
)
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "Modifier",
tint = Color.White,
tint = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.size(16.dp).padding(start = 8.dp)
)
}
@ -249,7 +250,7 @@ fun UsernameEditingField(
value = username,
onValueChange = onUsernameChange,
modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(color = Color.White, fontSize = 18.sp),
textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp),
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Done
@ -275,12 +276,12 @@ fun DisplayUsername(username: String, onEdit: () -> Unit) {
text = username,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
color = Color.White
color = MaterialTheme.colorScheme.onPrimary
)
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "Modifier",
tint = Color.White,
tint = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.size(16.dp).padding(start = 8.dp)
)
}
@ -386,7 +387,7 @@ fun PasswordTextField(
onValueChange = onValueChange,
label = { Text(label) },
modifier = Modifier.fillMaxWidth(),
textStyle = TextStyle(color = Color.White, fontSize = 18.sp),
textStyle = TextStyle(color = MaterialTheme.colorScheme.onPrimary, fontSize = 18.sp),
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Password,
@ -409,13 +410,13 @@ fun PasswordTextField(
fun SaveButton(onClick: () -> Unit) {
Button(
onClick = onClick,
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.onPrimary),
modifier = Modifier.fillMaxWidth()
) {
val text = stringResource(id = R.string.ButtonSaveprofile)
Text(text,
fontSize = 18.sp,
color = Color.Black)
color = MaterialTheme.colorScheme.primary)
}
}
@ -429,12 +430,12 @@ fun DisplayPassword(onEdit: () -> Unit) {
text = "*****",
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
color = Color.White
color = MaterialTheme.colorScheme.onPrimary
)
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "Modifier",
tint = Color.White,
tint = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.size(16.dp).padding(start = 8.dp)
)
}
@ -450,10 +451,10 @@ fun ButtonUnLog(textResId : Int, size :Int, colorTexte : Color, colorButton : Co
navController()
logsUser.unlogInformationUserConnect("UserUnLog")
},
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.background),
modifier = Modifier.fillMaxWidth(),
) {
Text(text, fontSize = size.sp, color = colorTexte)
Text(text, fontSize = size.sp, color = MaterialTheme.colorScheme.primary)
}
}
@ -469,6 +470,6 @@ fun ButtonLanguage(textResId : Int, size :Int, colorTexte : Color, colorButton :
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
modifier = Modifier.fillMaxWidth(),
) {
Text("${text} (${currentLangage.value})", fontSize = size.sp, color = colorTexte)
Text("${text} (${currentLangage.value})", fontSize = size.sp, color = MaterialTheme.colorScheme.primary)
}
}

@ -15,12 +15,12 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
@ -49,7 +49,7 @@ fun QuizMenu(
) {
Column(
modifier = Modifier.fillMaxSize().background(Color(0xFF100C1B))
modifier = Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)
) {
// Contenu princiapl
Column(
@ -61,7 +61,7 @@ fun QuizMenu(
) {
Text(
text = "▶ Menu des Quiz ◀",
color = Color.White,
color = MaterialTheme.colorScheme.onBackground,
style = TextStyle(
fontSize = 25.sp,
fontWeight = FontWeight.Bold,
@ -71,7 +71,7 @@ fun QuizMenu(
Spacer(Modifier.height(20.dp))
Column(
modifier = Modifier
.background(brush = gradient, shape = RoundedCornerShape(20.dp))
.background(MaterialTheme.colorScheme.onPrimary, shape = RoundedCornerShape(20.dp))
.fillMaxSize()
.padding(vertical = 30.dp)
.verticalScroll(rememberScrollState()),
@ -110,7 +110,7 @@ fun QuizMenu(
fontSize = 17.sp,
fontWeight = FontWeight.Medium,
textAlign = TextAlign.Center,
color = Color.White
color = MaterialTheme.colorScheme.primary
)
)
}

@ -4,6 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@ -37,7 +38,7 @@ fun QuizPage(
var pts by remember { mutableIntStateOf(0) }
val gradient = Brush.linearGradient(
colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)),
colors = listOf(MaterialTheme.colorScheme.onPrimary, MaterialTheme.colorScheme.onPrimary),
start = Offset(0f, 1000f),
end = Offset(1000f, 0f)
)

@ -127,7 +127,7 @@ fun RecapSubmitPage(
}
@Composable
fun QuoteText(text: String ){
fun QuoteText2(text: String ){
Text(
text = text,
modifier = Modifier.padding(start = 10.dp, top = 15.dp),
@ -138,7 +138,7 @@ fun QuoteText(text: String ){
}
@Composable
fun ImageQuote(imageUrl : String){
fun ImageQuote2(imageUrl : String){
AsyncImage(
model = imageUrl,
contentDescription = "exemple",
@ -149,7 +149,7 @@ fun ImageQuote(imageUrl : String){
}
@Composable
fun InfoQuoteText(nameId : Int, text : String){
fun InfoQuoteText2(nameId : Int, text : String){
Column(modifier = Modifier.padding(bottom = 20.dp)){
Text(

@ -56,4 +56,13 @@
//Page Accueil
<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>
<string name="timeCode">Time Code</string>
<string name="year">Year</string>
<string name="ErrorSubmitQuote"> Invalid Fields </string>
</resources>

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

Loading…
Cancel
Save