From c0301aa604019565accf9c7b973e96247ee439d4 Mon Sep 17 00:00:00 2001 From: brongniart Date: Thu, 20 Feb 2025 12:00:04 +0100 Subject: [PATCH 1/2] =?UTF-8?q?cr=C3=A9ation=20navbar=20a=20finir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../what_the_fantasy/ui/components/NavBar.kt | 30 ++++++++++++++++++- .../what_the_fantasy/ui/screens/LoginPage.kt | 3 ++ .../what_the_fantasy/ui/theme/Color.kt | 4 ++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt index dedbd00..14dba5f 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt @@ -1,4 +1,32 @@ package com.example.what_the_fantasy.ui.components -class NavBar { +import android.widget.ImageView +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.FlowRow + +import androidx.compose.foundation.layout.Row +import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import com.example.what_the_fantasy.R +import com.example.what_the_fantasy.ui.theme.colorNavBar + + +@Composable +fun NavBar(actualPage :String) { + FlowRow(modifier = Modifier + .background(colorNavBar), + Arrangement.SpaceAround + ){ + Text("Favorie") + Image( painter = painterResource(R.mipmap.ic_launcher_foreground), contentDescription = "Accueil") + Text("Quiz") + + } + } \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt index f6e1023..86c06ff 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt @@ -38,6 +38,7 @@ import androidx.navigation.compose.composable import com.example.what_the_fantasy.R import com.example.what_the_fantasy.data.local.UserStub import com.example.what_the_fantasy.data.model.User +import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.SpaceHeightComponent import com.example.what_the_fantasy.ui.components.TitlePageComponent import com.example.what_the_fantasy.ui.theme.colorBackground @@ -56,6 +57,7 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: () -> Unit) .background(colorBackground), contentAlignment = Alignment.Center ){ + Column( modifier = Modifier .fillMaxWidth(0.9f) @@ -74,6 +76,7 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: () -> Unit) SpaceHeightComponent(16) CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp) } + NavBar("") } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt index 41c8deb..64ce917 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/theme/Color.kt @@ -16,4 +16,6 @@ val gradienBox = Brush.linearGradient( start = Offset(0f, 1000f), // Départ en bas à gauche end = Offset(1000f, 0f) // Fin en haut à droite ) -val colorBackground = Color(0xFF100C1B) \ No newline at end of file +val colorBackground = Color(0xFF100C1B) + +val colorNavBar = Color(0xFF2F0E62) \ No newline at end of file From 0224bbf149b51b8b2dca6a213f47489ecd25830f Mon Sep 17 00:00:00 2001 From: brongniart Date: Thu, 20 Feb 2025 15:53:25 +0100 Subject: [PATCH 2/2] =?UTF-8?q?NavBar=20inf=C3=A9rieur=20et=20sup=C3=A9rie?= =?UTF-8?q?ur=20faite=20style=20bouton=20a=20corig=C3=A9=20&=20mettre=20la?= =?UTF-8?q?=20nav=20dans=20les=20onclick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../what_the_fantasy/ui/components/NavBar.kt | 81 +++++++++++-- .../ui/screens/AccueilPage.kt | 7 +- .../ui/screens/FavoritePage.kt | 7 +- .../what_the_fantasy/ui/screens/LoginPage.kt | 4 +- .../what_the_fantasy/ui/screens/ProfilPage.kt | 78 ++++++------- .../what_the_fantasy/ui/screens/QuizPage.kt | 106 +++++++++--------- .../what_the_fantasy/ui/screens/QuotePage.kt | 7 +- .../what_the_fantasy/ui/screens/SearchPage.kt | 7 +- .../ui/screens/SubmitQuotePage.kt | 7 +- 9 files changed, 198 insertions(+), 106 deletions(-) diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt index 14dba5f..a922a8e 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/components/NavBar.kt @@ -4,29 +4,92 @@ import android.widget.ImageView import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.Button 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.onGloballyPositioned import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.TextUnit +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.example.what_the_fantasy.R +import com.example.what_the_fantasy.ui.navigations.AppNavigator import com.example.what_the_fantasy.ui.theme.colorNavBar @Composable -fun NavBar(actualPage :String) { - FlowRow(modifier = Modifier - .background(colorNavBar), - Arrangement.SpaceAround - ){ - Text("Favorie") - Image( painter = painterResource(R.mipmap.ic_launcher_foreground), contentDescription = "Accueil") - Text("Quiz") +fun NavBar(content : @Composable ()-> Unit ) { + val nav = AppNavigator() + + Column( + modifier = Modifier + .fillMaxSize() + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .height(55.dp) + .background(colorNavBar) + .padding(10.dp), + Arrangement.SpaceBetween, + verticalAlignment = Alignment.Bottom + ) { + Button(onClick = {}, Modifier.background(Color.Unspecified)) { + Text("Profile", fontSize = 25.sp, color = Color.White) + } + Button(onClick = {}) { + Text("Theme", fontSize = 25.sp, color = Color.White) + } + + } + + Box(modifier = Modifier.background(Color.Black).fillMaxHeight(0.92f)){ + content() + } + + Row(modifier = Modifier + .background(colorNavBar) + .fillMaxSize(), + horizontalArrangement = Arrangement.SpaceAround, + verticalAlignment = Alignment.CenterVertically + ) { + + Button(onClick = {}) { + Text("Favorie", fontSize = 25.sp, color = Color.White) + } + + Button(onClick = {}) { + Image( + painter = painterResource(R.mipmap.ic_launcher_foreground), + contentDescription = "Accueil", + modifier = Modifier + .size(100.dp) + ) + } + + Button(onClick = {}) { + Text("Quiz", fontSize = 25.sp, color = Color.White) + } } + + } } \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt index 8fd4c97..4f5b249 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/AccueilPage.kt @@ -1,6 +1,11 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.runtime.Composable +import com.example.what_the_fantasy.ui.components.NavBar @Composable -fun AccueilPage() {} \ No newline at end of file +fun AccueilPage() { + NavBar { + + } +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt index 72c2e72..8945f9e 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/FavoritePage.kt @@ -1,6 +1,11 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.runtime.Composable +import com.example.what_the_fantasy.ui.components.NavBar @Composable -fun FavoritePage() {} \ No newline at end of file +fun FavoritePage() { + NavBar { + + } +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt index 86c06ff..ab97777 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/LoginPage.kt @@ -50,7 +50,6 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: () -> Unit) val users = UserStub.allUsers; - Box( modifier = Modifier .fillMaxSize() @@ -76,8 +75,9 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: () -> Unit) SpaceHeightComponent(16) CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp) } - NavBar("") + } + } 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 cdfbec9..e9ab71f 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 @@ -62,6 +62,7 @@ import com.example.what_the_fantasy.R import com.example.what_the_fantasy.data.local.QuestionStub import com.example.what_the_fantasy.data.local.UserStub import com.example.what_the_fantasy.ui.components.ErrorMessageProfileComponent +import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.SpaceHeightComponent import com.example.what_the_fantasy.ui.components.TitlePageComponent import com.example.what_the_fantasy.ui.theme.What_The_FantasyTheme @@ -75,47 +76,48 @@ fun ProfilPage(navController: NavController) { ) val user = UserStub.allUsers val index = 2 // Pour changer l'utilisateur pour le moment - - Box( - modifier = Modifier - .fillMaxSize() - .background(Color(0xFF100C1B)), - contentAlignment = Alignment.Center - ) { - Column( + NavBar { + Box( modifier = Modifier - .fillMaxWidth(0.9f) - .padding(20.dp) - .clip(RoundedCornerShape(16.dp)) - .background(gradient) - .padding(20.dp), - horizontalAlignment = Alignment.CenterHorizontally + .fillMaxSize() + .background(Color(0xFF100C1B)), + contentAlignment = Alignment.Center ) { + Column( + modifier = Modifier + .fillMaxWidth(0.9f) + .padding(20.dp) + .clip(RoundedCornerShape(16.dp)) + .background(gradient) + .padding(20.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + + // Titre + TitlePageComponent(R.string.titleProfile, 20, Color.White) + SpaceHeightComponent(16) + + // Image de profil + ImageProfil(user[index].imgUrl, 120, 2, Color.White) + SpaceHeightComponent(16) + + EditUsername(user[index].username)// Édition du Username + SpaceHeightComponent(16) + + EditEmail(user[index].email)// Édition du Email + Spacer(modifier = Modifier.height(8.dp)) + + EditPasswd() + SpaceHeightComponent(16) + + // Bouton + ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White) + SpaceHeightComponent(16) + ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White) + SpaceHeightComponent(16) + ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White) - // Titre - TitlePageComponent(R.string.titleProfile, 20, Color.White) - SpaceHeightComponent(16) - - // Image de profil - ImageProfil(user[index].imgUrl, 120, 2, Color.White) - SpaceHeightComponent(16) - - EditUsername(user[index].username)// Édition du Username - SpaceHeightComponent(16) - - EditEmail(user[index].email)// Édition du Email - Spacer(modifier = Modifier.height(8.dp)) - - EditPasswd() - SpaceHeightComponent(16) - - // Bouton - ButtonProfile(R.string.ButtonAddQuoteprofile,18, Color.Black, Color.White) - SpaceHeightComponent(16) - ButtonProfile(R.string.ButtonLanguageprofile,18, Color.Black, Color.White) - SpaceHeightComponent(16) - ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White) - + } } } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt index a342a02..0405ae3 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizPage.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.example.what_the_fantasy.data.local.QuestionStub import com.example.what_the_fantasy.data.model.Question +import com.example.what_the_fantasy.ui.components.NavBar @Composable fun QuizPage() { @@ -37,68 +38,69 @@ fun QuizPage() { ) val questions = QuestionStub.allQuestions - - Box( - modifier = Modifier - .fillMaxSize() - .background(Color(0xFF100C1B)) // Fond global de l'écran - .padding(16.dp) // Marges autour de tout le contenu - ) { - // Numéro de la question en haut - Text( - text = "Question numéro : " + questions.first().id.toString(), - color = Color.White, - fontSize = 18.sp, // Taille réduite pour tenir sur un écran portrait - modifier = Modifier - .align(Alignment.TopCenter) // Position en haut au centre - .padding(top = 16.dp) // Un peu d'espace en haut - ) - - // Contenu centré, mais avec une gestion plus équilibrée du placement - Column( + NavBar { + Box( modifier = Modifier .fillMaxSize() - .padding(top = 48.dp), // Réduit l'espace entre le numéro de la question et la question elle-même - verticalArrangement = Arrangement.Center, // Centre verticalement - horizontalAlignment = Alignment.CenterHorizontally // Centre horizontalement + .background(Color(0xFF100C1B)) // Fond global de l'écran + .padding(16.dp) // Marges autour de tout le contenu ) { - // Question principale + // Numéro de la question en haut Text( - text = questions.first().question, + text = "Question numéro : " + questions.first().id.toString(), color = Color.White, - fontSize = 22.sp, // Taille plus petite pour tenir sur un écran portrait - modifier = Modifier.padding(bottom = 16.dp) // Réduit l'espacement entre la question et les réponses + fontSize = 18.sp, // Taille réduite pour tenir sur un écran portrait + modifier = Modifier + .align(Alignment.TopCenter) // Position en haut au centre + .padding(top = 16.dp) // Un peu d'espace en haut ) - // Liste des réponses - val answers = listOf( - questions.first().ansA, - questions.first().ansB, - questions.first().ansC, - questions.first().ansD - ) + // Contenu centré, mais avec une gestion plus équilibrée du placement + Column( + modifier = Modifier + .fillMaxSize() + .padding(top = 48.dp), // Réduit l'espace entre le numéro de la question et la question elle-même + verticalArrangement = Arrangement.Center, // Centre verticalement + horizontalAlignment = Alignment.CenterHorizontally // Centre horizontalement + ) { + // Question principale + Text( + text = questions.first().question, + color = Color.White, + fontSize = 22.sp, // Taille plus petite pour tenir sur un écran portrait + modifier = Modifier.padding(bottom = 16.dp) // Réduit l'espacement entre la question et les réponses + ) + + // Liste des réponses + val answers = listOf( + questions.first().ansA, + questions.first().ansB, + questions.first().ansC, + questions.first().ansD + ) - // Pour chaque réponse, on applique une Box avec un espacement uniforme - answers.forEach { answer -> - Box( - modifier = Modifier - .width(220.dp) // Largeur plus petite pour que ça tienne mieux - .height(50.dp) // Hauteur ajustée - .background( - brush = gradient, - shape = RoundedCornerShape(16.dp) // Coins arrondis + // Pour chaque réponse, on applique une Box avec un espacement uniforme + answers.forEach { answer -> + Box( + modifier = Modifier + .width(220.dp) // Largeur plus petite pour que ça tienne mieux + .height(50.dp) // Hauteur ajustée + .background( + brush = gradient, + shape = RoundedCornerShape(16.dp) // Coins arrondis + ) + .clickable { /* Action pour la réponse */ } + .padding(horizontal = 8.dp), // Padding interne + contentAlignment = Alignment.Center + ) { + Text( + text = answer, + color = Color.White, + fontSize = 18.sp // Taille du texte ajustée pour un écran portrait ) - .clickable { /* Action pour la réponse */ } - .padding(horizontal = 8.dp), // Padding interne - contentAlignment = Alignment.Center - ) { - Text( - text = answer, - color = Color.White, - fontSize = 18.sp // Taille du texte ajustée pour un écran portrait - ) + } + Spacer(modifier = Modifier.height(16.dp)) // Espacement réduit entre les réponses } - Spacer(modifier = Modifier.height(16.dp)) // Espacement réduit entre les réponses } } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt index cfb1d2f..a5b82e7 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt @@ -1,6 +1,11 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.runtime.Composable +import com.example.what_the_fantasy.ui.components.NavBar @Composable -fun QuotePage() {} \ No newline at end of file +fun QuotePage() { + NavBar { + + } +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SearchPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SearchPage.kt index 9b8d6ac..be429f8 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SearchPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/SearchPage.kt @@ -1,6 +1,11 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.runtime.Composable +import com.example.what_the_fantasy.ui.components.NavBar @Composable -fun SearchPage() {} \ No newline at end of file +fun SearchPage() { + NavBar { + + } +} \ No newline at end of file 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 0b88b35..42913ae 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 @@ -1,6 +1,11 @@ package com.example.what_the_fantasy.ui.screens import androidx.compose.runtime.Composable +import com.example.what_the_fantasy.ui.components.NavBar @Composable -fun SubmitQuotePage() {} \ No newline at end of file +fun SubmitQuotePage() { + NavBar { + + } +} \ No newline at end of file