File tree Expand file tree Collapse file tree 4 files changed +17
-13
lines changed
composeApp/src/commonMain
kotlin/com/developersbreach/kotlindictionarymultiplatform/data/topic Expand file tree Collapse file tree 4 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ Access the latest APK for Kotlin Dictionary from the link below.
3535- [x] Add code block for syntax display on the ` Detail Screen `
3636- [ ] Implement caching on the ` Detail Screen ` to store previously viewed topic data
3737- [x] Implement dynamic topic loading in ` TopicRepository ` to support scalability
38- - [ ] Integrate Room database to persist bookmark states
38+ - [ ] Add bookmark feature for topic cards to allow users to save and revisit important topics
3939- [ ] Add a ` Home Page ` for navigation
4040- [ ] Add a ` Quiz Page ` to host topic-based quizzes
4141- [ ] Add a button in ` DetailScreen ` to attempt a quiz for that topic
Original file line number Diff line number Diff line change 2323 <string name =" topics" >Topics</string >
2424 <string name =" description_subtitle" >Description need to be added</string >
2525 <string name =" icon" >Icon</string >
26- <string name =" remove_bookmark" >Remove bookmark</string >
27- <string name =" add_bookmark" >Add bookmark</string >
2826 <string name =" search_kotlin_terms" >Search Kotlin terms...</string >
2927 <string name =" search" >Search</string >
3028</resources >
Original file line number Diff line number Diff line change @@ -3,24 +3,30 @@ package com.developersbreach.kotlindictionarymultiplatform.data.topic.model
33import kotlinx.serialization.SerialName
44import kotlinx.serialization.Serializable
55
6+ @Serializable
7+ data class TopicResponse (
8+ @SerialName(" documents" ) val topics : List <RawTopic >,
9+ )
10+
611@Serializable
712data class RawTopic (
8- @SerialName(" fields" ) val fields : Map < String , RawField > ,
13+ @SerialName(" fields" ) val fields : TopicFields ,
914)
1015
1116@Serializable
12- data class RawField (
13- @SerialName(" stringValue" ) val value : String ,
17+ data class TopicFields (
18+ @SerialName(" name" ) val name : RawField ,
19+ @SerialName(" description" ) val description : RawField ,
1420)
1521
1622@Serializable
17- data class Response (
18- @SerialName(" documents " ) val topics : List < RawTopic > ,
23+ data class RawField (
24+ @SerialName(" stringValue " ) val value : String ,
1925)
2026
2127fun RawTopic.toTopic (): Topic {
2228 return Topic (
23- name = fields[ " name" ]? .value.orEmpty() ,
24- description = fields[ " description" ]? .value.orEmpty() ,
29+ name = fields. name.value,
30+ description = fields. description.value,
2531 )
2632}
Original file line number Diff line number Diff line change 11package com.developersbreach.kotlindictionarymultiplatform.data.topic.repository
22
33import arrow.core.Either
4- import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Response
4+ import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.TopicResponse
55import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
66import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.toTopic
77import com.developersbreach.kotlindictionarymultiplatform.core.network.topicSource.FirestoreConstants
@@ -14,8 +14,8 @@ class TopicRepository(
1414) {
1515 suspend fun getTopics (): Either <Throwable , List <Topic >> {
1616 return Either .catch {
17- val response : Response = httpClient.get(FirestoreConstants .TOPICS_URL ).body()
18- response .topics.map { it.toTopic() }
17+ val topicResponse : TopicResponse = httpClient.get(FirestoreConstants .TOPICS_URL ).body()
18+ topicResponse .topics.map { it.toTopic() }
1919 }
2020 }
2121}
You can’t perform that action at this time.
0 commit comments