commit
716491d31f
@ -0,0 +1,169 @@
|
|||||||
|
package com.example.what_the_fantasy.ui.screens
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Favorite
|
||||||
|
import androidx.compose.material.icons.filled.FavoriteBorder
|
||||||
|
import androidx.compose.material.icons.filled.MailOutline
|
||||||
|
import androidx.compose.material.icons.filled.Share
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.draw.drawBehind
|
||||||
|
import androidx.compose.ui.geometry.CornerRadius
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.example.what_the_fantasy.R
|
||||||
|
import coil.compose.AsyncImage
|
||||||
|
import com.example.what_the_fantasy.ui.components.NavBar
|
||||||
|
import com.example.what_the_fantasy.ui.theme.gradienBox
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import com.example.what_the_fantasy.data.model.Character
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RecapSubmitPage(
|
||||||
|
index: Int,
|
||||||
|
navFavorite: (Int) -> Unit,
|
||||||
|
navAccueil: (Int) -> Unit,
|
||||||
|
navProfil:(Int) -> Unit,
|
||||||
|
quoteContent : String,
|
||||||
|
character: String,
|
||||||
|
source: String
|
||||||
|
) {
|
||||||
|
NavBar(onQuiz = true,
|
||||||
|
index = index,
|
||||||
|
navControllerFavorite = navFavorite,
|
||||||
|
navControllerAccueil = navAccueil,
|
||||||
|
navControllerProfil = navProfil,
|
||||||
|
navControllerQuiz = { }
|
||||||
|
) {
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize().background(Color(0xFF100C1B))
|
||||||
|
) {
|
||||||
|
// Contenu princiapl
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(0.9f)
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(20.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "▶ Recap de la citation ◀",
|
||||||
|
color = Color.White,
|
||||||
|
style = TextStyle(
|
||||||
|
fontSize = 25.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(20.dp))
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(brush = gradient, shape = RoundedCornerShape(20.dp))
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(vertical = 30.dp)
|
||||||
|
.verticalScroll(rememberScrollState()),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.padding(15.dp)
|
||||||
|
.drawBehind {
|
||||||
|
drawRoundRect(
|
||||||
|
gradienBox,
|
||||||
|
cornerRadius = CornerRadius(15.dp.toPx()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Row(modifier = Modifier.padding(15.dp)) {
|
||||||
|
ImageQuote(
|
||||||
|
imageUrl = "https://img.freepik.com/vecteurs-libre/personnage-guerrier-fantaisie_1045-185.jpg?size=338&ext=jpg"
|
||||||
|
)
|
||||||
|
Column {
|
||||||
|
QuoteText(
|
||||||
|
text = '"' + quoteContent + '"'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.padding(15.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
InfoQuoteText(
|
||||||
|
nameId = R.string.source,
|
||||||
|
text = source
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Character : $character"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun QuoteText(text: String ){
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
modifier = Modifier.padding(start = 10.dp, top = 15.dp),
|
||||||
|
fontWeight = FontWeight(1000),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
color = Color.White
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ImageQuote(imageUrl : String){
|
||||||
|
AsyncImage(
|
||||||
|
model = imageUrl,
|
||||||
|
contentDescription = "exemple",
|
||||||
|
modifier = Modifier
|
||||||
|
.size(150.dp)
|
||||||
|
.clip(RoundedCornerShape(15.dp))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun InfoQuoteText(nameId : Int, text : String){
|
||||||
|
Column(modifier = Modifier.padding(bottom = 20.dp)){
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight(400),
|
||||||
|
modifier = Modifier
|
||||||
|
.drawBehind {
|
||||||
|
drawRoundRect(
|
||||||
|
Color(255,255,255),
|
||||||
|
cornerRadius = CornerRadius(15.dp.toPx())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.padding(5.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,253 @@
|
|||||||
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.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.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.example.what_the_fantasy.R
|
||||||
|
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.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.theme.colorBackground
|
||||||
|
import com.example.what_the_fantasy.ui.theme.gradienBox
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SubmitQuotePage() {
|
fun SubmitQuotePage(
|
||||||
|
index: Int,
|
||||||
|
navFavorite: (Int) -> Unit,
|
||||||
|
navAccueil: (Int) -> Unit,
|
||||||
|
navProfil:(Int) -> Unit,
|
||||||
|
navControllerQuiz: (Int) -> Unit,
|
||||||
|
navRecap: (String, String, String) -> Unit
|
||||||
|
) {
|
||||||
|
NavBar(
|
||||||
|
index = index,
|
||||||
|
navControllerFavorite = navFavorite,
|
||||||
|
navControllerAccueil = navAccueil,
|
||||||
|
navControllerProfil = navProfil,
|
||||||
|
navControllerQuiz = navControllerQuiz
|
||||||
|
) {
|
||||||
|
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,
|
||||||
|
navRecap
|
||||||
|
)
|
||||||
|
SpaceHeightComponent(20)
|
||||||
|
BackButton(R.string.titleButtonBack, 12, Color.White,navProfil, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun quoteTextField(textQuoteResId : Int) : String{
|
||||||
|
val textQuote = stringResource(id = textQuoteResId)
|
||||||
|
var quote by remember { mutableStateOf("") }
|
||||||
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = quote,
|
||||||
|
onValueChange = { quote = it },
|
||||||
|
label = { Text(textQuote, color = Color.White) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||||
|
shape = RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return quote;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun characterTextField(textCharacterResId : Int) : String{
|
||||||
|
val textCharacter = stringResource(id = textCharacterResId)
|
||||||
|
var character by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = character,
|
||||||
|
onValueChange = { character = it },
|
||||||
|
label = { Text(textCharacter, color = Color.White) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||||
|
shape = RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun sourceTextField(textSourceResId : Int) : String{
|
||||||
|
val textSource = stringResource(id = textSourceResId)
|
||||||
|
var source by remember { mutableStateOf("") }
|
||||||
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = source,
|
||||||
|
onValueChange = { source = it },
|
||||||
|
label = { Text(textSource, color = Color.White) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||||
|
shape = RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun timeCodeTextField(textTimeCodeResId : Int) : String{
|
||||||
|
val textTimeCode = stringResource(id = textTimeCodeResId)
|
||||||
|
var timeCode by remember { mutableStateOf("") }
|
||||||
|
Column(modifier = Modifier.padding(top = 16.dp)) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = timeCode,
|
||||||
|
onValueChange = { timeCode = it },
|
||||||
|
label = { Text(textTimeCode, color = Color.White) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||||
|
shape = RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return timeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun yearTextField(textYearResId : Int) : String{
|
||||||
|
val textYear = stringResource(id = textYearResId)
|
||||||
|
var year by remember { mutableStateOf("") }
|
||||||
|
Column(modifier = Modifier.padding(top = 16.dp, bottom = 30.dp)) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = year,
|
||||||
|
onValueChange = { year = it },
|
||||||
|
label = { Text(textYear, color = Color.White) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||||
|
shape = RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SubmitQuoteButton(
|
||||||
|
quote: String,
|
||||||
|
character: String,
|
||||||
|
source: String,
|
||||||
|
timeCode: String,
|
||||||
|
year: String,
|
||||||
|
titleResId: Int,
|
||||||
|
size: Int,
|
||||||
|
colorButton: Color,
|
||||||
|
colorText: Color,
|
||||||
|
navRecap : (String, String, String) -> Unit
|
||||||
|
) {
|
||||||
|
val title = stringResource(id = titleResId)
|
||||||
|
var showError by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = { showError = !goToRecap(quote, character, source, timeCode, year, navRecap) },
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
) {
|
||||||
|
Text(title, fontSize = size.sp, color = colorText)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showError) {
|
||||||
|
ErrorMessageSubmitQuoteComponent(R.string.ErrorSubmitQuote)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun goToRecap(quote: String,
|
||||||
|
character: String,
|
||||||
|
source: String,
|
||||||
|
timeCode: String,
|
||||||
|
year: String,
|
||||||
|
navRecap : (String, String, String) -> Unit): Boolean {
|
||||||
|
if (validSubmitQuote(quote, character, source, timeCode, year)) {
|
||||||
|
navRecap(quote, character, source)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
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