parent
0add75488b
commit
5c2a195b95
@ -1,8 +1,212 @@
|
|||||||
package com.example.what_the_fantasy.ui.screens
|
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.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.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
|
@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)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in new issue