Skip to content

Commit 04c029e

Browse files
authored
Merge pull request #23 from DevelopersBreach/shreyas/topic-screen-firestore
Refactor `Topic Screen` to load data from Firestore
2 parents 23f7b5c + 451822e commit 04c029e

File tree

22 files changed

+110
-116
lines changed

22 files changed

+110
-116
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Download the APK
66
Access the latest APK for Kotlin Dictionary from the link below.
77

8-
[![Get APK](https://img.shields.io/badge/Get%20APK-maroon?style=for-the-badge&logo=android&logoColor=white)](https://github.com/DevelopersBreach/kotlin-dictionary-multiplatform/releases/download/v0.1.0/app-release-v0.1.0.apk)
8+
[![Get APK](https://img.shields.io/badge/Get%20APK-%23B125EA?style=for-the-badge&logo=android&logoColor=white)](https://github.com/DevelopersBreach/kotlin-dictionary-multiplatform/releases/download/v0.1.0/app-release-v0.1.0.apk)
99

1010
---
1111

@@ -29,13 +29,13 @@ Access the latest APK for Kotlin Dictionary from the link below.
2929

3030
### Roadmap v0.2.0
3131

32-
- [ ] Assign unique IDs to objects and enforce consistent ordering logic
32+
- [x] Assign unique IDs to objects and enforce consistent ordering logic
3333
- [ ] Correct usage of visibility modifiers across the codebase
3434
- [ ] Introduce common `@Preview` annotations for reusable Composable previews
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
37-
- [ ] Implement dynamic topic loading in `TopicRepository` to support scalability
38-
- [ ] Integrate Room database to persist bookmark states
37+
- [x] Implement dynamic topic loading in `TopicRepository` to support scalability
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

composeApp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ kotlin {
8787
implementation(libs.koin.androidx.compose)
8888
implementation(libs.generativeai)
8989
implementation(compose.uiTooling)
90+
implementation(libs.ktor.client.okhttp)
9091
}
9192
commonMain.dependencies {
9293
implementation(compose.runtime)

composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/PreviewUtils.kt

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,35 @@ internal fun fakeTopicDetails(): KotlinTopicDetails {
5353

5454
private fun sampleTopicList(): List<Topic> {
5555
return listOf(
56-
Topic("Smart Casts"),
57-
Topic("Null Safety"),
58-
Topic("Coroutines"),
59-
Topic("Lambdas"),
60-
Topic("Sealed Classes"),
56+
Topic(
57+
name = "Smart Casts",
58+
description = "Automatic casting by the compiler after type checks.",
59+
),
60+
Topic(
61+
name = "Null Safety",
62+
description = "Kotlin's system to eliminate null pointer exceptions at compile time.",
63+
),
64+
Topic(
65+
name = "Coroutines",
66+
description = "Lightweight threads for asynchronous and non-blocking programming.",
67+
),
68+
Topic(
69+
name = "Lambdas",
70+
description = "Anonymous functions used to pass behavior as data.",
71+
),
72+
Topic(
73+
name = "Sealed Classes",
74+
description = "Classes used to represent restricted class hierarchies for type safety.",
75+
),
6176
)
6277
}
6378

6479
internal fun sampleTopicUiList(): List<ItemTopic> {
6580
return sampleTopicList().map { topic ->
6681
ItemTopic(
67-
name = topic.name,
68-
initial = topic.name.firstOrNull()?.uppercase() ?: "",
69-
isBookmarked = true,
82+
name = topic.name ?: "",
83+
initial = topic.name?.firstOrNull()?.uppercase() ?: "",
84+
description = topic.description ?: "",
7085
)
7186
}
7287
}

composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/topic/TopicScreenPreview.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ private fun TopicScreenPreview() {
1212
KotlinDictionaryTheme {
1313
TopicScreenUI(
1414
topics = sampleTopicUiList(),
15-
bookmarkedStates = listOf(),
1615
searchQuery = "Search",
1716
onQueryChange = { },
18-
onBookmarkClick = { },
1917
onTopicClick = { },
2018
)
2119
}

composeApp/src/commonMain/composeResources/values/string.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
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>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.developersbreach.kotlindictionarymultiplatform.core.network.api
1+
package com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.api
22

33
import com.developersbreach.kotlindictionarymultiplatform.Log
4-
import com.developersbreach.kotlindictionarymultiplatform.core.network.parser.GeminiJsonParser
5-
import com.developersbreach.kotlindictionarymultiplatform.core.network.request.GeminiPromptBuilder
4+
import com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.parser.GeminiJsonParser
5+
import com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.request.GeminiPromptBuilder
66
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.KotlinTopicDetails
77
import io.ktor.client.HttpClient
88
import io.ktor.client.request.post
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.developersbreach.kotlindictionarymultiplatform.core.network.parser
1+
package com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.parser
22

33
import kotlinx.serialization.json.Json
44
import kotlinx.serialization.json.jsonObject
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.developersbreach.kotlindictionarymultiplatform.core.network.request
1+
package com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.request
22

33
import kotlinx.serialization.json.JsonObject
44
import kotlinx.serialization.json.buildJsonObject
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.developersbreach.kotlindictionarymultiplatform.core.network.topicSource
2+
3+
object FirestoreConstants {
4+
private const val ROOT_URL = "https://firestore.googleapis.com/v1/projects/kotlin-dictionary/databases/(default)/documents"
5+
const val TOPICS_URL = "$ROOT_URL/topics"
6+
}

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/data/detail/repository/DetailRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.developersbreach.kotlindictionarymultiplatform.data.detail.repository
22

33
import arrow.core.Either
4-
import com.developersbreach.kotlindictionarymultiplatform.core.network.api.GeminiApiService
4+
import com.developersbreach.kotlindictionarymultiplatform.core.network.detailsGenerator.api.GeminiApiService
55
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.KotlinTopicDetails
66
import com.developersbreach.kotlindictionarymultiplatform.getOpenApiKey
77

0 commit comments

Comments
 (0)