Compare commits
22 Commits
7ccb9e8cf9
...
c661a12d7d
Author | SHA1 | Date |
---|---|---|
|
c661a12d7d | 1 year ago |
|
47daea74e6 | 1 year ago |
|
90da510a63 | 1 year ago |
|
21276b729b | 1 year ago |
|
21b87e9206 | 1 year ago |
|
22de81e373 | 1 year ago |
|
aa95ce53a2 | 1 year ago |
|
2818828c3c | 1 year ago |
|
c2abb90896 | 1 year ago |
|
2c6f66eabd | 1 year ago |
|
f874d363aa | 1 year ago |
|
3dbe1afa25 | 1 year ago |
|
8d589d9146 | 1 year ago |
|
8a30b2e6cb | 1 year ago |
|
6a414e3796 | 1 year ago |
![]() |
3b089e35f6 | 1 year ago |
![]() |
90bd1b0e5b | 1 year ago |
![]() |
ce485f5bec | 1 year ago |
![]() |
c26affc745 | 1 year ago |
![]() |
b2a9da1992 | 1 year ago |
|
f0ebbb91fb | 1 year ago |
|
5f5c8ee1f2 | 1 year ago |
@ -1,181 +1,63 @@
|
|||||||
package com.example.veraxapplication
|
package com.example.veraxapplication
|
||||||
|
|
||||||
import android.graphics.Paint.Align
|
import ArticlesViewModel
|
||||||
|
import IUsersDataManager
|
||||||
|
import StubUsers
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Layout
|
|
||||||
import android.view.Menu
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.runtime.Composable
|
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.material3.ExperimentalMaterial3Api
|
|
||||||
import androidx.compose.material3.MenuDefaults
|
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TopAppBar
|
|
||||||
import androidx.compose.ui.res.colorResource
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
|
||||||
import androidx.compose.material.icons.filled.Favorite
|
|
||||||
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.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.NavigationBarDefaults.containerColor
|
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.material3.ScaffoldDefaults
|
|
||||||
import androidx.compose.material3.TopAppBarDefaults.topAppBarColors
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.runtime.remember
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.compose.runtime.setValue
|
import com.example.veraxapplication.modele.IArticlesDataManager
|
||||||
import androidx.compose.ui.Alignment
|
import com.example.veraxapplication.articles.StubArticles
|
||||||
import androidx.compose.ui.text.TextStyle
|
import com.example.veraxapplication.modele.api.UsersViewModel
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import com.example.veraxapplication.navigation.VeraxNavHost
|
||||||
import androidx.compose.ui.unit.dp
|
import com.example.veraxapplication.ui.connexion.AfficherForm
|
||||||
import androidx.compose.ui.unit.sp
|
import com.example.veraxapplication.ui.topBar.TopBarVerax
|
||||||
|
|
||||||
// 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)
|
// 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)
|
||||||
// doc compose, pleins de trucs: https://developer.android.com/jetpack/compose/text?hl=fr
|
// doc compose, pleins de trucs: https://developer.android.com/jetpack/compose/text?hl=fr
|
||||||
//doc couleur background pas finie: https://developer.android.com/jetpack/compose/components/scaffold
|
//doc couleur background pas finie: https://developer.android.com/jetpack/compose/components/scaffold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
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 theme = listOf("Economique","Culture","Politique","Faits divers")
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContent {
|
setContent {
|
||||||
TopBarVerax(theme = theme, article = article)
|
VeraxContent()
|
||||||
// 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
|
@Composable
|
||||||
fun TopBarVerax(theme : List<String>, article : List<String>) {
|
fun VeraxContent() {
|
||||||
var leMenu by remember {
|
|
||||||
mutableStateOf(false)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
Modifier.background(Color.Cyan)
|
|
||||||
) {
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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 */ }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
)
|
|
||||||
},
|
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
// Initialiser les données ou observer les données du ViewModel
|
||||||
}
|
var dataManager: IArticlesDataManager = StubArticles()
|
||||||
}
|
var articles = dataManager.getDerniersArticles(4)
|
||||||
}
|
|
||||||
|
|
||||||
|
var usersManager: IUsersDataManager = StubUsers()
|
||||||
|
var users = usersManager.getUsers();
|
||||||
|
|
||||||
|
// Observer les données du ViewModel
|
||||||
|
val articlesViewModel: ArticlesViewModel = viewModel()
|
||||||
|
|
||||||
|
// Observez les articles du ViewModel
|
||||||
|
val articlesApi by articlesViewModel.articles.observeAsState(initial = articles)
|
||||||
|
|
||||||
|
val usersViewModel: UsersViewModel = viewModel()
|
||||||
|
|
||||||
|
val usersApi by usersViewModel.users.observeAsState(initial = users)
|
||||||
|
|
||||||
|
|
||||||
|
var theme = listOf("Economique", "Culture", "Politique", "Faits divers")
|
||||||
|
|
||||||
|
|
||||||
|
TopBarVerax(articles = articlesApi, theme = theme, articlesStub= articles)
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun AffichageUnArticle(article : List<String>){
|
|
||||||
Column {
|
|
||||||
for(e in article){
|
|
||||||
Text(text = e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.example.veraxapplication.data
|
||||||
|
/*
|
||||||
|
data class Article(
|
||||||
|
var Title : String,
|
||||||
|
var Description : String,
|
||||||
|
var Image : String,
|
||||||
|
var Author : String,
|
||||||
|
var Content : List<Paragraph>,
|
||||||
|
var LectureTime : String
|
||||||
|
)
|
||||||
|
*/
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.example.veraxapplication.data
|
||||||
|
/*
|
||||||
|
data class Paragraph(
|
||||||
|
var Content : String,
|
||||||
|
)
|
||||||
|
*/
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.example.veraxapplication.modele
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
|
||||||
|
|
||||||
|
interface IArticlesDataManager {
|
||||||
|
val allArticles: List<Any?>?
|
||||||
|
|
||||||
|
fun getArticle(id: Int): Article?
|
||||||
|
fun getDerniersArticles(nbArticles: Int): List<Article>
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
import com.example.veraxapplication.modele.user.User
|
||||||
|
|
||||||
|
|
||||||
|
interface IUsersDataManager {
|
||||||
|
val allUsers: List<Any?>?
|
||||||
|
|
||||||
|
fun getUser(pseudo : String): User?
|
||||||
|
fun getUsers(): List<User>
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.example.veraxapplication.modele.api
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class ArticleDTO (
|
||||||
|
|
||||||
|
@SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
@SerializedName("titre")
|
||||||
|
val titre: String,
|
||||||
|
@SerializedName("description")
|
||||||
|
val description: String,
|
||||||
|
@SerializedName("temps")
|
||||||
|
val temps: String,
|
||||||
|
@SerializedName("date")
|
||||||
|
val date: String,
|
||||||
|
@SerializedName("auteur")
|
||||||
|
val auteur: String,
|
||||||
|
@SerializedName("categorie")
|
||||||
|
val categorie: String,
|
||||||
|
@SerializedName("imagePrincipale")
|
||||||
|
val imagePrincipale: String,
|
||||||
|
@SerializedName("note")
|
||||||
|
val note: String,
|
||||||
|
) {
|
||||||
|
fun toModel(): Article {
|
||||||
|
return Article(
|
||||||
|
id,
|
||||||
|
titre,
|
||||||
|
description,
|
||||||
|
temps,
|
||||||
|
date,
|
||||||
|
auteur,
|
||||||
|
categorie,
|
||||||
|
imagePrincipale,
|
||||||
|
note,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class ContenuDTO (
|
||||||
|
@SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
@SerializedName("typeContenu")
|
||||||
|
val typeContenu: String,
|
||||||
|
@SerializedName("titre")
|
||||||
|
val titre: String,
|
||||||
|
@SerializedName("texte")
|
||||||
|
val texte: String,
|
||||||
|
)
|
@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.example.veraxapplication.modele.api.IArticleService
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
object ArticleApiClient {
|
||||||
|
private const val BASE_URL = "http://181.214.189.133:9092/"
|
||||||
|
|
||||||
|
private val logging = HttpLoggingInterceptor().apply {
|
||||||
|
level = HttpLoggingInterceptor.Level.BODY
|
||||||
|
}
|
||||||
|
|
||||||
|
private val httpClient = OkHttpClient.Builder().apply {
|
||||||
|
addInterceptor(logging)
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
val retrofit: Retrofit = Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.client(httpClient)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
class ArticlesViewModel : ViewModel() {
|
||||||
|
private val _articles = MutableLiveData<List<Article>>()
|
||||||
|
val articles: LiveData<List<Article>> = _articles
|
||||||
|
|
||||||
|
private val service = ArticleApiClient.retrofit.create(IArticleService::class.java)
|
||||||
|
|
||||||
|
init {
|
||||||
|
loadArticles()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun loadArticles() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
val articlesDto = service.getArticles() // Pas besoin d'appeler .execute()
|
||||||
|
// Convertissez les DTO en modèles de données si nécessaire
|
||||||
|
_articles.value = articlesDto.map { it.toModel() }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("ArticlesViewModel", "Erreur lors du chargement des articles", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.example.veraxapplication.modele.api
|
||||||
|
|
||||||
|
import retrofit2.http.GET
|
||||||
|
|
||||||
|
interface IArticleService {
|
||||||
|
@GET("articles")
|
||||||
|
suspend fun getArticles(): List<ArticleDTO>
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.example.veraxapplication.modele.api
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.user.User
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.http.GET
|
||||||
|
|
||||||
|
interface IUserService {
|
||||||
|
@GET("users")
|
||||||
|
suspend fun getUsers(): List<UserDTO>
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.example.veraxapplication.modele.api
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.user.User
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class UserDTO (
|
||||||
|
|
||||||
|
@SerializedName("pseudo")
|
||||||
|
val pseudo: String,
|
||||||
|
@SerializedName("mdp")
|
||||||
|
val mdp: String,
|
||||||
|
@SerializedName("mail")
|
||||||
|
val mail: String,
|
||||||
|
@SerializedName("nom")
|
||||||
|
val nom: String,
|
||||||
|
@SerializedName("prenom")
|
||||||
|
val prenom: String,
|
||||||
|
@SerializedName("role")
|
||||||
|
val role: String,
|
||||||
|
|
||||||
|
) {
|
||||||
|
fun toModel(): User {
|
||||||
|
return User(
|
||||||
|
pseudo,
|
||||||
|
mdp,
|
||||||
|
mail,
|
||||||
|
nom,
|
||||||
|
prenom,
|
||||||
|
role,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.example.veraxapplication.modele.api
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import com.example.veraxapplication.modele.user.User
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
object RetrofitClientUser {
|
||||||
|
|
||||||
|
private const val BASE_URL = "https://codefirst.iut.uca.fr/containers/Verax-verax-api"
|
||||||
|
|
||||||
|
private val logging = HttpLoggingInterceptor().apply {
|
||||||
|
level = HttpLoggingInterceptor.Level.BODY
|
||||||
|
}
|
||||||
|
|
||||||
|
private val httpClient = OkHttpClient.Builder().apply {
|
||||||
|
addInterceptor(logging)
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
|
||||||
|
val retrofit: Retrofit by lazy {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
// interface UserApiService {
|
||||||
|
// @GET("users")
|
||||||
|
// suspend fun getUsers() : List<User>
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsersViewModel : ViewModel() {
|
||||||
|
private val _users = MutableLiveData<List<User>>()
|
||||||
|
val users: LiveData<List<User>> = _users
|
||||||
|
|
||||||
|
private val service = ArticleApiClient.retrofit.create(IUserService::class.java)
|
||||||
|
|
||||||
|
init {
|
||||||
|
loadUsers()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun loadUsers() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
val usersDto = service.getUsers() // Pas besoin d'appeler .execute()
|
||||||
|
// Convertissez les DTO en modèles de données si nécessaire
|
||||||
|
_users.value = usersDto.map { it.toModel() }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("UsersViewModel", "Erreur lors du chargement des users", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.example.veraxapplication.modele.articles
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.articles.contenus.Contenu
|
||||||
|
|
||||||
|
class Article(
|
||||||
|
val id: Int,
|
||||||
|
val titre: String,
|
||||||
|
val description: String,
|
||||||
|
val temps: String,
|
||||||
|
val date: String,
|
||||||
|
val auteur: String,
|
||||||
|
val categorie: String,
|
||||||
|
val imagePrincipale: String,
|
||||||
|
val note: String
|
||||||
|
) {
|
||||||
|
public val lContenus: MutableList<Contenu> = java.util.ArrayList()
|
||||||
|
|
||||||
|
init {
|
||||||
|
// Initialisation des contenus si nécessaire
|
||||||
|
}
|
||||||
|
|
||||||
|
fun remplirArticle(lContenus: List<Contenu>?) {
|
||||||
|
if (lContenus != null) {
|
||||||
|
this.lContenus.addAll(lContenus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val contenus: List<Any>
|
||||||
|
get() = lContenus
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "Article(id=$id, titre='$titre', description='$description', temps='$temps', date='$date', auteur='$auteur', imagePrincipale='$imagePrincipale', note=$note, contenus=${lContenus.size} contenus)"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.example.veraxapplication.modele.articles.contenus
|
||||||
|
|
||||||
|
|
||||||
|
abstract class Contenu(var id: Int) {
|
||||||
|
var typeContenu: String? = null
|
||||||
|
protected set
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.veraxapplication.modele.articles.contenus
|
||||||
|
|
||||||
|
class ContenuMedia(id: Int, var titre: String, var lien: String) : Contenu(id) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.typeContenu = "image"
|
||||||
|
}
|
||||||
|
|
||||||
|
val contenu: Map<String, String>
|
||||||
|
get() {
|
||||||
|
val contenu: MutableMap<String, String> = HashMap()
|
||||||
|
contenu["titre"] = titre
|
||||||
|
contenu["contenu"] = lien
|
||||||
|
return contenu
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newVideo(id: Int, titre: String, lien: String): ContenuMedia {
|
||||||
|
val temp = ContenuMedia(id, titre, lien)
|
||||||
|
|
||||||
|
temp.typeContenu = "video"
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "$lien\n\n"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.example.veraxapplication.modele.articles.contenus
|
||||||
|
|
||||||
|
class ContenuParagraphe(id: Int, var titre: String, var texte: String) : Contenu(id) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.typeContenu = "paragraphe"
|
||||||
|
}
|
||||||
|
|
||||||
|
val contenu: Map<String, String>
|
||||||
|
get() {
|
||||||
|
val contenu: MutableMap<String, String> = HashMap()
|
||||||
|
contenu["titre"] = titre
|
||||||
|
contenu["contenu"] = texte
|
||||||
|
return contenu
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "$texte \n\n"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
import com.example.veraxapplication.modele.IArticlesDataManager
|
||||||
|
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.modele.user.User
|
||||||
|
|
||||||
|
|
||||||
|
class StubUsers() : IUsersDataManager {
|
||||||
|
private var lUsers: MutableList<User>? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
chargerUsers()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun chargerUsers() {
|
||||||
|
lUsers = java.util.ArrayList<User>()
|
||||||
|
val user1 = User (
|
||||||
|
"NoaSil",
|
||||||
|
"1234",
|
||||||
|
"",
|
||||||
|
"Sillard",
|
||||||
|
"Noa",
|
||||||
|
"Admin"
|
||||||
|
)
|
||||||
|
lUsers!!.add(user1)
|
||||||
|
val user2 = User (
|
||||||
|
"Sha",
|
||||||
|
"1234",
|
||||||
|
"",
|
||||||
|
"Cascarra",
|
||||||
|
"Shana",
|
||||||
|
"Admin"
|
||||||
|
)
|
||||||
|
lUsers!!.add(user2)
|
||||||
|
val user3 = User (
|
||||||
|
"TonyF",
|
||||||
|
"1234",
|
||||||
|
"tony@gmail.com",
|
||||||
|
"Fages",
|
||||||
|
"Tony",
|
||||||
|
"Admin"
|
||||||
|
)
|
||||||
|
lUsers!!.add(user3)
|
||||||
|
val user4 = User (
|
||||||
|
"JeanSwaggLaPuissance63",
|
||||||
|
"1234",
|
||||||
|
"jean.lapuissance@gmail.com",
|
||||||
|
"Marcillac",
|
||||||
|
"Jean",
|
||||||
|
"Admin"
|
||||||
|
)
|
||||||
|
lUsers!!.add(user4)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val allUsers: List<User>?
|
||||||
|
get() = lUsers
|
||||||
|
|
||||||
|
override fun getUser(pseudo : String): User? {
|
||||||
|
println("Passage dans getUser avec comme pseudo : $pseudo")
|
||||||
|
lUsers?.let {
|
||||||
|
println("Nombre d'utilisateurs disponibles : ${it.size}")
|
||||||
|
|
||||||
|
val userARenvoyer: User? = it.find { user -> user.pseudo == pseudo }
|
||||||
|
|
||||||
|
return userARenvoyer
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getUsers(): List<User>
|
||||||
|
{
|
||||||
|
return lUsers?.takeIf { it.isNotEmpty() }?.take(lUsers!!.size) ?: emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.example.veraxapplication.modele.user
|
||||||
|
|
||||||
|
data class User(val pseudo : String, val mdp : String, val mail : String, val nom : String, val prenom : String, val role : String)
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.example.veraxapplication.navigation
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.NavType
|
||||||
|
import androidx.navigation.compose.NavHost
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import androidx.navigation.navArgument
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import com.example.veraxapplication.ui.article.AffichageLesArticles
|
||||||
|
import com.example.veraxapplication.ui.article.AfficherArticle
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VeraxNavHost(articles : List<Article>, navController: NavHostController, articlesStub: List<Article>) {
|
||||||
|
|
||||||
|
|
||||||
|
NavHost(
|
||||||
|
navController = navController,
|
||||||
|
startDestination = "accueil"
|
||||||
|
){
|
||||||
|
composable(route="accueil"){
|
||||||
|
AffichageLesArticles(
|
||||||
|
articles = articles,
|
||||||
|
goToArticle = {
|
||||||
|
navController.navigate("article/${it.id}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(
|
||||||
|
route="article/{articleid}",
|
||||||
|
arguments= listOf(navArgument("articleid"){ type= NavType.IntType})
|
||||||
|
){
|
||||||
|
it.arguments?.getInt("articleid")?.let { articleid ->
|
||||||
|
articlesStub.find { it.id == articleid }?.let {
|
||||||
|
AfficherArticle(
|
||||||
|
e = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,189 @@
|
|||||||
|
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
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
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.layout.ContentScale
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
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>, goToArticle: (Article) -> Unit){
|
||||||
|
Column(modifier = Modifier.verticalScroll(rememberScrollState())){
|
||||||
|
for(article in articles){
|
||||||
|
Box {
|
||||||
|
AffichageUnArticleInfo(e = article, goToArticle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
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)) {
|
||||||
|
|
||||||
|
Text(text = e.titre, fontFamily = FontFamily.Serif, fontSize = 30.sp)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Image(
|
||||||
|
painter = rememberImagePainter(
|
||||||
|
data = e.imagePrincipale
|
||||||
|
),
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(350.dp)
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(5.dp, 35.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Button(onClick = { goToArticle(e)},
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = Salmon,
|
||||||
|
contentColor = Color.Black
|
||||||
|
),
|
||||||
|
border = BorderStroke(1.dp, Color.Black),
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
) {
|
||||||
|
Text(text = "Voir plus")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AfficherArticle(e : Article){
|
||||||
|
Column(modifier = Modifier
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
.padding(7.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)
|
||||||
|
|
||||||
|
|
||||||
|
Image(
|
||||||
|
painter = rememberImagePainter(
|
||||||
|
data = e.imagePrincipale
|
||||||
|
),
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(350.dp)
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(5.dp, 35.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
// Affichage contenus
|
||||||
|
DisplayContenu(e.lContenus)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DisplayHeader(author: String, description: String, lectureTime: String) {
|
||||||
|
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 : "+ author, fontSize = 17.sp)
|
||||||
|
Text(text = "Description : "+ description, fontSize = 17.sp)
|
||||||
|
Text(text = "Temps de lecture : " + lectureTime + " minutes", fontSize = 17.sp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Composable
|
||||||
|
fun DisplayContenu(contenus: List<Contenu>) {
|
||||||
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
|
for (contenu in contenus) {
|
||||||
|
when (contenu) {
|
||||||
|
|
||||||
|
is ContenuMedia -> {
|
||||||
|
Log.d("Img", contenu.titre + " " + contenu.lien)
|
||||||
|
Text(text = contenu.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
||||||
|
when (contenu.typeContenu) {
|
||||||
|
"image" -> {
|
||||||
|
Image(
|
||||||
|
painter = rememberImagePainter(data = contenu.lien),
|
||||||
|
contentScale = ContentScale.FillHeight,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(350.dp)
|
||||||
|
.padding(5.dp, 35.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.wrapContentWidth(Alignment.CenterHorizontally) // Centrer l'image
|
||||||
|
)
|
||||||
|
}
|
||||||
|
"video" -> {
|
||||||
|
Text(
|
||||||
|
text = "Ici une video ..." + contenu.toString(),
|
||||||
|
fontSize = 15.sp,
|
||||||
|
textAlign = TextAlign.Start
|
||||||
|
)
|
||||||
|
|
||||||
|
VideoPlayer(videoUrl = contenu.lien)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ContenuParagraphe -> {
|
||||||
|
Text(text = contenu.titre, fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
||||||
|
Text(text = contenu.texte, fontSize = 16.sp, textAlign = TextAlign.Start)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
|
import com.google.android.exoplayer2.MediaItem
|
||||||
|
import com.google.android.exoplayer2.ui.PlayerView
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VideoPlayer(videoUrl : String){
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
val player = ExoPlayer.Builder(context).build()
|
||||||
|
|
||||||
|
val playerView = PlayerView(context).apply {
|
||||||
|
layoutParams = ViewGroup.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val mediaItem = MediaItem.Builder()
|
||||||
|
.setUri(videoUrl)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
player.setMediaItem(mediaItem)
|
||||||
|
player.prepare()
|
||||||
|
player.play()
|
||||||
|
|
||||||
|
AndroidView(
|
||||||
|
factory = { context -> playerView },
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
update = { view ->
|
||||||
|
view.player = player
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.example.veraxapplication.ui.connexion
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextField
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.example.veraxapplication.modele.user.User
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AfficherForm(users : List<User>) {
|
||||||
|
var pseudo = "DEFAULT"
|
||||||
|
var mdp = "DEFAULT"
|
||||||
|
Column {
|
||||||
|
TextField(value = "Pseudo", onValueChange = { value -> pseudo = value }, modifier = Modifier.padding(5.dp))
|
||||||
|
TextField(value = "Mot de passe", onValueChange = { value -> mdp = value }, modifier = Modifier.padding(5.dp))
|
||||||
|
for (u in users) {
|
||||||
|
Text(text = u.pseudo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
package com.example.veraxapplication.ui.topBar
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
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.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
import androidx.compose.material.icons.filled.Menu
|
||||||
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||||
|
import androidx.compose.material3.DropdownMenu
|
||||||
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.colorResource
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import com.example.veraxapplication.R
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import com.example.veraxapplication.navigation.VeraxNavHost
|
||||||
|
import com.example.veraxapplication.ui.theme.Orange
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun TopBarVerax(theme: List<String>, articles: List<Article>, articlesStub : List<Article>) {
|
||||||
|
/*var leMenu by remember { mutableStateOf(false) }*/
|
||||||
|
|
||||||
|
val navController = rememberNavController()
|
||||||
|
|
||||||
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
|
|
||||||
|
Row( modifier = Modifier.background(Color.Blue).fillMaxSize()) {
|
||||||
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
|
CenterAlignedTopAppBar(
|
||||||
|
title = {
|
||||||
|
Text(
|
||||||
|
//text = R.string.app_name,
|
||||||
|
text= "Verax",
|
||||||
|
style = TextStyle(fontSize = 35.sp),
|
||||||
|
color = colorResource(R.color.red),
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
},
|
||||||
|
navigationIcon = { if (navBackStackEntry?.destination?.route != "accueil"){
|
||||||
|
IconButton(onClick = { navController.popBackStack() }) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.AutoMirrored.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
|
||||||
|
.border(
|
||||||
|
width = 1.dp,
|
||||||
|
color = Color.Black,
|
||||||
|
shape = RoundedCornerShape(10.dp)
|
||||||
|
)
|
||||||
|
.background(Orange)
|
||||||
|
) {
|
||||||
|
theme.sorted().forEach {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
it,
|
||||||
|
style = TextStyle(fontSize = 25.sp),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = { }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { innerPadding ->
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(innerPadding),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
|
) {
|
||||||
|
|
||||||
|
VeraxNavHost(articles = articles, navController, articlesStub= articlesStub)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">VeraxApplication</string>
|
<string name="app_name">Verax</string>
|
||||||
</resources>
|
</resources>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<network-security-config>
|
||||||
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
|
<domain includeSubdomains="true">181.214.189.133</domain>
|
||||||
|
<domain includeSubdomains="true">codefirst.iut.uca.fr/containers/Verax-verax-api</domain>
|
||||||
|
</domain-config>
|
||||||
|
</network-security-config>
|
Loading…
Reference in new issue