From 0e97e3780252e7b1fe1bf3a6a96980e49a1c8417 Mon Sep 17 00:00:00 2001 From: "louis.guichard-montguers" Date: Mon, 3 Mar 2025 11:45:58 +0100 Subject: [PATCH] ajout d'un button qui marche pas encore --- .../ui/navigations/AppNavigator.kt | 2 +- .../ui/screens/QuizEndPage.kt | 59 ++++++++++++++++++- .../app/src/main/res/values-fr/strings.xml | 4 ++ .../app/src/main/res/values/strings.xml | 3 + 4 files changed, 64 insertions(+), 4 deletions(-) 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 5ab890c..edda6a4 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 @@ -156,7 +156,7 @@ fun AppNavigator() { QuizEndPage( idQuiz, pts, - navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) } + navMenu = { navController.navigate(Destination.QuizMenu.route) } ) } } diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt index 6b1d652..90efdf7 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuizEndPage.kt @@ -8,6 +8,8 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text @@ -18,6 +20,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign @@ -33,7 +36,7 @@ val gradient = Brush.linearGradient( ) @Composable -fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) { +fun QuizEndPage(idQuiz: Int, points: Int, navMenu: (Int) -> Unit) { Column( modifier = Modifier.fillMaxSize().background(Color(0xFF100C1B)) ) { @@ -76,7 +79,8 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) { .background(brush = gradient, shape = RoundedCornerShape(20.dp)) .padding(30.dp) .fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.SpaceEvenly ) { Text ( text = "Quiz N°$idQuiz", @@ -96,9 +100,41 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) { color = Color.White, style = TextStyle(fontSize = 15.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center) ) + + val note = when { + points == 10 -> "S" + points >= 7 -> "A" + points >= 4 -> "B" + else -> "C" + } + + Box( + contentAlignment = Alignment.Center, + modifier = Modifier + .size(100.dp) + .background(Color.White, shape = RoundedCornerShape(50.dp)) + ) { + Text( + text = note, + color = Color.Red, + style = TextStyle( + fontSize = 40.sp, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Center + ) + ) + } + + ButtonQuiz(R.string.Quiz, 18, Color.Black, Color.White, navMenu) } + + + } + + + // // Bandeau inférieur // Row( // modifier = Modifier @@ -129,4 +165,21 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) { // ) // } } -} \ No newline at end of file + + +} + +@Composable +fun ButtonQuiz(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: (Int) -> Unit){ + val text = stringResource(id = textResId) + Button( + onClick = { navController(1) }, + colors = ButtonDefaults.buttonColors(containerColor = colorButton), + modifier = Modifier + .fillMaxWidth() + ) { + Text(text, fontSize = size.sp, color = colorTexte) + } +} + + 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 6485726..1859f03 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 @@ -34,4 +34,8 @@ Sauvegarder L\'adress email est invalide Les mots de passe ne correspondent pas + + //QuizEndPage + tous les quiz + \ 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 254d478..c84e7d5 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -34,4 +34,7 @@ Invalid email address Passwords do not match + + //QuizEndPage + All Quiz \ No newline at end of file