diff --git a/Android/VeraxApplication/app/src/main/java/com/example/veraxapplication/MainActivity.kt b/Android/VeraxApplication/app/src/main/java/com/example/veraxapplication/MainActivity.kt index 775033e..370cd77 100644 --- a/Android/VeraxApplication/app/src/main/java/com/example/veraxapplication/MainActivity.kt +++ b/Android/VeraxApplication/app/src/main/java/com/example/veraxapplication/MainActivity.kt @@ -67,17 +67,11 @@ class MainActivity : ComponentActivity() { // 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")))) - var dataManager : IArticlesDataManager = StubArticles() + var dataManager: IArticlesDataManager = StubArticles() var articles = dataManager.getDerniersArticles(4) - - - - - - - var theme = listOf("Economique","Culture","Politique","Faits divers") + var theme = listOf("Economique", "Culture", "Politique", "Faits divers") var color = Color(0xFF00FF00) override fun onCreate(savedInstanceState: Bundle?) { @@ -88,185 +82,187 @@ class MainActivity : ComponentActivity() { articles?.forEach({ a -> Log.println(Log.ASSERT, "debug articles", a.toString()) - -// if (a != null) { -// a.contenus.forEach({cont -> -// -// Log.println(Log.ASSERT, "contenus de l'article " + a.id, cont.toString()) -// }) -// } -// }) - - - //TopBarVerax(theme = theme, article = articles) - // allez sur la doc de Scaffold sur Android Dev et si vous comprenez comment on doit faire bien ouej - + }) } } -} -// Il faudrait mettre ca dans un fichier appart mais je connais plus les conventions ... -@OptIn(ExperimentalMaterial3Api::class) -@Composable -fun TopBarVerax(theme : List, article : List
) { - var leMenu by remember { - mutableStateOf(false) - } - Row() { - Scaffold( - topBar = { - CenterAlignedTopAppBar( - title = { - Text( - text = "Verax", - style = TextStyle(fontSize = 35.sp), - color = colorResource(R.color.red), - textAlign = TextAlign.Center, - /*backcolor = topAppBarColors( + // Il faudrait mettre ca dans un fichier appart mais je connais plus les conventions ... + @OptIn(ExperimentalMaterial3Api::class) + @Composable + fun TopBarVerax(theme: List, article: List
) { + var leMenu by remember { + mutableStateOf(false) + } + Row() { + Scaffold( + topBar = { + CenterAlignedTopAppBar( + title = { + Text( + text = "Verax", + style = TextStyle(fontSize = 35.sp), + color = colorResource(R.color.red), + textAlign = TextAlign.Center, + /*backcolor = topAppBarColors( containerColor = MaterialTheme.colorScheme.primaryContainer),*/ //version recommandée par le prof - modifier = Modifier.fillMaxWidth() - ) - }, - navigationIcon = { - IconButton(onClick = { /* action() */ }) { - Icon( - imageVector = Icons.Filled.ArrowBack, - contentDescription = "Retour", - Modifier.size(30.dp) + modifier = Modifier.fillMaxWidth() ) + }, + navigationIcon = { + IconButton(onClick = { /* action() */ }) { + Icon( + imageVector = Icons.Filled.ArrowBack, + contentDescription = "Retour", + Modifier.size(30.dp) + ) + } + }, + actions = { + IconButton(onClick = { leMenu = !leMenu }) { + Icon( + imageVector = Icons.Filled.Menu, + contentDescription = "Menu", + Modifier.size(35.dp) + ) + } + DropdownMenu( + expanded = leMenu, onDismissRequest = { leMenu = false }, + modifier = Modifier + .background(Color.hsl(0.08F, 1F, 0.96F)) + ) { + theme.sorted().forEach { + DropdownMenuItem( + text = { + Text( + it, + style = TextStyle(fontSize = 25.sp), + modifier = Modifier + .padding(10.dp) + ) + }, + onClick = { /* faut un moyen d'appeler une methode diff pour chaque, ca doit etre faisable facilement */ } + ) + } + } } - }, - actions = { - IconButton(onClick = { leMenu = !leMenu }) { + + ) + }, + bottomBar = { + // Faudrait pouvoir faire un flex sur les boutons parce que là ils sont juste côte à côte + BottomAppBar(containerColor = Color.Black, contentColor = Color.White) { + IconButton(onClick = { /*TODO*/ }) { Icon( - imageVector = Icons.Filled.Menu, - contentDescription = "Menu", + imageVector = Icons.Filled.Home, + contentDescription = "Home", Modifier.size(35.dp) ) } - DropdownMenu( - expanded = leMenu, onDismissRequest = { leMenu = false }, - modifier = Modifier - .background(Color.hsl(0.08F, 1F, 0.96F)) - ) { - theme.sorted().forEach { - DropdownMenuItem( - text = { - Text( - it, - style = TextStyle(fontSize = 25.sp), - modifier = Modifier - .padding(10.dp) - ) - }, - onClick = { /* faut un moyen d'appeler une methode diff pour chaque, ca doit etre faisable facilement */ } - ) - } + IconButton(onClick = { /*TODO*/ }) { + Icon( + imageVector = Icons.Filled.Person, + contentDescription = "Account", + Modifier.size(35.dp) + ) } } - - ) - }, - bottomBar = { - // Faudrait pouvoir faire un flex sur les boutons parce que là ils sont juste côte à côte - BottomAppBar(containerColor = Color.Black, contentColor = Color.White) { - IconButton(onClick = { /*TODO*/ }) { - Icon( - imageVector = Icons.Filled.Home, - contentDescription = "Home", - Modifier.size(35.dp) - ) - } - IconButton(onClick = { /*TODO*/ }) { - Icon( - imageVector = Icons.Filled.Person, - contentDescription = "Account", - Modifier.size(35.dp) - ) - } } - } - ) { innerPadding -> - Column( - modifier = Modifier - .padding(innerPadding), - verticalArrangement = Arrangement.spacedBy(16.dp), - ) { - AffichageUnArticle(article = article) + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + AffichageUnArticle(article = article) + } } } } -} -@Composable -fun AffichageUnArticle(article : List
){ - Column() { - for(e in article){ - DisplayTitle(title = e.Title) - DisplayHeader(author = e.Author, description = e.Description, lectureTime = e.LectureTime) - DisplayImage(image = e.Image) - DisplayContentArticle(content = e.Content) + @Composable + fun AffichageUnArticle(article: List
) { + Column() { + for (e in article) { + DisplayTitle(title = e.Title) + DisplayHeader( + author = e.Author, + description = e.Description, + lectureTime = e.LectureTime + ) + DisplayImage(image = e.Image) + DisplayContentArticle(content = e.Content) + } } } -} -@Composable -fun DisplayImage(image: String) { - Log.d("DisplayImage", "Chargement de l'image à partir de l'URL : $image") + @Composable + fun DisplayImage(image: String) { + Log.d("DisplayImage", "Chargement de l'image à partir de l'URL : $image") - val painter = rememberImagePainter( - data = image, - builder = { - scale(Scale.FILL) - } - ) + val painter = rememberImagePainter( + data = image, + builder = { + scale(Scale.FILL) + } + ) - Log.d("DisplayImage", "Painter créé avec succès") + Log.d("DisplayImage", "Painter créé avec succès") - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center - ) { - androidx.compose.foundation.Image( - painter = painter, - contentDescription = null, + Box( modifier = Modifier.fillMaxSize(), - ) + contentAlignment = Alignment.Center + ) { + androidx.compose.foundation.Image( + painter = painter, + contentDescription = null, + modifier = Modifier.fillMaxSize(), + ) + } } -} - -@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 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 DisplayTitle(title: String) { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text(text = title, fontFamily = FontFamily.Serif, fontSize = 30.sp) + } } -} -@Composable -fun DisplayContentArticle(content: List) { - Column { - for(e in content){ - Text(text = e.Content, fontSize = 15.sp, fontFamily = FontFamily.Serif, textAlign = TextAlign.Justify, modifier = Modifier.padding(10.dp)) + @Composable + fun DisplayContentArticle(content: List) { + Column { + for (e in content) { + Text( + text = e.Content, + fontSize = 15.sp, + fontFamily = FontFamily.Serif, + textAlign = TextAlign.Justify, + modifier = Modifier.padding(10.dp) + ) + } } } }