|
|
|
@ -1,17 +1,15 @@
|
|
|
|
|
package com.example.veraxapplication.ui.article
|
|
|
|
|
|
|
|
|
|
import VideoPlayer
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
|
|
import androidx.compose.foundation.Image
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.border
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
|
import androidx.compose.foundation.layout.wrapContentWidth
|
|
|
|
|
import androidx.compose.foundation.rememberScrollState
|
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
|
@ -31,46 +29,46 @@ import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import coil.compose.rememberImagePainter
|
|
|
|
|
import com.example.veraxapplication.modele.articles.Article
|
|
|
|
|
import com.example.veraxapplication.modele.articles.contenus.Contenu
|
|
|
|
|
import com.example.veraxapplication.modele.articles.contenus.ContenuMedia
|
|
|
|
|
import com.example.veraxapplication.modele.articles.contenus.ContenuParagraphe
|
|
|
|
|
import com.example.veraxapplication.ui.theme.Salmon
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun AffichageLesArticles(articles : List<Article>){
|
|
|
|
|
fun AffichageLesArticles(articles : List<Article>, goToArticle: (Article) -> Unit){
|
|
|
|
|
Column(modifier = Modifier.verticalScroll(rememberScrollState())){
|
|
|
|
|
for(article in articles){
|
|
|
|
|
Box (Modifier.clickable { /*faut je regarde la doc*/ }){
|
|
|
|
|
AffichageUnArticleInfo(e = article)
|
|
|
|
|
Box {
|
|
|
|
|
AffichageUnArticleInfo(e = article, goToArticle)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun AffichageUnArticleInfo(e : Article){
|
|
|
|
|
fun AffichageUnArticleInfo(e : Article, goToArticle: (Article) -> Unit){
|
|
|
|
|
Column(modifier = Modifier
|
|
|
|
|
.padding(7.dp)
|
|
|
|
|
.border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(10.dp))
|
|
|
|
|
.padding(5.dp)) {
|
|
|
|
|
/*DisplayTitle(title = e.Title)
|
|
|
|
|
DisplayHeader(author = e.Author, description = e.Description, lectureTime = e.LectureTime)
|
|
|
|
|
DisplayImage(image = e.Image)
|
|
|
|
|
DisplayContentArticle(content = e.Content)*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Text(text = e.titre, fontFamily = FontFamily.Serif, fontSize = 30.sp)
|
|
|
|
|
|
|
|
|
|
DisplayHeader(author = e.auteur, description = e.description , lectureTime = e.temps)
|
|
|
|
|
|
|
|
|
|
var imageURl = e.note
|
|
|
|
|
Log.d("ImageLoad", "URL de l'image reçue de l'API : $imageURl")
|
|
|
|
|
|
|
|
|
|
Box(modifier = Modifier
|
|
|
|
|
.padding(15.dp)
|
|
|
|
|
.border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(10.dp))
|
|
|
|
|
.clip(RoundedCornerShape(10.dp))
|
|
|
|
|
.background(Salmon)
|
|
|
|
|
) {
|
|
|
|
|
Column (modifier = Modifier.padding(15.dp)) {
|
|
|
|
|
Text(text = "Auteur : "+e.auteur, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Description : "+e.description, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Temps de lecture : "+e.temps+" minutes", fontSize = 17.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Log.d("ImageLoad", e.toString())
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(
|
|
|
|
|
data = imageURl
|
|
|
|
|
data = e.imagePrincipale
|
|
|
|
|
),
|
|
|
|
|
contentScale = ContentScale.Crop,
|
|
|
|
|
contentDescription = null,
|
|
|
|
@ -80,7 +78,8 @@ fun AffichageUnArticleInfo(e : Article){
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Button(onClick = { /*TODO*/ },
|
|
|
|
|
|
|
|
|
|
Button(onClick = { goToArticle(e)},
|
|
|
|
|
colors = ButtonDefaults.buttonColors(
|
|
|
|
|
containerColor = Salmon,
|
|
|
|
|
contentColor = Color.Black
|
|
|
|
@ -95,43 +94,19 @@ fun AffichageUnArticleInfo(e : Article){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun AfficherArticle(e : Article){
|
|
|
|
|
Column(modifier = Modifier
|
|
|
|
|
fun AfficherArticle(e : Article) {
|
|
|
|
|
Column(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
|
|
.padding(7.dp)
|
|
|
|
|
.padding(5.dp)) {
|
|
|
|
|
.padding(5.dp)
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
Text(text = e.titre, fontFamily = FontFamily.Serif, fontSize = 30.sp)
|
|
|
|
|
|
|
|
|
|
// Affichage des informations de l'article
|
|
|
|
|
DisplayHeader(author = e.auteur, description = e.description, lectureTime = e.temps)
|
|
|
|
|
|
|
|
|
|
Text(text = "coucou")
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(data = e.imagePrincipale),
|
|
|
|
|
contentScale = ContentScale.FillHeight,
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(350.dp)
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.wrapContentWidth(Alignment.CenterHorizontally)
|
|
|
|
|
)*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Affichage contenus
|
|
|
|
|
//DisplayContenu(e.lContenus)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayHeader(author: String, description: String, lectureTime: String) {
|
|
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.padding(15.dp)
|
|
|
|
@ -140,42 +115,63 @@ fun DisplayHeader(author: String, description: String, lectureTime: String) {
|
|
|
|
|
.background(Salmon)
|
|
|
|
|
) {
|
|
|
|
|
Column(modifier = Modifier.padding(15.dp)) {
|
|
|
|
|
Text(text = "Auteur : "+ author, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Description : "+ description, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Temps de lecture : " + lectureTime + " minutes", fontSize = 17.sp)
|
|
|
|
|
Text(text = "Auteur : " + e.auteur, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Description : " + e.description, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Temps de lecture : " + e.temps + " minutes", fontSize = 17.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayContenu(contenus: List<Contenu>) {
|
|
|
|
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
|
|
|
|
for (contenu in contenus) {
|
|
|
|
|
when (contenu) {
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(
|
|
|
|
|
data = e.imagePrincipale
|
|
|
|
|
),
|
|
|
|
|
contentScale = ContentScale.Crop,
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(350.dp)
|
|
|
|
|
.align(Alignment.CenterHorizontally)
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Column(modifier = Modifier) {
|
|
|
|
|
for (text in e.contenus) {
|
|
|
|
|
when (text) {
|
|
|
|
|
is ContenuMedia -> {
|
|
|
|
|
Text(text = contenu.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
when (contenu.typeContenu) {
|
|
|
|
|
Text(text = text.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
when (text.typeContenu) {
|
|
|
|
|
"image" -> {
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(data = contenu.lien),
|
|
|
|
|
painter = rememberImagePainter(
|
|
|
|
|
data = text.lien
|
|
|
|
|
),
|
|
|
|
|
contentScale = ContentScale.FillHeight,
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(350.dp)
|
|
|
|
|
.align(Alignment.CenterHorizontally)
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.wrapContentWidth(Alignment.CenterHorizontally) // Centrer l'image
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"video" -> {
|
|
|
|
|
// Pour l'instant, un simple texte pour les vidéos
|
|
|
|
|
Text(text = "Ici une vidéo ... ${contenu.lien}", fontSize = 15.sp, textAlign = TextAlign.Start)
|
|
|
|
|
// Implémentation pour vidéo à venir...
|
|
|
|
|
Text(
|
|
|
|
|
text = "Ici une video ..." + text.toString(),
|
|
|
|
|
fontSize = 15.sp,
|
|
|
|
|
textAlign = TextAlign.Start
|
|
|
|
|
)
|
|
|
|
|
// le player video marche a moitié mais honnetenement je comprends pas le soucis
|
|
|
|
|
VideoPlayer(videoUrl = text.lien)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is ContenuParagraphe -> {
|
|
|
|
|
Text(text = contenu.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
Text(text = contenu.texte, fontSize = 16.sp, textAlign = TextAlign.Start)
|
|
|
|
|
Text(text = text.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
Text(text = text.toString(), fontSize = 16.sp, textAlign = TextAlign.Start)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -183,68 +179,34 @@ fun DisplayContenu(contenus: List<Contenu>) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayImage(image: String) {
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(
|
|
|
|
|
data = image
|
|
|
|
|
),
|
|
|
|
|
contentScale = ContentScale.Crop,
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
fun DisplayHeader(author: String, description: String, lectureTime: String) {
|
|
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(350.dp)
|
|
|
|
|
.align(Alignment.CenterHorizontally)
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
)
|
|
|
|
|
.padding(15.dp)
|
|
|
|
|
.border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(10.dp))
|
|
|
|
|
.clip(RoundedCornerShape(10.dp))
|
|
|
|
|
.background(Salmon)
|
|
|
|
|
) {
|
|
|
|
|
Column(modifier = Modifier.padding(15.dp)) {
|
|
|
|
|
Text(text = "Auteur : "+ author, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Description : "+ description, fontSize = 17.sp)
|
|
|
|
|
Text(text = "Temps de lecture : " + lectureTime + " minutes", fontSize = 17.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayImage(image: String) {
|
|
|
|
|
fun DisplayImage(imageURl : String){
|
|
|
|
|
Log.d("ImageLoad", "URL de l'image reçue de l'API : $imageURl")
|
|
|
|
|
|
|
|
|
|
Image(
|
|
|
|
|
painter = rememberImagePainter(
|
|
|
|
|
data = e.imagePrincipale
|
|
|
|
|
data = imageURl
|
|
|
|
|
),
|
|
|
|
|
contentScale = ContentScale.Crop,
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(350.dp)
|
|
|
|
|
.align(Alignment.CenterHorizontally)
|
|
|
|
|
.padding(5.dp, 35.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayHeader(author: String, description: String, lectureTime: String) {
|
|
|
|
|
Box(modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(10.dp))
|
|
|
|
|
.clip(RoundedCornerShape(10.dp))
|
|
|
|
|
.background(Salmon)
|
|
|
|
|
.padding(10.dp)) {
|
|
|
|
|
Column () {
|
|
|
|
|
Text(text = author)
|
|
|
|
|
Text(text = description)
|
|
|
|
|
Text(text = "Lecture Time: " + lectureTime + " minutes")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayTitle(title: String) {
|
|
|
|
|
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally){
|
|
|
|
|
Text(text = title, fontFamily = FontFamily.Serif, fontSize = 30.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayContentArticle(content: List<Contenu>) {
|
|
|
|
|
Column {
|
|
|
|
|
for(e in content){
|
|
|
|
|
Text(text = e.Content, fontSize = 15.sp, fontFamily = FontFamily.Serif, textAlign = TextAlign.Justify, modifier = Modifier.padding(10.dp))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|