ajoout QuizAccueil

pull/19/head
parent 1cdf28bcdd
commit 3a01eaa1b7

@ -11,10 +11,13 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.navigation.compose.rememberNavController
import com.example.what_the_fantasy.ui.screens.AppNavigator import com.example.what_the_fantasy.ui.screens.AppNavigator
import com.example.what_the_fantasy.ui.theme.What_The_FantasyTheme import com.example.what_the_fantasy.ui.theme.What_The_FantasyTheme
import com.example.what_the_fantasy.ui.screens.LoginPage import com.example.what_the_fantasy.ui.screens.LoginPage
import com.example.what_the_fantasy.ui.screens.ProfilPage import com.example.what_the_fantasy.ui.screens.ProfilPage
import com.example.what_the_fantasy.ui.screens.QuizAccueil
import com.example.what_the_fantasy.ui.screens.QuizApp
import com.example.what_the_fantasy.ui.screens.QuizPage import com.example.what_the_fantasy.ui.screens.QuizPage
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
@ -31,9 +34,10 @@ class MainActivity : ComponentActivity() {
) )
} }
} }
//AppNavigator() // Accès à la page login et SingUp (pour le moment) //AppNavigator() // Accès à la page login et SingUp (pour le moment)
//ProfilPage() //Accès à la page profil //ProfilPage() //Accès à la page profil
QuizPage() QuizApp()
} }
} }
} }

@ -0,0 +1,136 @@
package com.example.what_the_fantasy.ui.screens
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.what_the_fantasy.R
@Composable
fun QuizAccueil(navController: NavController) {
Row(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFF100C1B))
.padding(top = 100.dp)
) {
Spacer(modifier = Modifier.weight(0.1f))
Column(
modifier = Modifier
.weight(0.9f)
.fillMaxHeight(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.size(width = 150.dp, height = 100.dp)
.padding(8.dp)
.clickable {
navController.navigate("quizPage")
}
) {
Image(
painter = painterResource(id = R.drawable.quiz),
contentDescription = "Quiz 1",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
}
Box(
modifier = Modifier
.size(width = 150.dp, height = 100.dp)
.padding(8.dp)
.clickable {
navController.navigate("quizPage")
}
) {
Image(
painter = painterResource(id = R.drawable.quiz),
contentDescription = "Quiz 2",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
}
}
Spacer(modifier = Modifier.width(10.dp))
Column(
modifier = Modifier
.weight(0.9f)
.fillMaxHeight(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.size(width = 150.dp, height = 100.dp)
.padding(8.dp)
.clickable {
navController.navigate("quizPage")
}
) {
Image(
painter = painterResource(id = R.drawable.quiz),
contentDescription = "Quiz 3",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
}
Box(
modifier = Modifier
.size(width = 150.dp, height = 100.dp)
.padding(8.dp)
.clickable {
navController.navigate("quizPage")
}
) {
Image(
painter = painterResource(id = R.drawable.quiz),
contentDescription = "Quiz 4",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
}
}
Spacer(modifier = Modifier.weight(0.1f))
}
}
@Composable
fun QuizApp() {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = "quizAccueil") {
composable("quizAccueil") {
QuizAccueil(navController = navController)
}
composable("quizPage") {
QuizPage(navController = navController)
}
}
}

@ -14,9 +14,13 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -31,6 +35,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.example.what_the_fantasy.data.local.QuestionStub import com.example.what_the_fantasy.data.local.QuestionStub
import com.example.what_the_fantasy.data.model.Question import com.example.what_the_fantasy.data.model.Question
@ -39,7 +44,7 @@ val questions = QuestionStub.allQuestions
var pts = 0 var pts = 0
@Composable @Composable
fun QuizPage() { fun QuizPage(navController: NavController) {
var idCurrentQuestion by remember { mutableIntStateOf(0) } var idCurrentQuestion by remember { mutableIntStateOf(0) }
fun goNext(correctAns: String, ans: String) { fun goNext(correctAns: String, ans: String) {
if (correctAns == "A") { if (correctAns == "A") {
@ -68,6 +73,20 @@ fun QuizPage() {
.background(Color(0xFF100C1B)) // Fond global de l'écran .background(Color(0xFF100C1B)) // Fond global de l'écran
.padding(16.dp) // Marges autour de tout le contenu .padding(16.dp) // Marges autour de tout le contenu
) { ) {
IconButton(
onClick = {
navController.popBackStack() // Revenir à la page précédente (QuizAccueil)
},
modifier = Modifier
.align(Alignment.TopStart)
) {
Icon(
imageVector = Icons.Default.ArrowBack, // Flèche de retour
contentDescription = "Retour",
tint = Color.White
)
}
// Numéro de la question en haut // Numéro de la question en haut
Text( Text(
text = "Question numéro : " + questions[idCurrentQuestion].id.toString(), text = "Question numéro : " + questions[idCurrentQuestion].id.toString(),

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Loading…
Cancel
Save