fin style + ajout partage

pull/38/head
kevin.modejar 2 months ago
parent ccbef9f16a
commit b5e463ebfb

@ -25,7 +25,7 @@ class MainActivity : ComponentActivity() {
What_The_FantasyTheme { What_The_FantasyTheme {
//AppNavigator() //AppNavigator()
//QuizPage() //QuizPage()
QuotePage(QuoteStub.quote1) QuotePage(1)
} }
} }
} }

@ -9,6 +9,7 @@ import com.example.what_the_fantasy.ui.screens.AccueilPage
import com.example.what_the_fantasy.ui.screens.FavoritePage import com.example.what_the_fantasy.ui.screens.FavoritePage
import com.example.what_the_fantasy.ui.screens.LoginPage import com.example.what_the_fantasy.ui.screens.LoginPage
import com.example.what_the_fantasy.ui.screens.ProfilPage import com.example.what_the_fantasy.ui.screens.ProfilPage
import com.example.what_the_fantasy.ui.screens.QuizApp
import com.example.what_the_fantasy.ui.screens.QuizPage import com.example.what_the_fantasy.ui.screens.QuizPage
import com.example.what_the_fantasy.ui.screens.QuotePage import com.example.what_the_fantasy.ui.screens.QuotePage
import com.example.what_the_fantasy.ui.screens.SearchPage import com.example.what_the_fantasy.ui.screens.SearchPage
@ -52,7 +53,11 @@ fun AppNavigator() {
ProfilPage(index = userIndex, navController = navController) ProfilPage(index = userIndex, navController = navController)
} }
composable(Destination.Quiz.route) { QuizPage(navController) } composable(Destination.Quiz.route) { QuizPage(navController) }
composable(Destination.Quote.route) { } composable(Destination.Quote.route) { backStackEntry ->
// Récupère l'index passé dans la route
val index = backStackEntry.arguments?.getString("userIndex")?.toInt() ?: -1
QuotePage(quoteId = index)//, navController = navController)
}
composable(Destination.Search.route) { SearchPage() } composable(Destination.Search.route) { SearchPage() }
composable(Destination.SignUp.route) { SignUpPage(navController) } composable(Destination.SignUp.route) { SignUpPage(navController) }
composable(Destination.SubmitQuote.route) { SubmitQuotePage() } composable(Destination.SubmitQuote.route) { SubmitQuotePage() }

@ -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,45 +27,78 @@ 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
{ ) {
Row(modifier = Modifier.padding(15.dp)){ Column(modifier = Modifier
ImageQuote( .padding(15.dp)
imageUrl = quote.imgUrl .drawBehind {
) drawRoundRect(
QuoteText( gradienBox,
text = '"'+quote.content+'"' cornerRadius = CornerRadius(15.dp.toPx()),
)
}
) {
Row(modifier = Modifier.padding(15.dp)) {
ImageQuote(
imageUrl = quote.imgUrl
)
Column {
) FunctionalIcon(
} // --/!\-- a modifier --/!\--
Column (modifier = Modifier.padding(15.dp)) { // service -> isFavorite(id)
InfoQuoteText( true,
nameId = R.string.source, id = quoteId,
text = quote.source context = context
) )
InfoQuoteText( QuoteText(
nameId = R.string.charac, text = '"' + quote.content + '"'
text = quote.character )
) }
Text( }
text = "like : " + quote.likes.toString() Column(modifier = Modifier.padding(15.dp)) {
) InfoQuoteText(
nameId = R.string.source,
text = quote.source
)
InfoQuoteText(
nameId = R.string.charac,
text = quote.character
)
Row(
modifier = Modifier
.padding(top = 10.dp)
.align(alignment = Alignment.End)
) {
LikeInfo(
likes = quote.likes
)
}
}
} }
} }
} }
@ -62,7 +108,9 @@ 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,
)
}

@ -11,6 +11,9 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4) val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71) val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260) val Pink40 = Color(0xFF7D5260)
val likeIcon = Color.Red
val whiteBackcgroundText = Color.Black
val iconText = Color.White
val gradienBox = Brush.linearGradient( val gradienBox = Brush.linearGradient(
colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)), // Violet clair → Violet foncé colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)), // Violet clair → Violet foncé
start = Offset(0f, 1000f), // Départ en bas à gauche start = Offset(0f, 1000f), // Départ en bas à gauche

@ -8,6 +8,11 @@
//Page Quote //Page Quote
<string name="charac">Personnage</string> <string name="charac">Personnage</string>
<string name="source">Source</string> <string name="source">Source</string>
<string name="share">Partager</string>
<string name="comment">Commentaire</string>
<string name="favorite">Favoris</string>
<string name="like">Likes</string>
<string name="profilePict">Image de profil</string>
//Page Login //Page Login
<string name="titleLogin">Connexion au compte</string> <string name="titleLogin">Connexion au compte</string>

@ -7,6 +7,11 @@
//Page Quote //Page Quote
<string name="charac">Character</string> <string name="charac">Character</string>
<string name="source">Source</string> <string name="source">Source</string>
<string name="share">Share</string>
<string name="comment">comment</string>
<string name="favorite">favorite</string>
<string name="like">likes</string>
<string name="profilePict">Profile picture</string>
//Page Login //Page Login
<string name="titleLogin">Account login</string> <string name="titleLogin">Account login</string>

Loading…
Cancel
Save