page submitQuote manque juste la verification

submitQuote
parent 0add75488b
commit 5c2a195b95

@ -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<Quote> { QuotePage() }
@ -102,8 +104,17 @@ fun AppNavigator() {
popUpTo(Login) { inclusive = true }
}
},services) }
composable<SubmitQuote> { SubmitQuotePage() }
composable<SubmitQuote> {
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<QuizMenu> {
val quizMenu:QuizMenu=it.toRoute()
QuizMenu(

@ -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)

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

@ -43,4 +43,14 @@
//Page Favori
<string name="TitleFavorite">Favoris</string>
//Page Submit Quote
<string name="titleSubmitQuote">Proposez Une Citation</string>
<string name="titleButtonSubmit">Proposez</string>
<string name="titleButtonBack">Profile</string>
<string name="quote">citation</string>
<string name="character">personnage</string>
<string name="source">source</string>
<string name="timeCode">code temporel</string>
<string name="year">année de sortie</string>
</resources>

@ -41,4 +41,13 @@
//Page Favori
<string name="TitleFavorite">Favorites</string>
//Page SubmitQuote
<string name="titleSubmitQuote">Submit Quote</string>
<string name="titleButtonSubmit">Submit</string>
<string name="titleButtonBack">Profil</string>
<string name="quote">quote</string>
<string name="character">character</string>
<string name="source">source</string>
<string name="timeCode">time code</string>
<string name="year">year</string>
</resources>
Loading…
Cancel
Save