ajout d'un button qui marche pas encore

ErrorMessage
parent 0867d41e1f
commit 0e97e37802

@ -156,7 +156,7 @@ fun AppNavigator() {
QuizEndPage(
idQuiz,
pts,
navControllerQuizMenu = { navController.navigate(Destination.QuizMenu.route) }
navMenu = { navController.navigate(Destination.QuizMenu.route) }
)
}
}

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

@ -34,4 +34,8 @@
<string name="ButtonSaveprofile">Sauvegarder</string>
<string name="ErrorEmailprofile">L\'adress email est invalide</string>
<string name="Errorpasswdprofile">Les mots de passe ne correspondent pas</string>
//QuizEndPage
<string name="Quiz">tous les quiz</string>
</resources>

@ -34,4 +34,7 @@
<string name="ErrorEmailprofile">Invalid email address</string>
<string name="Errorpasswdprofile">Passwords do not match</string>
//QuizEndPage
<string name="Quiz">All Quiz</string>
</resources>
Loading…
Cancel
Save