|
|
|
@ -14,6 +14,8 @@ import androidx.compose.material3.ButtonDefaults
|
|
|
|
|
import androidx.compose.material3.IconButton
|
|
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.material3.TextFieldColors
|
|
|
|
|
import androidx.compose.material3.TextFieldDefaults
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
@ -34,6 +36,7 @@ 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.ErrorMessageSubmitQuoteComponent
|
|
|
|
|
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
|
|
|
|
@ -44,90 +47,108 @@ import com.example.what_the_fantasy.ui.theme.gradienBox
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SubmitQuotePage(
|
|
|
|
|
index : Int,
|
|
|
|
|
navControllerProfil: (Int) -> Unit
|
|
|
|
|
index: Int,
|
|
|
|
|
navFavorite: (Int) -> Unit,
|
|
|
|
|
navAccueil: (Int) -> Unit,
|
|
|
|
|
navProfil:(Int) -> Unit,
|
|
|
|
|
navControllerQuiz: (Int) -> Unit
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxSize()
|
|
|
|
|
.background(colorBackground),
|
|
|
|
|
contentAlignment = Alignment.Center
|
|
|
|
|
){
|
|
|
|
|
Column(
|
|
|
|
|
NavBar(
|
|
|
|
|
index = index,
|
|
|
|
|
navControllerFavorite = navFavorite,
|
|
|
|
|
navControllerAccueil = navAccueil,
|
|
|
|
|
navControllerProfil = navProfil,
|
|
|
|
|
navControllerQuiz = navControllerQuiz
|
|
|
|
|
) {
|
|
|
|
|
Box(
|
|
|
|
|
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)
|
|
|
|
|
.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,navProfil, index)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun QuoteTextField(textQuoteResId : Int) : String{
|
|
|
|
|
fun quoteTextField(textQuoteResId : Int) : String{
|
|
|
|
|
val textQuote = stringResource(id = textQuoteResId)
|
|
|
|
|
var quote by remember { mutableStateOf("") } // Stocke la valeur du champ
|
|
|
|
|
var quote by remember { mutableStateOf("") }
|
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
|
|
|
|
OutlinedTextField(
|
|
|
|
|
value = quote,
|
|
|
|
|
onValueChange = { quote = it },
|
|
|
|
|
label = { Text(textQuote) },
|
|
|
|
|
label = { Text(textQuote, color = Color.White) },
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
|
|
|
|
shape = RoundedCornerShape(16.dp) // Bords arrondis
|
|
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return quote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun CharacterTextField(textCharacterResId : Int) : String{
|
|
|
|
|
fun characterTextField(textCharacterResId : Int) : String{
|
|
|
|
|
val textCharacter = stringResource(id = textCharacterResId)
|
|
|
|
|
var character by remember { mutableStateOf("") } // Stocke la valeur du champ
|
|
|
|
|
var character by remember { mutableStateOf("") }
|
|
|
|
|
|
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
|
|
|
|
OutlinedTextField(
|
|
|
|
|
value = character,
|
|
|
|
|
onValueChange = { character = it },
|
|
|
|
|
label = { Text(textCharacter) },
|
|
|
|
|
label = { Text(textCharacter, color = Color.White) },
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
|
|
|
|
shape = RoundedCornerShape(16.dp) // Bords arrondis
|
|
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return character;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SourceTextField(textSourceResId : Int) : String{
|
|
|
|
|
fun sourceTextField(textSourceResId : Int) : String{
|
|
|
|
|
val textSource = stringResource(id = textSourceResId)
|
|
|
|
|
var source by remember { mutableStateOf("") } // Stocke la valeur du champ
|
|
|
|
|
var source by remember { mutableStateOf("") }
|
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
|
|
|
|
OutlinedTextField(
|
|
|
|
|
value = source,
|
|
|
|
|
onValueChange = { source = it },
|
|
|
|
|
label = { Text(textSource) },
|
|
|
|
|
label = { Text(textSource, color = Color.White) },
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
|
|
|
|
shape = RoundedCornerShape(16.dp) // Bords arrondis
|
|
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
@ -135,19 +156,19 @@ fun SourceTextField(textSourceResId : Int) : String{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun TimeCodeTextField(textTimeCodeResId : Int) : String{
|
|
|
|
|
fun timeCodeTextField(textTimeCodeResId : Int) : String{
|
|
|
|
|
val textTimeCode = stringResource(id = textTimeCodeResId)
|
|
|
|
|
var timeCode by remember { mutableStateOf("") } // Stocke la valeur du champ
|
|
|
|
|
var timeCode by remember { mutableStateOf("") }
|
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
|
|
|
|
OutlinedTextField(
|
|
|
|
|
value = timeCode,
|
|
|
|
|
onValueChange = { timeCode = it },
|
|
|
|
|
label = { Text(textTimeCode) },
|
|
|
|
|
label = { Text(textTimeCode, color = Color.White) },
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
|
|
|
|
shape = RoundedCornerShape(16.dp) // Bords arrondis
|
|
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return timeCode;
|
|
|
|
@ -155,19 +176,19 @@ fun TimeCodeTextField(textTimeCodeResId : Int) : String{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun YearTextField(textYearResId : Int) : String{
|
|
|
|
|
fun yearTextField(textYearResId : Int) : String{
|
|
|
|
|
val textYear = stringResource(id = textYearResId)
|
|
|
|
|
var year by remember { mutableStateOf("") } // Stocke la valeur du champ
|
|
|
|
|
var year by remember { mutableStateOf("") }
|
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp, bottom = 30.dp)) {
|
|
|
|
|
OutlinedTextField(
|
|
|
|
|
value = year,
|
|
|
|
|
onValueChange = { year = it },
|
|
|
|
|
label = { Text(textYear) },
|
|
|
|
|
label = { Text(textYear, color = Color.White) },
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
|
|
|
|
shape = RoundedCornerShape(16.dp) // Bords arrondis
|
|
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return year;
|
|
|
|
@ -175,26 +196,41 @@ fun YearTextField(textYearResId : Int) : String{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SubmitQuoteButton( quote : String, character : String, source: String, timeCode: String, year: String , titleResId : Int, size : Int, colorButton : Color, colorText : Color){
|
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
onClick = { showError = !validSubmitQuote(quote, character, source, timeCode, year) },
|
|
|
|
|
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth(),
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
) {
|
|
|
|
|
Text(title, fontSize = size.sp, color = colorText)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(showError){
|
|
|
|
|
ErrorMessageProfileComponent(R.string.ErrorLogin)
|
|
|
|
|
if (showError) {
|
|
|
|
|
ErrorMessageSubmitQuoteComponent(R.string.ErrorSubmitQuote)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun validSubmitQuote(): Boolean{
|
|
|
|
|
return true
|
|
|
|
|
fun validSubmitQuote(quote : String, character : String, source: String, timeCode: String, year: String): Boolean{
|
|
|
|
|
val isNotBlank = quote.isNotBlank() &&
|
|
|
|
|
character.isNotBlank() &&
|
|
|
|
|
source.isNotBlank() &&
|
|
|
|
|
timeCode.isNotBlank() &&
|
|
|
|
|
year.isNotBlank() &&
|
|
|
|
|
year.all { it.isDigit() }
|
|
|
|
|
return isNotBlank
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|