|
|
@ -1,11 +1,24 @@
|
|
|
|
package com.example.what_the_fantasy.ui.screens
|
|
|
|
package com.example.what_the_fantasy.ui.screens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
|
|
|
import android.net.Uri
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
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.padding
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
|
|
|
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.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
@ -14,33 +27,59 @@ import androidx.compose.ui.draw.clip
|
|
|
|
import androidx.compose.ui.draw.drawBehind
|
|
|
|
import androidx.compose.ui.draw.drawBehind
|
|
|
|
import androidx.compose.ui.geometry.CornerRadius
|
|
|
|
import androidx.compose.ui.geometry.CornerRadius
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.unit.TextUnit
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
import com.example.what_the_fantasy.data.model.Quote
|
|
|
|
import com.example.what_the_fantasy.data.model.Quote
|
|
|
|
import coil.compose.AsyncImage
|
|
|
|
import coil.compose.AsyncImage
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.data.local.QuoteStub
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.colorBackground
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.gradienBox
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.iconText
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.likeIcon
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.whiteBackcgroundText
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun QuotePage(quote : Quote) {
|
|
|
|
fun QuotePage(quoteId : Int) {
|
|
|
|
// Column (modifier = Modifier.padding(15.dp).drawBehind {
|
|
|
|
var quote : Quote= QuoteStub.quote1 // service -> GetQuote(id)
|
|
|
|
// drawRoundRect(
|
|
|
|
val context = LocalContext.current
|
|
|
|
// Color(70,190,115),
|
|
|
|
Box(
|
|
|
|
// cornerRadius = CornerRadius(15.dp.toPx()),
|
|
|
|
modifier = Modifier
|
|
|
|
// )
|
|
|
|
.fillMaxSize()
|
|
|
|
// }.size(500.dp, 600.dp))
|
|
|
|
.background(colorBackground),
|
|
|
|
Box
|
|
|
|
contentAlignment = Alignment.Center
|
|
|
|
{
|
|
|
|
) {
|
|
|
|
|
|
|
|
Column(modifier = Modifier
|
|
|
|
|
|
|
|
.padding(15.dp)
|
|
|
|
|
|
|
|
.drawBehind {
|
|
|
|
|
|
|
|
drawRoundRect(
|
|
|
|
|
|
|
|
gradienBox,
|
|
|
|
|
|
|
|
cornerRadius = CornerRadius(15.dp.toPx()),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
) {
|
|
|
|
Row(modifier = Modifier.padding(15.dp)) {
|
|
|
|
Row(modifier = Modifier.padding(15.dp)) {
|
|
|
|
ImageQuote(
|
|
|
|
ImageQuote(
|
|
|
|
imageUrl = quote.imgUrl
|
|
|
|
imageUrl = quote.imgUrl
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FunctionalIcon(
|
|
|
|
|
|
|
|
// --/!\-- a modifier --/!\--
|
|
|
|
|
|
|
|
// service -> isFavorite(id)
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
id = quoteId,
|
|
|
|
|
|
|
|
context = context
|
|
|
|
|
|
|
|
)
|
|
|
|
QuoteText(
|
|
|
|
QuoteText(
|
|
|
|
text = '"' + quote.content + '"'
|
|
|
|
text = '"' + quote.content + '"'
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Column(modifier = Modifier.padding(15.dp)) {
|
|
|
|
Column(modifier = Modifier.padding(15.dp)) {
|
|
|
|
InfoQuoteText(
|
|
|
|
InfoQuoteText(
|
|
|
|
nameId = R.string.source,
|
|
|
|
nameId = R.string.source,
|
|
|
@ -50,19 +89,28 @@ fun QuotePage(quote : Quote) {
|
|
|
|
nameId = R.string.charac,
|
|
|
|
nameId = R.string.charac,
|
|
|
|
text = quote.character
|
|
|
|
text = quote.character
|
|
|
|
)
|
|
|
|
)
|
|
|
|
Text(
|
|
|
|
Row(
|
|
|
|
text = "like : " + quote.likes.toString()
|
|
|
|
modifier = Modifier
|
|
|
|
|
|
|
|
.padding(top = 10.dp)
|
|
|
|
|
|
|
|
.align(alignment = Alignment.End)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
LikeInfo(
|
|
|
|
|
|
|
|
likes = quote.likes
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun QuoteText(text: String ){
|
|
|
|
fun QuoteText(text: String ){
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = text,
|
|
|
|
text = text,
|
|
|
|
modifier = Modifier.padding(start = 10.dp, top = 15.dp),
|
|
|
|
modifier = Modifier.padding(start = 10.dp, top = 15.dp),
|
|
|
|
fontWeight = FontWeight(1000)
|
|
|
|
fontWeight = FontWeight(1000),
|
|
|
|
|
|
|
|
fontSize = 20.sp,
|
|
|
|
|
|
|
|
color = iconText
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -70,23 +118,96 @@ fun QuoteText(text: String ){
|
|
|
|
fun ImageQuote(imageUrl : String){
|
|
|
|
fun ImageQuote(imageUrl : String){
|
|
|
|
AsyncImage(
|
|
|
|
AsyncImage(
|
|
|
|
model = imageUrl,
|
|
|
|
model = imageUrl,
|
|
|
|
contentDescription = "Photo de profil",
|
|
|
|
contentDescription = stringResource(R.string.profilePict),
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.size(150.dp)
|
|
|
|
.size(150.dp)
|
|
|
|
.clip(RoundedCornerShape(15.dp))
|
|
|
|
.clip(RoundedCornerShape(15.dp))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){
|
|
|
|
|
|
|
|
Row(modifier = Modifier
|
|
|
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
onClick = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val sendIntent = Intent().apply {
|
|
|
|
|
|
|
|
action = Intent.ACTION_SEND
|
|
|
|
|
|
|
|
// lien a changer quand le site sra deployer
|
|
|
|
|
|
|
|
putExtra(Intent.EXTRA_TEXT, "http://wfWebsite/quote/" + id.toString() )
|
|
|
|
|
|
|
|
type = "text/plain"
|
|
|
|
|
|
|
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // Ajout pour compatibilité
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val shareIntent = Intent.createChooser(sendIntent, null)
|
|
|
|
|
|
|
|
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // Ajout aussi ici
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.startActivity(shareIntent)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
modifier = Modifier.padding(start = 15.dp)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.Default.Share,
|
|
|
|
|
|
|
|
contentDescription = stringResource(R.string.share),
|
|
|
|
|
|
|
|
tint = iconText,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
onClick = { }, //Go to comment
|
|
|
|
|
|
|
|
modifier = Modifier.padding(start = 20.dp)
|
|
|
|
|
|
|
|
){
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.Default.MailOutline,
|
|
|
|
|
|
|
|
contentDescription = stringResource(R.string.comment),
|
|
|
|
|
|
|
|
tint = iconText,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isFavorite){
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
onClick = { }, //Go to comment
|
|
|
|
|
|
|
|
modifier = Modifier.padding(start = 20.dp)
|
|
|
|
|
|
|
|
){
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.Default.Favorite,
|
|
|
|
|
|
|
|
contentDescription = stringResource(R.string.favorite),
|
|
|
|
|
|
|
|
tint = likeIcon,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
onClick = { }, //Go to comment
|
|
|
|
|
|
|
|
modifier = Modifier.padding(start = 50.dp)
|
|
|
|
|
|
|
|
){
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.Default.FavoriteBorder,
|
|
|
|
|
|
|
|
contentDescription = stringResource(R.string.favorite),
|
|
|
|
|
|
|
|
tint = iconText
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun InfoQuoteText(nameId : Int, text : String){
|
|
|
|
fun InfoQuoteText(nameId : Int, text : String){
|
|
|
|
Column(modifier = Modifier.padding(bottom = 40.dp)){
|
|
|
|
Column(modifier = Modifier.padding(bottom = 20.dp)){
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = stringResource(id = nameId),
|
|
|
|
text = stringResource(id = nameId),
|
|
|
|
fontWeight = FontWeight(500)
|
|
|
|
fontSize = 18.sp,
|
|
|
|
|
|
|
|
fontWeight = FontWeight(500),
|
|
|
|
|
|
|
|
color = iconText
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = text,
|
|
|
|
text = text,
|
|
|
|
|
|
|
|
color = whiteBackcgroundText,
|
|
|
|
|
|
|
|
fontSize = 16.sp,
|
|
|
|
|
|
|
|
fontWeight = FontWeight(400),
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.drawBehind {
|
|
|
|
.drawBehind {
|
|
|
|
drawRoundRect(
|
|
|
|
drawRoundRect(
|
|
|
@ -98,3 +219,16 @@ fun InfoQuoteText(nameId : Int, text : String){
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
fun LikeInfo(likes : Int){
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
text = likes.toString(),
|
|
|
|
|
|
|
|
color = iconText
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.Default.Favorite,
|
|
|
|
|
|
|
|
contentDescription = stringResource(R.string.favorite),
|
|
|
|
|
|
|
|
tint = iconText,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|