Compare commits
5 Commits
master
...
navigation
Author | SHA1 | Date |
---|---|---|
![]() |
d331cac022 | 1 year ago |
|
af3ff9dacc | 1 year ago |
![]() |
5cfc57e864 | 1 year ago |
![]() |
b69f2bf3ea | 1 year ago |
![]() |
2d231a4402 | 1 year ago |
@ -1,63 +1,49 @@
|
|||||||
package com.example.veraxapplication
|
package com.example.veraxapplication
|
||||||
|
|
||||||
import ArticlesViewModel
|
|
||||||
import IUsersDataManager
|
|
||||||
import StubUsers
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.runtime.getValue
|
import com.example.veraxapplication.articles.IArticlesDataManager
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
||||||
import com.example.veraxapplication.modele.IArticlesDataManager
|
|
||||||
import com.example.veraxapplication.articles.StubArticles
|
import com.example.veraxapplication.articles.StubArticles
|
||||||
import com.example.veraxapplication.modele.api.UsersViewModel
|
import com.example.veraxapplication.modele.ApiClient
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
import com.example.veraxapplication.navigation.VeraxNavHost
|
import com.example.veraxapplication.navigation.VeraxNavHost
|
||||||
import com.example.veraxapplication.ui.connexion.AfficherForm
|
import com.example.veraxapplication.ui.article.AfficherArticle
|
||||||
import com.example.veraxapplication.ui.topBar.TopBarVerax
|
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() {
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContent {
|
|
||||||
VeraxContent()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
class MainActivity : ComponentActivity() {
|
||||||
fun VeraxContent() {
|
|
||||||
|
|
||||||
|
// 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"))))
|
||||||
|
|
||||||
// Initialiser les données ou observer les données du ViewModel
|
|
||||||
var dataManager: IArticlesDataManager = StubArticles()
|
var dataManager: IArticlesDataManager = StubArticles()
|
||||||
var articles = dataManager.getDerniersArticles(4)
|
var articles = dataManager.getDerniersArticles(4)
|
||||||
|
val articlesApi = ApiClient.apiService.getArticles()
|
||||||
|
|
||||||
var usersManager: IUsersDataManager = StubUsers()
|
|
||||||
var users = usersManager.getUsers();
|
|
||||||
|
|
||||||
// Observer les données du ViewModel
|
var theme = listOf("Economique", "Culture", "Politique", "Faits divers")
|
||||||
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)
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContent {
|
||||||
|
|
||||||
|
|
||||||
var theme = listOf("Economique", "Culture", "Politique", "Faits divers")
|
// TopBarVerax(theme = theme, articles = articlesApi)
|
||||||
|
TopBarVerax(theme = theme, articles = articles)
|
||||||
|
|
||||||
|
// VeraxNavHost()
|
||||||
|
|
||||||
TopBarVerax(articles = articlesApi, theme = theme, articlesStub= articles)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
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
|
|
||||||
)
|
|
||||||
*/
|
|
@ -1,6 +0,0 @@
|
|||||||
package com.example.veraxapplication.data
|
|
||||||
/*
|
|
||||||
data class Paragraph(
|
|
||||||
var Content : String,
|
|
||||||
)
|
|
||||||
*/
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.example.veraxapplication.modele
|
||||||
|
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
object RetrofitClient {
|
||||||
|
|
||||||
|
private const val BASE_URL = "http://181.214.189.133:9092/"
|
||||||
|
|
||||||
|
val retrofit: Retrofit by lazy {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiClient {
|
||||||
|
val apiService: ApiService by lazy {
|
||||||
|
RetrofitClient.retrofit.create(ApiService::class.java)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.example.veraxapplication.modele
|
||||||
|
|
||||||
|
import com.example.veraxapplication.modele.articles.Article
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.http.GET
|
||||||
|
|
||||||
|
interface ApiService {
|
||||||
|
@GET("articles/")
|
||||||
|
fun getArticles(): Call<List<Article>>
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
import com.example.veraxapplication.modele.user.User
|
|
||||||
|
|
||||||
|
|
||||||
interface IUsersDataManager {
|
|
||||||
val allUsers: List<Any?>?
|
|
||||||
|
|
||||||
fun getUser(pseudo : String): User?
|
|
||||||
fun getUsers(): List<User>
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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,
|
|
||||||
)
|
|
@ -1,54 +0,0 @@
|
|||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.example.veraxapplication.modele.api
|
|
||||||
|
|
||||||
import retrofit2.http.GET
|
|
||||||
|
|
||||||
interface IArticleService {
|
|
||||||
@GET("articles")
|
|
||||||
suspend fun getArticles(): List<ArticleDTO>
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
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>
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
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,44 @@
|
|||||||
|
package com.example.veraxapplication.navigation
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
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.articles.IArticlesDataManager
|
||||||
|
import com.example.veraxapplication.articles.StubArticles
|
||||||
|
//import com.example.veraxapplication.HomeScreen
|
||||||
|
|
||||||
|
//https://codefirst.iut.uca.fr/git/Kotlin_Android/Android_TP_2/src/branch/master/app/src/main/java/fr/iut/tp2/navigation/TP2NavHost.kt
|
||||||
|
@Composable
|
||||||
|
fun NavHost(){
|
||||||
|
val navController = rememberNavController()
|
||||||
|
val dataManager : IArticlesDataManager = StubArticles()
|
||||||
|
var articles = dataManager.getDerniersArticles(4)
|
||||||
|
|
||||||
|
NavHost(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
navController = navController,
|
||||||
|
startDestination = "home"
|
||||||
|
) {
|
||||||
|
|
||||||
|
composable(route = "home") {
|
||||||
|
/* HomeScreen(
|
||||||
|
//article = , //recup l article cliqué
|
||||||
|
goToArticle = {
|
||||||
|
navController.navigate("articleALaUne/${it.id}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
composable(
|
||||||
|
route = "articleALaUne/{articleId}",
|
||||||
|
arguments = navArgument("articleALaUne") { type = NavType.LongType })
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Verax</string>
|
<string name="app_name">VeraxApplication</string>
|
||||||
</resources>
|
</resources>
|
@ -1,7 +0,0 @@
|
|||||||
<?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