|
|
@ -14,8 +14,10 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
|
|
|
import androidx.compose.material3.TextField
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
@ -43,7 +45,7 @@ fun SubmitQuotePage(
|
|
|
|
navFavorite: (Int) -> Unit,
|
|
|
|
navFavorite: (Int) -> Unit,
|
|
|
|
navAccueil: (Int) -> Unit,
|
|
|
|
navAccueil: (Int) -> Unit,
|
|
|
|
navProfil:(Int) -> Unit,
|
|
|
|
navProfil:(Int) -> Unit,
|
|
|
|
navControllerQuiz: (Int) -> Unit,
|
|
|
|
navQuiz: (Int) -> Unit,
|
|
|
|
navRecap: (String, String, String) -> Unit
|
|
|
|
navRecap: (String, String, String) -> Unit
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
NavBar(
|
|
|
|
NavBar(
|
|
|
@ -51,13 +53,13 @@ fun SubmitQuotePage(
|
|
|
|
navControllerFavorite = navFavorite,
|
|
|
|
navControllerFavorite = navFavorite,
|
|
|
|
navControllerAccueil = navAccueil,
|
|
|
|
navControllerAccueil = navAccueil,
|
|
|
|
navControllerProfil = navProfil,
|
|
|
|
navControllerProfil = navProfil,
|
|
|
|
navControllerQuiz = navControllerQuiz
|
|
|
|
navControllerQuiz = navQuiz
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Box(
|
|
|
|
Box(
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxSize()
|
|
|
|
.fillMaxSize()
|
|
|
|
.background(colorBackground)
|
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
|
.verticalScroll(rememberScrollState()),
|
|
|
|
.background(MaterialTheme.colorScheme.background,),
|
|
|
|
contentAlignment = Alignment.Center
|
|
|
|
contentAlignment = Alignment.Center
|
|
|
|
){
|
|
|
|
){
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
@ -65,11 +67,11 @@ fun SubmitQuotePage(
|
|
|
|
.fillMaxWidth(0.9f)
|
|
|
|
.fillMaxWidth(0.9f)
|
|
|
|
.padding(20.dp)
|
|
|
|
.padding(20.dp)
|
|
|
|
.clip(RoundedCornerShape(16.dp))
|
|
|
|
.clip(RoundedCornerShape(16.dp))
|
|
|
|
.background(gradienBox)
|
|
|
|
.background(MaterialTheme.colorScheme.onPrimary)
|
|
|
|
.padding(20.dp),
|
|
|
|
.padding(20.dp),
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
TitlePageComponent(R.string.titleSubmitQuote, Color.White)
|
|
|
|
TitlePageComponent(R.string.titleSubmitQuote, MaterialTheme.colorScheme.primary)
|
|
|
|
SpaceHeightComponent(20)
|
|
|
|
SpaceHeightComponent(20)
|
|
|
|
SubmitQuoteButton(
|
|
|
|
SubmitQuoteButton(
|
|
|
|
quoteTextField(R.string.quote),
|
|
|
|
quoteTextField(R.string.quote),
|
|
|
@ -79,12 +81,13 @@ fun SubmitQuotePage(
|
|
|
|
yearTextField(R.string.year),
|
|
|
|
yearTextField(R.string.year),
|
|
|
|
R.string.titleButtonSubmit,
|
|
|
|
R.string.titleButtonSubmit,
|
|
|
|
18,
|
|
|
|
18,
|
|
|
|
Color.White,
|
|
|
|
MaterialTheme.colorScheme.background,
|
|
|
|
Color.Black,
|
|
|
|
MaterialTheme.colorScheme.primary,
|
|
|
|
navRecap
|
|
|
|
navRecap
|
|
|
|
)
|
|
|
|
)
|
|
|
|
SpaceHeightComponent(20)
|
|
|
|
SpaceHeightComponent(20)
|
|
|
|
BackButton(R.string.titleButtonBack, 12, Color.White,navProfil, index)
|
|
|
|
// Bouton profile deja disponible dans la navbar
|
|
|
|
|
|
|
|
//BackButton(R.string.titleButtonBack, 12, Color.White,navProfil, index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -95,11 +98,12 @@ fun SubmitQuotePage(
|
|
|
|
fun quoteTextField(textQuoteResId : Int) : String{
|
|
|
|
fun quoteTextField(textQuoteResId : Int) : String{
|
|
|
|
val textQuote = stringResource(id = textQuoteResId)
|
|
|
|
val textQuote = stringResource(id = textQuoteResId)
|
|
|
|
var quote by remember { mutableStateOf("") }
|
|
|
|
var quote by remember { mutableStateOf("") }
|
|
|
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
|
|
|
Column(modifier = Modifier
|
|
|
|
|
|
|
|
.padding(top = 16.dp)) {
|
|
|
|
OutlinedTextField(
|
|
|
|
OutlinedTextField(
|
|
|
|
value = quote,
|
|
|
|
value = quote,
|
|
|
|
onValueChange = { quote = it },
|
|
|
|
onValueChange = { quote = it },
|
|
|
|
label = { Text(textQuote, color = Color.White) },
|
|
|
|
label = { Text(textQuote, color = MaterialTheme.colorScheme.primary) },
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.fillMaxWidth()
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
.padding(top = 8.dp),
|
|
|
@ -119,7 +123,7 @@ fun characterTextField(textCharacterResId : Int) : String{
|
|
|
|
OutlinedTextField(
|
|
|
|
OutlinedTextField(
|
|
|
|
value = character,
|
|
|
|
value = character,
|
|
|
|
onValueChange = { character = it },
|
|
|
|
onValueChange = { character = it },
|
|
|
|
label = { Text(textCharacter, color = Color.White) },
|
|
|
|
label = { Text(textCharacter, color = MaterialTheme.colorScheme.primary) },
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.fillMaxWidth()
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
.padding(top = 8.dp),
|
|
|
@ -138,7 +142,7 @@ fun sourceTextField(textSourceResId : Int) : String{
|
|
|
|
OutlinedTextField(
|
|
|
|
OutlinedTextField(
|
|
|
|
value = source,
|
|
|
|
value = source,
|
|
|
|
onValueChange = { source = it },
|
|
|
|
onValueChange = { source = it },
|
|
|
|
label = { Text(textSource, color = Color.White) },
|
|
|
|
label = { Text(textSource, color = MaterialTheme.colorScheme.primary) },
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.fillMaxWidth()
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
.padding(top = 8.dp),
|
|
|
@ -158,7 +162,7 @@ fun timeCodeTextField(textTimeCodeResId : Int) : String{
|
|
|
|
OutlinedTextField(
|
|
|
|
OutlinedTextField(
|
|
|
|
value = timeCode,
|
|
|
|
value = timeCode,
|
|
|
|
onValueChange = { timeCode = it },
|
|
|
|
onValueChange = { timeCode = it },
|
|
|
|
label = { Text(textTimeCode, color = Color.White) },
|
|
|
|
label = { Text(textTimeCode, color = MaterialTheme.colorScheme.primary) },
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.fillMaxWidth()
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
.padding(top = 8.dp),
|
|
|
@ -178,7 +182,7 @@ fun yearTextField(textYearResId : Int) : String{
|
|
|
|
OutlinedTextField(
|
|
|
|
OutlinedTextField(
|
|
|
|
value = year,
|
|
|
|
value = year,
|
|
|
|
onValueChange = { year = it },
|
|
|
|
onValueChange = { year = it },
|
|
|
|
label = { Text(textYear, color = Color.White) },
|
|
|
|
label = { Text(textYear, color = MaterialTheme.colorScheme.primary) },
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.fillMaxWidth()
|
|
|
|
.padding(top = 8.dp),
|
|
|
|
.padding(top = 8.dp),
|
|
|
@ -238,11 +242,10 @@ fun validSubmitQuote(quote : String, character : String, source: String, timeCod
|
|
|
|
val timeCodeRegex = """^\d{1}:\d{2}:\d{2}$""".toRegex()
|
|
|
|
val timeCodeRegex = """^\d{1}:\d{2}:\d{2}$""".toRegex()
|
|
|
|
val movieTitleRegex = """^[A-Za-z0-9\s\-\(\):]+$""".toRegex()
|
|
|
|
val movieTitleRegex = """^[A-Za-z0-9\s\-\(\):]+$""".toRegex()
|
|
|
|
val characterRegex = """^[A-Za-zÀ-ÿ\s\-']+$""".toRegex()
|
|
|
|
val characterRegex = """^[A-Za-zÀ-ÿ\s\-']+$""".toRegex()
|
|
|
|
val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val isNotBlank = quote.isNotBlank() && quote.matches(quoteRegex) && !quote.matches(invalidRegex) && quote.length in 3..100 &&
|
|
|
|
val isNotBlank = quote.isNotBlank() && quote.matches(quoteRegex) && quote.length in 3..100 &&
|
|
|
|
character.isNotBlank() && character.matches(characterRegex) && character.length in 3..50 && !character.matches(invalidRegex) &&
|
|
|
|
character.isNotBlank() && character.matches(characterRegex) && character.length in 3..50 &&
|
|
|
|
source.isNotBlank() && source.matches(movieTitleRegex) && source.length in 3..50 && !source.matches(invalidRegex) &&
|
|
|
|
source.isNotBlank() && source.matches(movieTitleRegex) && source.length in 3..50 &&
|
|
|
|
timeCode.isNotBlank() && timeCode.matches(timeCodeRegex) &&
|
|
|
|
timeCode.isNotBlank() && timeCode.matches(timeCodeRegex) &&
|
|
|
|
year.isNotBlank() && year.all { it.isDigit() } && year.length == 4 && year.toInt() in 1900..2025
|
|
|
|
year.isNotBlank() && year.all { it.isDigit() } && year.length == 4 && year.toInt() in 1900..2025
|
|
|
|
return isNotBlank
|
|
|
|
return isNotBlank
|
|
|
|