StubRefontFavori #47

Merged
leni.beaulaton merged 2 commits from StubRefontFavori into master 1 month ago

@ -1,27 +1,21 @@
package com.example.what_the_fantasy.data.local
import com.example.what_the_fantasy.data.local.QuoteStub.quotes
import com.example.what_the_fantasy.data.local.UserStub.users
import com.example.what_the_fantasy.data.model.Favorite
import com.example.what_the_fantasy.data.model.Quote
object FavoriteStub {
val favorites: MutableList<Favorite> = mutableListOf(
Favorite(UserStub.users[0], QuoteStub.quote1),
Favorite(UserStub.users[1], QuoteStub.quote12),
Favorite(UserStub.users[2], QuoteStub.quote13),
Favorite(UserStub.users[3], QuoteStub.quote6),
Favorite(UserStub.users[4], QuoteStub.quote5),
Favorite(UserStub.users[5], QuoteStub.quote3),
Favorite(UserStub.users[6], QuoteStub.quote17),
Favorite(UserStub.users[7], QuoteStub.quote7),
Favorite(UserStub.users[8], QuoteStub.quote19),
Favorite(UserStub.users[9], QuoteStub.quote20),
Favorite(UserStub.users[10], QuoteStub.quote11)
Favorite(users[0], mutableListOf(quotes[0], quotes[0], quotes[0])), // Aragorn123 aime ces citations
Favorite(users[1], mutableListOf(quotes[5], quotes[6], quotes[7])), // Legolas456 aime ces citations
Favorite(users[2], mutableListOf(quotes[8], quotes[9], quotes[10])), // Gandalf789 aime ces citations
Favorite(users[3], mutableListOf(quotes[11], quotes[12], quotes[13])), // FrodoBaggins aime ces citations
Favorite(users[4], mutableListOf(quotes[14], quotes[15], quotes[16])), // Gimli999 aime ces citations
Favorite(users[5], mutableListOf(quotes[17], quotes[18], quotes[19])), // Galadriel321 aime ces citations
Favorite(users[6], mutableListOf(quotes[17], quotes[2], quotes[7])), // Boromir654 aime ces citations
Favorite(users[7], mutableListOf(quotes[3], quotes[4], quotes[10])), // Eowyn777 aime ces citations
Favorite(users[8], mutableListOf(quotes[6], quotes[8], quotes[9])), // Saruman888 aime ces citations
Favorite(users[9], mutableListOf(quotes[5], quotes[13], quotes[15])), // Faramir222 aime ces citations
Favorite(users[10], mutableListOf(quotes[12], quotes[17], quotes[16])) // dev aime ces citations
)
fun getFavoritesByUser(userId: Int): List<Quote> {
return favorites
.filter { it.user.id == userId }
.map { it.quote }
}
}

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

@ -6,10 +6,10 @@ import com.example.what_the_fantasy.data.model.User
object UserStub {
//LE MOT DE PASSE POUR TOUS LES UTILISATEURS EST : 1234
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", 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", 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", 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", SrcLanguage.fr),//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.vf), //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.vf),//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.vf),//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.vf),//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", 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", SrcLanguage.vo),//1234

@ -2,5 +2,5 @@ package com.example.what_the_fantasy.data.model
class Favorite (
val user: User,
val quote: Quote
val quote: List<Quote>
)

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

@ -1,5 +1,6 @@
package com.example.what_the_fantasy.data.services
import com.example.what_the_fantasy.data.model.Favorite
import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.data.model.User
@ -11,7 +12,7 @@ interface IServices {
fun ChangeLangage(user: User)
fun CreateUser(username : String, email : String, passwd : String, services : IServices) : Boolean
fun getFavorite(username: String)
fun getFavorite(user: User): List<Quote>
fun getAllUsers(): List<User>
fun getUserById(id: Int): User?
@ -21,5 +22,6 @@ interface IServices {
fun getQuote( id : Int): Quote?
fun isFavorite(id : Int): Boolean
fun getAllFavorite(): List<Favorite>
fun getAllQuote(): List<Quote>
}

@ -1,54 +1,64 @@
package com.example.what_the_fantasy.data.services
import com.example.what_the_fantasy.data.model.Favorite
import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.data.model.User
class ServicesAPI : IServices {
override fun EditUsername(username: String, index : Int) : Boolean {
TODO("Not yet implemented")
}
//class ServicesAPI : IServices {
// override fun EditUsername(username: String, index : Int) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun EditEmail(email: String, index : Int) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun EditPasswd(passwd: String, index : Int) {
// TODO("Not yet implemented")
// }
//
// override fun EditImage(imageURL: String, index : Int) {
// TODO("Not yet implemented")
// }
//
// override fun ChangeLangage(user: User) {
// TODO("Not yet implemented")
// }
//
// override fun CreateUser(username: String, email: String, passwd: String, services: IServices) : Boolean {
// TODO("Not yet implemented")
// }
//
// override fun SearchQuote(quote: String) {
// TODO("Not yet implemented")
// }
//
// override fun getQuote(id: Int): Quote? {
// TODO("Not yet implemented")
// }
//
// override fun isFavorite(id: Int): Boolean {
// TODO("Not yet implemented")
// }
//
// override fun getAllFavorite(): List<Favorite> {
// TODO("Not yet implemented")
// }
override fun EditEmail(email: String, index : Int) : Boolean {
TODO("Not yet implemented")
}
override fun EditPasswd(passwd: String, index : Int) {
TODO("Not yet implemented")
}
override fun EditImage(imageURL: String, index : Int) {
TODO("Not yet implemented")
}
override fun ChangeLangage(user: User) {
TODO("Not yet implemented")
}
override fun CreateUser(username: String, email: String, passwd: String, services: IServices) : Boolean {
TODO("Not yet implemented")
}
override fun SearchQuote(quote: String) {
TODO("Not yet implemented")
}
override fun getQuote(id: Int): Quote? {
TODO("Not yet implemented")
}
override fun isFavorite(id: Int): Boolean {
TODO("Not yet implemented")
}
override fun getFavorite(username: String) {
TODO("Not yet implemented")
}
override fun getAllUsers(): List<User> {
TODO("Not yet implemented")
}
override fun getUserById(id: Int): User? {
TODO("Not yet implemented")
}
}
// override fun getAllQuote(): List<Quote> {
// TODO("Not yet implemented")
// }
//
// override fun getFavorite(user: User): Favorite {
// TODO("Not yet implemented")
// }
//
// override fun getAllUsers(): List<User> {
// TODO("Not yet implemented")
// }
//
// override fun getUserById(id: Int): User? {
// TODO("Not yet implemented")
// }
//
//}

@ -4,7 +4,9 @@ import android.annotation.SuppressLint
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.Logs.LogsUsers
import com.example.what_the_fantasy.data.local.QuoteStub
import com.example.what_the_fantasy.data.local.FavoriteStub.favorites
import com.example.what_the_fantasy.data.local.QuoteStub.quotes
import com.example.what_the_fantasy.data.model.Favorite
import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.data.model.SrcLanguage
import com.example.what_the_fantasy.ui.components.hashPassword
@ -53,7 +55,7 @@ class ServicesStub : IServices {
override fun ChangeLangage(user: User) {
if(user.langage == SrcLanguage.vo){
user.langage = SrcLanguage.fr
user.langage = SrcLanguage.vf
}
else{
user.langage = SrcLanguage.vo
@ -79,6 +81,14 @@ class ServicesStub : IServices {
return false
}
override fun getFavorite(user: User): List<Quote> {
val favorite = favorites
return favorite[0].quote
//return emptyList()
}
override fun getAllFavorite(): List<Favorite> = favorites
override fun getAllQuote(): List<Quote> = quotes
override fun getAllUsers(): List<User> = users
override fun getUserById(id: Int): User? {
@ -90,16 +100,14 @@ class ServicesStub : IServices {
}
override fun getQuote(id: Int): Quote? {
return (QuoteStub.allQuotes.find { it.id == id })
return (quotes.find { it.id == id+1 })
}
override fun isFavorite(id: Int): Boolean {
TODO("Not yet implemented")
}
override fun getFavorite(username: String) {
TODO("Not yet implemented")
}
//------------------------------------------------------

@ -17,7 +17,6 @@ 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.data.local.DailyQuoteStub
import com.example.what_the_fantasy.data.local.QuoteStub
import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.QuoteLittle
@ -35,7 +34,7 @@ fun AccueilPage(
) {
var itemCount by remember { mutableStateOf(15) }
val dailyQuote = DailyQuoteStub.dailyQuote
val quotes = QuoteStub.allQuotes.take(itemCount)
val quotes = services.getAllQuote().take(itemCount)
val user = services.getUserById(index) ?: return
val titleDalyQuote = stringResource(R.string.TitleHomeDailyQuote)
@ -88,7 +87,7 @@ fun AccueilPage(
}
}
}
if (itemCount < QuoteStub.allQuotes.size) {
if (itemCount < quotes.size) {
item {
LaunchedEffect(itemCount) {
itemCount += 15

@ -1,5 +1,6 @@
package com.example.what_the_fantasy.ui.screens
import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
@ -31,7 +32,9 @@ fun FavoritePage(
services: IServices
) {
val user = services.getUserById(index) ?: return
val quotes = FavoriteStub.getFavoritesByUser(user.id)
val quotes = services.getFavorite(user)
val TitlePage = stringResource(R.string.TitleFavorite)
NavBar(onFavorite = true,
index = index,
@ -61,7 +64,6 @@ fun FavoritePage(
items(quotes) { quote ->
Column(Modifier.clickable { navQuote(quote.id) }) {
QuoteLittle(quote)
Spacer(modifier = Modifier.height(16.dp))
}
}

Loading…
Cancel
Save