Le modele marche !

navigationHost
Shana CASCARRA 4 months ago
parent 8d589d9146
commit 3dbe1afa25

@ -1,62 +1,14 @@
package com.example.veraxapplication
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.example.veraxapplication.ui.theme.Salmon
import androidx.compose.ui.graphics.Color
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.ui.res.colorResource
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
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.draw.clip
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.rememberImagePainter
import coil.size.Scale
import com.example.veraxapplication.articles.IArticlesDataManager
import com.example.veraxapplication.articles.StubArticles
import com.example.veraxapplication.data.Article
import com.example.veraxapplication.data.Paragraph
import com.example.veraxapplication.ui.topBar.*
// doc navBar: https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#TopAppBar(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.Function1,androidx.compose.foundation.layout.WindowInsets,androidx.compose.material3.TopAppBarColors,androidx.compose.material3.TopAppBarScrollBehavior)
@ -70,10 +22,10 @@ class MainActivity : ComponentActivity() {
// un truc vite fait pour avoir un visi
// var article = listOf("Thinkerview", "thinkerview.jgp", "Thinkerview est une chaîne youtube d'interview-débat")
var articles = listOf( Article("Thinkerview", "This is a descrition", Author = "IAmAGreatAuthor", Image = "https://www.gstatic.com/webp/gallery/1.jpg", LectureTime = "12", Content = listOf(Paragraph("This is a paragraph"), Paragraph("This is another paragraph"), Paragraph("This is a third paragraph"))), Article("Thinkerview", "This is a descrition", Author = "IAmAGreatAuthor", Image = "https://www.gstatic.com/webp/gallery/1.jpg", LectureTime = "12", Content = listOf(Paragraph("This is a paragraph"), Paragraph("This is another paragraph"), Paragraph("This is a third paragraph"))))
//var articles = listOf( Article("Thinkerview", "This is a descrition", Author = "IAmAGreatAuthor", Image = "https://www.gstatic.com/webp/gallery/1.jpg", LectureTime = "12", Content = listOf(Paragraph("This is a paragraph"), Paragraph("This is another paragraph"), Paragraph("This is a third paragraph"))), Article("Thinkerview", "This is a descrition", Author = "IAmAGreatAuthor", Image = "https://www.gstatic.com/webp/gallery/1.jpg", LectureTime = "12", Content = listOf(Paragraph("This is a paragraph"), Paragraph("This is another paragraph"), Paragraph("This is a third paragraph"))))
var dataManager: IArticlesDataManager = StubArticles()
//var articles = dataManager.getDerniersArticles(4)
var articles = dataManager.getDerniersArticles(4)
var theme = listOf("Economique", "Culture", "Politique", "Faits divers")

@ -1,5 +1,5 @@
package com.example.veraxapplication.data
/*
data class Article(
var Title : String,
var Description : String,
@ -8,3 +8,4 @@ data class Article(
var Content : List<Paragraph>,
var LectureTime : String
)
*/

@ -1,5 +1,6 @@
package com.example.veraxapplication.data
/*
data class Paragraph(
var Content : String,
)
*/

@ -7,5 +7,5 @@ interface IArticlesDataManager {
val allArticles: List<Any?>?
fun getArticle(id: Int): Article?
fun getDerniersArticles(nbArticles: Int): List<Article?>?
fun getDerniersArticles(nbArticles: Int): List<Article>
}

@ -430,10 +430,8 @@ class StubArticles() : IArticlesDataManager {
return null // Retourne null si lArticles est null
}
override fun getDerniersArticles(nbArticles: Int): List<Article>? {
return lArticles?.let {
it.take(min(nbArticles, it.size))
}
override fun getDerniersArticles(nbArticles: Int): List<Article> {
return lArticles?.takeIf { it.isNotEmpty() }?.take(nbArticles) ?: emptyList()
}
}

@ -1,14 +1,10 @@
package com.example.veraxapplication.ui.article
import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@ -17,18 +13,15 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.rememberImagePainter
import coil.size.Scale
import com.example.veraxapplication.data.Article
import com.example.veraxapplication.data.Paragraph
import com.example.veraxapplication.modele.articles.Article
import com.example.veraxapplication.ui.theme.Salmon
@Composable
@ -50,7 +43,7 @@ fun AffichageUnArticle(e : Article){
Text(text = e.Title, fontFamily = FontFamily.Serif, fontSize = 30.sp)
Text(text = e.titre, fontFamily = FontFamily.Serif, fontSize = 30.sp)
Box(modifier = Modifier
.fillMaxWidth()
@ -59,14 +52,14 @@ fun AffichageUnArticle(e : Article){
.background(Salmon)
.padding(10.dp)) {
Column () {
Text(text = e.Author)
Text(text = e.Description)
Text(text = "Lecture Time: " + e.LectureTime + " minutes")
Text(text = e.auteur)
Text(text = e.description)
Text(text = "Lecture Time: " + e.temps + " minutes")
}
}
Image(
painter = rememberImagePainter(
data = e.Image,
data = e.imagePrincipale,
builder = {
scale(Scale.FILL)
}
@ -75,16 +68,18 @@ fun AffichageUnArticle(e : Article){
modifier = Modifier.size(250.dp),
)
/*
Column {
for(c in e.Content){
Text(text = c.Content, fontSize = 15.sp, fontFamily = FontFamily.Serif, textAlign = TextAlign.Justify, modifier = Modifier.padding(10.dp))
for(c in e.contenus){
Text(text = c.toString(), fontSize = 15.sp, fontFamily = FontFamily.Serif, textAlign = TextAlign.Justify, modifier = Modifier.padding(10.dp))
}
}
*/
}
}
/*
@Composable
fun DisplayImage(image: String) {
Log.d("DisplayImage", "Chargement de l'image à partir de l'URL : $image")
@ -134,10 +129,10 @@ fun DisplayTitle(title: String) {
}
@Composable
fun DisplayContentArticle(content: List<Paragraph>) {
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))
}
}
}
}*/

@ -9,10 +9,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
@ -34,12 +31,12 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.veraxapplication.R
import com.example.veraxapplication.data.Article
import com.example.veraxapplication.ui.article.*
import com.example.veraxapplication.modele.articles.Article
import com.example.veraxapplication.ui.article.AffichageLesArticles
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBarVerax(theme : List<String>, articles : List<Article>) {
fun TopBarVerax(theme: List<String>, articles: List<Article>) {
var leMenu by remember {
mutableStateOf(false)
}

Loading…
Cancel
Save