Merge pull request 'componentQuote' (#40) from componentQuote into master

Reviewed-on: #40
pull/41/head
Leni BEAULATON 2 months ago
commit 91307b146a

@ -6,7 +6,7 @@ import com.example.what_the_fantasy.data.model.User
class LogsUsers{ class LogsUsers{
fun logDebugDisplayUsers(users : List<User>, titleLog : String){ fun logDebugDisplayUsers(users : List<User>, titleLog : String){
for(user in users){ for(user in users){
Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.imgUrl}") Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.imgUrl} => ${user.language}")
} }
} }

@ -1,6 +1,8 @@
package com.example.what_the_fantasy.data.local package com.example.what_the_fantasy.data.local
import com.example.what_the_fantasy.data.model.Quote import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.data.model.SrcLanguage
import com.example.what_the_fantasy.data.model.SrcType
object QuoteStub { object QuoteStub {
@ -8,181 +10,221 @@ object QuoteStub {
id = 1, id = 1,
content = "All we have to decide is what to do with the time that is given us.", content = "All we have to decide is what to do with the time that is given us.",
likes = 466, likes = 466,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.gandalf.name, character = CharacterStub.gandalf.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
date = 2000,
type = SrcType.Movie,
imgUrl = CharacterStub.gandalf.imgUrl imgUrl = CharacterStub.gandalf.imgUrl
) )
val quote2 = Quote( val quote2 = Quote(
id = 2, id = 2,
content = "A wizard is never late, nor is he early, he arrives precisely when he means to.", content = "A wizard is never late, nor is he early, he arrives precisely when he means to.",
likes = 467, likes = 467,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.gandalf.name, character = CharacterStub.gandalf.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
imgUrl = CharacterStub.gandalf.imgUrl imgUrl = CharacterStub.gandalf.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote3 = Quote( val quote3 = Quote(
id = 3, id = 3,
content = "Even the smallest person can change the course of the future.", content = "Even the smallest person can change the course of the future.",
likes = 466, likes = 466,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.galadriel.name, character = CharacterStub.galadriel.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
imgUrl = CharacterStub.galadriel.imgUrl imgUrl = CharacterStub.galadriel.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote4 = Quote( val quote4 = Quote(
id = 4, id = 4,
content = "I would rather share one lifetime with you than face all the ages of this world alone.", content = "I would rather share one lifetime with you than face all the ages of this world alone.",
likes = 120, likes = 120,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.arwen.name, character = CharacterStub.arwen.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
imgUrl = CharacterStub.arwen.imgUrl imgUrl = CharacterStub.arwen.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote5 = Quote( val quote5 = Quote(
id = 5, id = 5,
content = "Faithless is he that says farewell when the road darkens.", content = "Faithless is he that says farewell when the road darkens.",
likes = 150, likes = 150,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.gimli.name, character = CharacterStub.gimli.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
imgUrl = CharacterStub.gimli.imgUrl imgUrl = CharacterStub.gimli.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote6 = Quote( val quote6 = Quote(
id = 6, id = 6,
content = "It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to.", content = "It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to.",
likes = 200, likes = 200,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.frodoBaggins.name, character = CharacterStub.frodoBaggins.name,
source = "The Lord of the Rings: The Fellowship of the Ring", source = "The Lord of the Rings: The Fellowship of the Ring",
imgUrl = CharacterStub.frodoBaggins.imgUrl imgUrl = CharacterStub.frodoBaggins.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote7 = Quote( val quote7 = Quote(
id = 7, id = 7,
content = "I am no man.", content = "I am no man.",
likes = 300, likes = 300,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.eowyn.name, character = CharacterStub.eowyn.name,
source = "The Lord of the Rings: The Return of the King", source = "The Lord of the Rings: The Return of the King",
imgUrl = CharacterStub.eowyn.imgUrl imgUrl = CharacterStub.eowyn.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote8 = Quote( val quote8 = Quote(
id = 8, id = 8,
content = "The world is changed. I feel it in the water. I feel it in the earth. I smell it in the air.", content = "The world is changed. I feel it in the water. I feel it in the earth. I smell it in the air.",
likes = 400, likes = 400,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.treebeard.name, character = CharacterStub.treebeard.name,
source = "The Lord of the Rings: The Two Towers", source = "The Lord of the Rings: The Two Towers",
imgUrl = CharacterStub.treebeard.imgUrl imgUrl = CharacterStub.treebeard.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote9 = Quote( val quote9 = Quote(
id = 9, id = 9,
content = "We wants it, we needs it. Must have the precious.", content = "We wants it, we needs it. Must have the precious.",
likes = 500, likes = 500,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.gollum.name, character = CharacterStub.gollum.name,
source = "The Lord of the Rings: The Two Towers", source = "The Lord of the Rings: The Two Towers",
imgUrl = CharacterStub.gollum.imgUrl imgUrl = CharacterStub.gollum.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote10 = Quote( val quote10 = Quote(
id = 10, id = 10,
content = "The board is set, the pieces are moving. We come to it at last, the great battle of our time.", content = "The board is set, the pieces are moving. We come to it at last, the great battle of our time.",
likes = 600, likes = 600,
language = "en", language = SrcLanguage.vo,
character = CharacterStub.gandalf.name, character = CharacterStub.gandalf.name,
source = "The Lord of the Rings: The Return of the King", source = "The Lord of the Rings: The Return of the King",
imgUrl = CharacterStub.gandalf.imgUrl imgUrl = CharacterStub.gandalf.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote11 = Quote( val quote11 = Quote(
id = 11, id = 11,
content = "Un grand pouvoir implique de grandes responsabilités.", content = "Un grand pouvoir implique de grandes responsabilités.",
likes = 466, likes = 466,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.aragorn.name, character = CharacterStub.aragorn.name,
source = "Spider-Man", source = "Spider-Man",
imgUrl = CharacterStub.aragorn.imgUrl imgUrl = CharacterStub.aragorn.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote12 = Quote( val quote12 = Quote(
id = 12, id = 12,
content = "Que la Force soit avec toi.", content = "Que la Force soit avec toi.",
likes = 467, likes = 467,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.legolas.name, character = CharacterStub.legolas.name,
source = "Star Wars", source = "Star Wars",
imgUrl = CharacterStub.legolas.imgUrl imgUrl = CharacterStub.legolas.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote13 = Quote( val quote13 = Quote(
id = 13, id = 13,
content = "La magie est partout. Il suffit de savoir où la trouver.", content = "La magie est partout. Il suffit de savoir où la trouver.",
likes = 466, likes = 466,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.gandalf.name, character = CharacterStub.gandalf.name,
source = "Harry Potter", source = "Harry Potter",
imgUrl = CharacterStub.gandalf.imgUrl imgUrl = CharacterStub.gandalf.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote14 = Quote( val quote14 = Quote(
id = 14, id = 14,
content = "Le monde est plein de choses magiques, patientant que nos sens s'aiguisent.", content = "Le monde est plein de choses magiques, patientant que nos sens s'aiguisent.",
likes = 120, likes = 120,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.frodoBaggins.name, character = CharacterStub.frodoBaggins.name,
source = "Le Seigneur des Anneaux", source = "Le Seigneur des Anneaux",
imgUrl = CharacterStub.frodoBaggins.imgUrl imgUrl = CharacterStub.frodoBaggins.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote15 = Quote( val quote15 = Quote(
id = 15, id = 15,
content = "La peur mène à la colère, la colère mène à la haine, la haine mène à la souffrance.", content = "La peur mène à la colère, la colère mène à la haine, la haine mène à la souffrance.",
likes = 150, likes = 150,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.gimli.name, character = CharacterStub.gimli.name,
source = "Star Wars", source = "Star Wars",
imgUrl = CharacterStub.gimli.imgUrl imgUrl = CharacterStub.gimli.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote16 = Quote( val quote16 = Quote(
id = 16, id = 16,
content = "La vie est une aventure audacieuse ou rien du tout.", content = "La vie est une aventure audacieuse ou rien du tout.",
likes = 200, likes = 200,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.galadriel.name, character = CharacterStub.galadriel.name,
source = "Helen Keller", source = "Helen Keller",
imgUrl = CharacterStub.galadriel.imgUrl imgUrl = CharacterStub.galadriel.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote17 = Quote( val quote17 = Quote(
id = 17, id = 17,
content = "Le courage n'est pas l'absence de peur, mais la capacité de vaincre ce qui fait peur.", content = "Le courage n'est pas l'absence de peur, mais la capacité de vaincre ce qui fait peur.",
likes = 300, likes = 300,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.boromir.name, character = CharacterStub.boromir.name,
source = "Nelson Mandela", source = "Nelson Mandela",
imgUrl = CharacterStub.boromir.imgUrl imgUrl = CharacterStub.boromir.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote18 = Quote( val quote18 = Quote(
id = 18, id = 18,
content = "La folie, c'est de faire toujours la même chose et de s'attendre à un résultat différent.", content = "La folie, c'est de faire toujours la même chose et de s'attendre à un résultat différent.",
likes = 400, likes = 400,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.eowyn.name, character = CharacterStub.eowyn.name,
source = "Albert Einstein", source = "Albert Einstein",
imgUrl = CharacterStub.eowyn.imgUrl imgUrl = CharacterStub.eowyn.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote19 = Quote( val quote19 = Quote(
id = 19, id = 19,
content = "Le bonheur n'est pas quelque chose de tout fait. Il vient de vos propres actions.", content = "Le bonheur n'est pas quelque chose de tout fait. Il vient de vos propres actions.",
likes = 500, likes = 500,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.saruman.name, character = CharacterStub.saruman.name,
source = "Dalaï Lama", source = "Dalaï Lama",
imgUrl = CharacterStub.saruman.imgUrl imgUrl = CharacterStub.saruman.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val quote20 = Quote( val quote20 = Quote(
id = 20, id = 20,
content = "La vie est un mystère qu'il faut vivre, et non un problème à résoudre.", content = "La vie est un mystère qu'il faut vivre, et non un problème à résoudre.",
likes = 600, likes = 600,
language = "fr", language = SrcLanguage.fr,
character = CharacterStub.samwiseGamgee.name, character = CharacterStub.samwiseGamgee.name,
source = "Gandhi", source = "Gandhi",
imgUrl = CharacterStub.samwiseGamgee.imgUrl imgUrl = CharacterStub.samwiseGamgee.imgUrl,
date = 2000,
type = SrcType.Movie,
) )
val allQuotes: List<Quote> = listOf( val allQuotes: List<Quote> = listOf(

@ -1,40 +1,23 @@
package com.example.what_the_fantasy.data.local package com.example.what_the_fantasy.data.local
import com.example.what_the_fantasy.data.model.SrcLanguage
import com.example.what_the_fantasy.data.model.User import com.example.what_the_fantasy.data.model.User
object UserStub { object UserStub {
//LE MOT DE PASSE POUR TOUS LES UTILISATEURS EST : 1234 //LE MOT DE PASSE POUR TOUS LES UTILISATEURS EST : 1234
val users: MutableList<User> = mutableListOf( val users: MutableList<User> = mutableListOf(
User(1, "Aragorn123", "aragorn@example.com", "2022-01-15", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-fantaisie_1045-185.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"), //1234 User(1, "Aragorn123", "aragorn@example.com", "2022-01-15", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-fantaisie_1045-185.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.fr), //1234
User(2, "Legolas456", "legolas@example.com", "2021-05-23", "https://img.freepik.com/vecteurs-libre/personnage-elfe-fantaisie_1045-186.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(2, "Legolas456", "legolas@example.com", "2021-05-23", "https://img.freepik.com/vecteurs-libre/personnage-elfe-fantaisie_1045-186.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.fr),//1234
User(3, "Gandalf789", "gandalf@example.com", "2020-09-10", "https://img.freepik.com/vecteurs-libre/personnage-magicien-fantaisie_1045-187.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(3, "Gandalf789", "gandalf@example.com", "2020-09-10", "https://img.freepik.com/vecteurs-libre/personnage-magicien-fantaisie_1045-187.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.fr),//1234
User(4, "FrodoBaggins", "frodo@example.com", "2023-03-18", "https://img.freepik.com/vecteurs-libre/personnage-hobbit-fantaisie_1045-188.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(4, "FrodoBaggins", "frodo@example.com", "2023-03-18", "https://img.freepik.com/vecteurs-libre/personnage-hobbit-fantaisie_1045-188.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.fr),//1234
User(5, "Gimli999", "gimli@example.com", "2022-07-04", "https://img.freepik.com/vecteurs-libre/personnage-nain-fantaisie_1045-189.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(5, "Gimli999", "gimli@example.com", "2022-07-04", "https://img.freepik.com/vecteurs-libre/personnage-nain-fantaisie_1045-189.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(6, "Galadriel321", "galadriel@example.com", "2021-11-30", "https://img.freepik.com/vecteurs-libre/personnage-elfe-femme-fantaisie_1045-190.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(6, "Galadriel321", "galadriel@example.com", "2021-11-30", "https://img.freepik.com/vecteurs-libre/personnage-elfe-femme-fantaisie_1045-190.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(7, "Boromir654", "boromir@example.com", "2023-06-22", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-191.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(7, "Boromir654", "boromir@example.com", "2023-06-22", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-191.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(8, "Eowyn777", "eowyn@example.com", "2022-04-11", "https://img.freepik.com/vecteurs-libre/personnage-guerriere-femme-fantaisie_1045-192.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(8, "Eowyn777", "eowyn@example.com", "2022-04-11", "https://img.freepik.com/vecteurs-libre/personnage-guerriere-femme-fantaisie_1045-192.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(9, "Saruman888", "saruman@example.com", "2021-08-15", "https://img.freepik.com/vecteurs-libre/personnage-magicien-malefique-fantaisie_1045-193.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(9, "Saruman888", "saruman@example.com", "2021-08-15", "https://img.freepik.com/vecteurs-libre/personnage-magicien-malefique-fantaisie_1045-193.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(10, "Faramir222", "faramir@example.com", "2023-02-08", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"),//1234 User(10, "Faramir222", "faramir@example.com", "2023-02-08", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.vo),//1234
User(11, "dev", "testeur@example.com", "2023-02-08", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4")//1234 User(11, "dev", "testeur@example.com", "2023-02-08", "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg", "03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", SrcLanguage.fr)//1234
) )
fun addUser(user: User) {
users.add(user)
}
//
// // Modifier un utilisateur
// fun updateUser(id: Int, updatedUser: User) {
// val index = users.indexOfFirst { it.id == id }
// if (index != -1) {
// users[index] = updatedUser
// }
// }
//
// // Supprimer un utilisateur
// fun removeUser(id: Int) {
// users.removeAll { it.id == id }
// }
//
} }

@ -1,11 +1,16 @@
package com.example.what_the_fantasy.data.model package com.example.what_the_fantasy.data.model
import java.util.Date
data class Quote ( data class Quote (
val id: Int, val id: Int,
val content: String, val content: String,
val likes: Int, val likes: Int,
val language: String, val language: SrcLanguage,
val character: String, val character: String,
val source: String, val source: String,
val imgUrl: String val imgUrl: String,
val type: SrcType,
val date: Int
) )

@ -0,0 +1,6 @@
package com.example.what_the_fantasy.data.model
enum class SrcLanguage {
fr,
vo
}

@ -6,5 +6,6 @@ class User(
var email:String, var email:String,
var date:String, var date:String,
val imgUrl: String, val imgUrl: String,
var password: String var password: String,
val language : SrcLanguage
) )

@ -6,6 +6,7 @@ import com.example.what_the_fantasy.data.local.UserStub
import com.example.what_the_fantasy.data.local.UserStub.users import com.example.what_the_fantasy.data.local.UserStub.users
import com.example.what_the_fantasy.data.model.User import com.example.what_the_fantasy.data.model.User
import com.example.what_the_fantasy.Logs.LogsUsers import com.example.what_the_fantasy.Logs.LogsUsers
import com.example.what_the_fantasy.data.model.SrcLanguage
import com.example.what_the_fantasy.ui.components.hashPassword import com.example.what_the_fantasy.ui.components.hashPassword
import java.time.LocalDate import java.time.LocalDate
@ -52,7 +53,7 @@ class ServicesStub : IServices {
return false return false
} }
} }
val user = User(nbUser+1,username, email, date,randomImage(userStub), passwordhash) val user = User(nbUser+1,username, email, date,randomImage(userStub), passwordhash, SrcLanguage.vo)
users.add(user)//ajout au stub users.add(user)//ajout au stub
//Afficher tous les users //Afficher tous les users

@ -0,0 +1,68 @@
package com.example.what_the_fantasy.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.ui.theme.gradienBox
@Composable
fun LittleQuoteComponent(quote : Quote){
Row(
modifier = Modifier
.fillMaxWidth(0.9f)
.clip(RoundedCornerShape(16.dp))
.background(gradienBox)
) {
val sizeTextInfoQuote = 13
val lineHeightText = 12
val sizeTextQuote = 16
AsyncImage(
model = quote.imgUrl,
contentDescription = "Quote picture",
modifier = Modifier
.size(130.dp)
.clip(RoundedCornerShape(16.dp))
)
Column(modifier = Modifier.padding(10.dp)) {
TextInfoQuote(
quote.content,
sizeTextQuote,
lineHeightText
)
SpaceHeightComponent(40)
TextInfoQuote("${stringResource(R.string.dateQuote)} : ${quote.date}", sizeTextInfoQuote, lineHeightText)
TextInfoQuote("${quote.type} : ${quote.source}", sizeTextInfoQuote, lineHeightText)
TextInfoQuote("${stringResource(R.string.CharacterQuote)}: ${quote.character}", sizeTextInfoQuote, lineHeightText)
}
}
}
@Composable
fun TextInfoQuote(text : String, fontSizeText : Int, lineHeightText : Int){
Text(text,
color = Color.White,
fontSize = fontSizeText.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
lineHeight = lineHeightText.sp)
}

@ -1,21 +1,28 @@
package com.example.what_the_fantasy.ui.components package com.example.what_the_fantasy.ui.components
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight 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 androidx.compose.ui.unit.sp
@Composable @Composable
fun TitlePageComponent(titleResId : Int, size : Int, color : Color) { fun TitlePageComponent(titleResId: Int, color: Color) {
val title = stringResource(id = titleResId) val title = stringResource(id = titleResId)
Text( Text(
text = title, text = title,
fontSize = size.sp, fontSize = 20.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = color color = color,
textAlign = TextAlign.Center,
) )
} }

@ -3,37 +3,33 @@ package com.example.what_the_fantasy.ui.screens
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Text import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.what_the_fantasy.R import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.services.IServices import com.example.what_the_fantasy.data.local.QuoteStub
import com.example.what_the_fantasy.ui.components.LittleQuoteComponent
import com.example.what_the_fantasy.ui.components.NavBar import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.SpaceHeightComponent
import com.example.what_the_fantasy.ui.components.TitlePageComponent import com.example.what_the_fantasy.ui.components.TitlePageComponent
import com.example.what_the_fantasy.ui.theme.colorBackground import com.example.what_the_fantasy.ui.theme.colorBackground
import com.example.what_the_fantasy.ui.theme.gradienBox
@Composable @Composable
fun FavoritePage( fun FavoritePage(
index: Int, index: Int,
navAccueil: (Int) -> Unit, navAccueil: (Int) -> Unit,
navQuiz: (Int) -> Unit, navQuiz: (Int) -> Unit,
navProfil:(Int) -> Unit navProfil: (Int) -> Unit
) { ) {
NavBar(onFavorite = true, NavBar(
onFavorite = true,
index = index, index = index,
navControllerFavorite = { }, navControllerFavorite = { },
navControllerAccueil = navAccueil, navControllerAccueil = navAccueil,
@ -45,28 +41,29 @@ fun FavoritePage(
.fillMaxSize() .fillMaxSize()
.background(colorBackground), .background(colorBackground),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
){
Column {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFF100C1B)),
contentAlignment = Alignment.Center
) { ) {
Row( Column(modifier = Modifier
.padding(top = 20.dp),
horizontalAlignment = Alignment.CenterHorizontally) {
TitlePageComponent(R.string.TitleFavorite, Color.White)
LazyColumn(
modifier = Modifier modifier = Modifier
.fillMaxWidth(0.9f) .fillMaxSize()
.padding(20.dp) .background(Color(0xFF100C1B))
.clip(RoundedCornerShape(16.dp)) .padding(top = 16.dp),
.background(gradienBox) horizontalAlignment = Alignment.CenterHorizontally
.padding(20.dp),
) { ) {
Text("Une image") items(QuoteStub.allQuotes) { quote ->
Text("Une citation d'un personnage") LittleQuoteComponent(quote)
Spacer(modifier = Modifier.height(16.dp))
} }
} }
} }
} }
} }
} }

@ -73,8 +73,8 @@ fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Uni
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
TitlePageComponent(R.string.titleLogin, 20,Color.White) TitlePageComponent(R.string.titleLogin, Color.White)
SpaceHeightComponent(16) SpaceHeightComponent(20)
ConnexionButtonLogin(users,IdentifiantTextField(R.string.IdentifiantLogin), PassWdTextField(R.string.PasswdLogin), R.string.ButtonLogin,18, Color.White, Color.Black,navControllerProfil) ConnexionButtonLogin(users,IdentifiantTextField(R.string.IdentifiantLogin), PassWdTextField(R.string.PasswdLogin), R.string.ButtonLogin,18, Color.White, Color.Black,navControllerProfil)
SpaceHeightComponent(16) SpaceHeightComponent(16)
CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp) CreateAccountButton(R.string.ButtonCreateLogin,12, Color.White, navControllerSignUp)
@ -109,7 +109,7 @@ fun PassWdTextField(textpasswdResId : Int) : String{
val textpasswd = stringResource(id = textpasswdResId) val textpasswd = stringResource(id = textpasswdResId)
var passwd by remember { mutableStateOf("") } // Stocke la valeur du champ var passwd by remember { mutableStateOf("") } // Stocke la valeur du champ
var passwordVisible by remember { mutableStateOf(false) } // État pour afficher/masquer var passwordVisible by remember { mutableStateOf(false) } // État pour afficher/masquer
Column(modifier = Modifier.padding(top = 10.dp)) { Column(modifier = Modifier.padding(top = 10.dp, bottom = 30.dp)) {
OutlinedTextField( OutlinedTextField(
value = passwd, value = passwd,
onValueChange = { passwd = it }, onValueChange = { passwd = it },
@ -156,13 +156,11 @@ fun validLogin(identifiant : String, passwd : String, users : List<User>, navCon
users.forEachIndexed { index, user -> users.forEachIndexed { index, user ->
val hashPassWd = hashPassword(passwd) val hashPassWd = hashPassword(passwd)
if (user.username == identifiant && user.password == hashPassWd) { if (user.username == identifiant && user.password == hashPassWd) {
// Utilise l'index pour naviguer à la position correspondante
navController(index) // Passer l'index à la fonction navController navController(index) // Passer l'index à la fonction navController
return true return true
} }
} }
return false return false
} }
@Composable @Composable

@ -108,7 +108,7 @@ fun ProfilPage(index: Int,
) { ) {
// Titre // Titre
TitlePageComponent(R.string.titleProfile, 20, Color.White) TitlePageComponent(R.string.titleProfile, Color.White)
SpaceHeightComponent(16) SpaceHeightComponent(16)
// Image de profil // Image de profil

@ -77,7 +77,7 @@ fun SignUpPage(navControllerLogin: () -> Unit, services : IServices) {
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
TitlePageComponent(R.string.titleSignUp, 20,Color.White) TitlePageComponent(R.string.titleSignUp,Color.White)
IdentifiantTextFieldSign(R.string.IdentifiantLogin,identifiant = username,onValueChange = { username = it }) IdentifiantTextFieldSign(R.string.IdentifiantLogin,identifiant = username,onValueChange = { username = it })
EmailTextFieldSign(R.string.EmailSignUp, email, onValueChange = { email = it }) EmailTextFieldSign(R.string.EmailSignUp, email, onValueChange = { email = it })
PassWdTextFieldSign(R.string.PasswdLogin,password, onValueChange = { password = it },passwordVisible,onPasswordVisibilityChange = { passwordVisible = !passwordVisible }) PassWdTextFieldSign(R.string.PasswdLogin,password, onValueChange = { password = it },passwordVisible,onPasswordVisibilityChange = { passwordVisible = !passwordVisible })

@ -34,4 +34,13 @@
<string name="ButtonSaveprofile">Sauvegarder</string> <string name="ButtonSaveprofile">Sauvegarder</string>
<string name="ErrorEmailprofile">L\'adress email est invalide</string> <string name="ErrorEmailprofile">L\'adress email est invalide</string>
<string name="Errorpasswdprofile">Les mots de passe ne correspondent pas</string> <string name="Errorpasswdprofile">Les mots de passe ne correspondent pas</string>
//Component quote
<string name="dateQuote">Date</string>
<string name="CharacterQuote">Personnage</string>
//Page Favori
<string name="TitleFavorite">Favoris</string>
</resources> </resources>

@ -34,4 +34,11 @@
<string name="ErrorEmailprofile">Invalid email address</string> <string name="ErrorEmailprofile">Invalid email address</string>
<string name="Errorpasswdprofile">Passwords do not match</string> <string name="Errorpasswdprofile">Passwords do not match</string>
//Component quote
<string name="dateQuote">Date</string>
<string name="CharacterQuote">Character</string>
//Page Favori
<string name="TitleFavorite">Favorites</string>
</resources> </resources>
Loading…
Cancel
Save