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 169f329..80a3f4c 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 @@ -17,6 +17,7 @@ import com.example.what_the_fantasy.ui.screens.QuotePage import com.example.what_the_fantasy.ui.screens.SearchPage import com.example.what_the_fantasy.ui.screens.SignUpPage import com.example.what_the_fantasy.ui.screens.SubmitQuotePage +import com.example.what_the_fantasy.ui.screens.validLogin import kotlinx.serialization.Serializable @Serializable @@ -40,7 +41,7 @@ data object Search @Serializable data object SignUp @Serializable -data object SubmitQuote +data class SubmitQuote(val userIndex: Int) @Composable @@ -90,7 +91,8 @@ fun AppNavigator() { popUpTo(profil) { inclusive = true } } }, - services = services + services = services, + navSubmitQuote = { navController.navigate( SubmitQuote(profil.userIndex))} ) } composable { QuotePage() } @@ -102,8 +104,17 @@ fun AppNavigator() { popUpTo(Login) { inclusive = true } } },services) } - composable { SubmitQuotePage() } - + composable { + val submitQuote:SubmitQuote=it.toRoute() + SubmitQuotePage( + index = submitQuote.userIndex, + navControllerProfil = { userIndex -> + navController.navigate(Profil(userIndex)) { + // Vider pile de navigation pour empêcher le retour à la page Login + popUpTo(Login) { inclusive = true } + } + }) + } composable { val quizMenu:QuizMenu=it.toRoute() QuizMenu( 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 b122258..4242829 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 @@ -79,7 +79,8 @@ fun ProfilPage(index: Int, navAccueil: (Int) -> Unit, navQuiz: (Int) -> Unit, navUnLog: () -> Unit, - services: IServices + services: IServices, + navSubmitQuote: () -> Unit ) { val user = services.getUserById(index) ?: return @@ -125,8 +126,8 @@ fun ProfilPage(index: Int, SpaceHeightComponent(16) // Bouton - //ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie - //SpaceHeightComponent(16) + ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navSubmitQuote) // Pas encore de navigation definie + SpaceHeightComponent(16) ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie SpaceHeightComponent(16) ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White, navUnLog) 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 dd6dce6..bb17128 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,8 +1,212 @@ package com.example.what_the_fantasy.ui.screens +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.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +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.OutlinedTextField +import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +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.res.stringResource +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.text.input.VisualTransformation +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.data.model.Character +import com.example.what_the_fantasy.data.model.User +import com.example.what_the_fantasy.data.services.IServices +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.components.hashPassword +import com.example.what_the_fantasy.ui.navigations.Profil +import com.example.what_the_fantasy.ui.theme.colorBackground +import com.example.what_the_fantasy.ui.theme.gradienBox @Composable -fun SubmitQuotePage() { -} \ No newline at end of file +fun SubmitQuotePage( + index : Int, + navControllerProfil: (Int) -> Unit +) { + + + + Box( + modifier = Modifier + .fillMaxSize() + .background(colorBackground), + contentAlignment = Alignment.Center + ){ + Column( + modifier = Modifier + .fillMaxWidth(0.9f) + .padding(20.dp) + .clip(RoundedCornerShape(16.dp)) + .background(gradienBox) + .padding(20.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + TitlePageComponent(R.string.titleSubmitQuote, Color.White) + SpaceHeightComponent(20) + SubmitQuoteButton(QuoteTextField(R.string.quote), CharacterTextField(R.string.character), SourceTextField(R.string.source), TimeCodeTextField(R.string.timeCode), YearTextField(R.string.year), R.string.titleButtonSubmit,18, Color.White, Color.Black) + SpaceHeightComponent(20) + BackButton(R.string.titleButtonBack, 12, Color.White,navControllerProfil, index) + } + } + +} + +@Composable +fun QuoteTextField(textQuoteResId : Int) : String{ + val textQuote = stringResource(id = textQuoteResId) + var quote by remember { mutableStateOf("") } // Stocke la valeur du champ + Column(modifier = Modifier.padding(top = 16.dp)) { + OutlinedTextField( + value = quote, + onValueChange = { quote = it }, + label = { Text(textQuote) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), + shape = RoundedCornerShape(16.dp) // Bords arrondis + ) + } + return quote; +} + +@Composable +fun CharacterTextField(textCharacterResId : Int) : String{ + val textCharacter = stringResource(id = textCharacterResId) + var character by remember { mutableStateOf("") } // Stocke la valeur du champ + + Column(modifier = Modifier.padding(top = 16.dp)) { + OutlinedTextField( + value = character, + onValueChange = { character = it }, + label = { Text(textCharacter) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), + shape = RoundedCornerShape(16.dp) // Bords arrondis + ) + } + return character; +} + +@Composable +fun SourceTextField(textSourceResId : Int) : String{ + val textSource = stringResource(id = textSourceResId) + var source by remember { mutableStateOf("") } // Stocke la valeur du champ + Column(modifier = Modifier.padding(top = 16.dp)) { + OutlinedTextField( + value = source, + onValueChange = { source = it }, + label = { Text(textSource) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), + shape = RoundedCornerShape(16.dp) // Bords arrondis + ) + } + return source; +} + + +@Composable +fun TimeCodeTextField(textTimeCodeResId : Int) : String{ + val textTimeCode = stringResource(id = textTimeCodeResId) + var timeCode by remember { mutableStateOf("") } // Stocke la valeur du champ + Column(modifier = Modifier.padding(top = 16.dp)) { + OutlinedTextField( + value = timeCode, + onValueChange = { timeCode = it }, + label = { Text(textTimeCode) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), + shape = RoundedCornerShape(16.dp) // Bords arrondis + ) + } + return timeCode; +} + + +@Composable +fun YearTextField(textYearResId : Int) : String{ + val textYear = stringResource(id = textYearResId) + var year by remember { mutableStateOf("") } // Stocke la valeur du champ + Column(modifier = Modifier.padding(top = 16.dp, bottom = 30.dp)) { + OutlinedTextField( + value = year, + onValueChange = { year = it }, + label = { Text(textYear) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), + shape = RoundedCornerShape(16.dp) // Bords arrondis + ) + } + return year; +} + + +@Composable +fun SubmitQuoteButton( quote : String, character : String, source: String, timeCode: String, year: String , titleResId : Int, size : Int, colorButton : Color, colorText : Color){ + val title = stringResource(id = titleResId) + var showError by remember { mutableStateOf(false) } + Button( + onClick = { showError = validSubmitQuote() + }, + colors = ButtonDefaults.buttonColors(containerColor = colorButton), + modifier = Modifier + .fillMaxWidth(), + ) { + Text(title, fontSize = size.sp, color = colorText) + } + + if(showError){ + ErrorMessageProfileComponent(R.string.ErrorLogin) + } +} + +fun validSubmitQuote(): Boolean{ + return true +} + +@Composable +fun BackButton(titleResId : Int, size : Int, color : Color, navController: (Int) -> Unit, user: Int) { + val title = stringResource(id = titleResId) + Text( + text = title, + fontSize = size.sp, + color = color, + modifier = Modifier.clickable { + navController(user) + } + ) +} + 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 84332fa..19d5e87 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 @@ -43,4 +43,14 @@ //Page Favori Favoris + + //Page Submit Quote + Proposez Une Citation + Proposez + Profile + citation + personnage + source + code temporel + année de sortie \ 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 2fcce63..63bf200 100644 --- a/What_The_Fantasy/app/src/main/res/values/strings.xml +++ b/What_The_Fantasy/app/src/main/res/values/strings.xml @@ -41,4 +41,13 @@ //Page Favori Favorites + //Page SubmitQuote + Submit Quote + Submit + Profil + quote + character + source + time code + year \ No newline at end of file