Skip to content

Commit d5c5fdd

Browse files
Merge pull request #18 from DevelopersBreach/rework-simplify-topics-screen-implementation
Rework/simplify topics screen implementation, remove redundant resources
2 parents a50640c + e83e479 commit d5c5fdd

File tree

17 files changed

+129
-270
lines changed

17 files changed

+129
-270
lines changed

README.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,42 @@
44

55
---
66

7+
## 🎯 Roadmap
8+
9+
### Roadmap v0.1.0
10+
11+
- [x] Add initial `README` with project overview
12+
- [x] Add `ktlint` configuration for code style enforcement
13+
- [x] Integrate `Arrow Core` for exception handling
14+
- [x] Add `Kermit` logging library and replace println statements
15+
- [x] Configure GitHub Actions workflow
16+
- [x] Implement section-wise scroll behavior on the `Detail Screen` for better navigation
17+
- [x] Replace the search icon on the `Topic Card` to improve visual consistency
18+
- [x] Hide API key from code by using expect/actual for OpenAPI key
19+
- [x] Switch AI integration from OpenAI to Gemini
20+
- [x] Refactor network layer for cleaner architecture
21+
- [ ] Create a separate module for reusable UI components
22+
23+
---
24+
25+
### Roadmap v0.2.0
26+
27+
- [ ] Assign unique IDs to objects and enforce consistent ordering logic
28+
- [ ] Correct usage of visibility modifiers across the codebase
29+
- [ ] Introduce common `@Preview` annotations for reusable Composable previews
30+
- [ ] Add inline code formatting support for syntax display on the `Detail Screen`
31+
- [ ] Implement caching on the `Detail Screen` to store previously viewed topic data
32+
- [ ] Implement dynamic topic loading in `TopicRepository` to support scalability
33+
- [ ] Integrate Room database to persist bookmark states
34+
- [ ] Add a `Home Page` for navigation
35+
- [ ] Add a `Quiz Page` to host topic-based quizzes
36+
- [ ] Add a button in `DetailScreen` to attempt a quiz for that topic
37+
- [ ] Add a `Contributors Page` to showcase project contributors
38+
- [ ] Add a `Settings Page` with basic preferences
39+
- [ ] Implement a `Splash Screen`
40+
41+
---
42+
743
Kotlin Dictionary is a student-led, cross-platform app designed to help learners dive deep into the Kotlin programming language. It serves as an interactive reference where you can explore topics with clear explanations and reinforce your learning through quizzes.
844
_The data is powered by AI tools which help automate content generation, ensure consistency, and speed up the documentation._
945

@@ -49,23 +85,4 @@ Here are a couple of early previews from the Android version of the app:
4985

5086
## ⚠️ Disclaimer
5187

52-
This is an educational project developed by students. Expect rapid changes, experiments, and ongoing improvements as part of the learning journey. 😊
53-
54-
---
55-
56-
## 🎢 Roadmap
57-
58-
- [x] Add `ktlint` configuration for code style enforcement.
59-
- [x] Integrate `Arrow Core` for exception handling.
60-
- [x] Add a centralized logger.
61-
- [ ] Create a separate module for reusable UI components.
62-
- [x] Configure GitHub Actions workflow.
63-
- [ ] Assign unique IDs to objects and enforce consistent ordering logic.
64-
- [ ] Correct usage of visibility modifiers across the codebase.
65-
- [ ] Introduce common @Preview annotations for reusable Composable previews.
66-
- [ ] Implement section-wise scroll behavior on the `Detail Screen` for better navigation.
67-
- [ ] Add inline code formatting support for syntax display on the `Detail Screen`.
68-
- [x] Replace the search icon on the `Topic Card` to improve visual consistency.
69-
- [ ] Implement caching on the `Detail Screen` to store previously viewed topic data.
70-
- [x] Switch AI integration from OpenAI to Gemini.
71-
- [ ] Refactor network layer for cleaner architecture.
88+
This is an educational project developed by students. Expect rapid changes, experiments, and ongoing improvements as part of the learning journey. 😊

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,17 @@ import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Kotl
55
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Section
66
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Syntax
77
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
8-
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.TopicUi
8+
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.ItemTopic
99

10-
fun sampleCodeSnippet(): String {
10+
internal fun sampleCodeSnippet(): String {
1111
return """
1212
fun greet(name: String): String {
1313
return "Hello, Sam!"
1414
}
1515
""".trimIndent()
1616
}
1717

18-
fun topic(): String {
19-
return "Smart Casts"
20-
}
21-
22-
fun subtitle(): String {
23-
return "Automatic casting of immutable values"
24-
}
25-
26-
fun fakeTopicDetails(): KotlinTopicDetails {
18+
internal fun fakeTopicDetails(): KotlinTopicDetails {
2719
return KotlinTopicDetails(
2820
topicId = "smart-cast",
2921
topicName = "Smart Cast",
@@ -59,7 +51,7 @@ fun fakeTopicDetails(): KotlinTopicDetails {
5951
)
6052
}
6153

62-
fun sampleTopicList(): List<Topic> {
54+
private fun sampleTopicList(): List<Topic> {
6355
return listOf(
6456
Topic("Smart Casts"),
6557
Topic("Null Safety"),
@@ -69,9 +61,9 @@ fun sampleTopicList(): List<Topic> {
6961
)
7062
}
7163

72-
fun sampleTopicUiList(): List<TopicUi> {
64+
internal fun sampleTopicUiList(): List<ItemTopic> {
7365
return sampleTopicList().map { topic ->
74-
TopicUi(
66+
ItemTopic(
7567
name = topic.name,
7668
initial = topic.name.firstOrNull()?.uppercase() ?: "",
7769
isBookmarked = true,

composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/detail/CodeExampleBoxPreview.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import com.developersbreach.kotlindictionarymultiplatform.ui.theme.KotlinDiction
1111

1212
@PreviewLightDark
1313
@Composable
14-
fun CodeExampleBoxPreview() {
14+
private fun CodeExampleBoxPreview() {
1515
KotlinDictionaryTheme {
1616
CodeExampleBox(
1717
code = sampleCodeSnippet(),

composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/detail/DetailScreenPreview.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.developersbreach.kotlindictionarymultiplatform.ui.theme.KotlinDiction
99

1010
@PreviewLightDark
1111
@Composable
12-
fun DetailScreenPreview() {
12+
private fun DetailScreenPreview() {
1313
KotlinDictionaryTheme {
1414
DetailScreenUI(
1515
detailUiState = fakeTopicDetails().toDetailUi(),

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

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

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,22 @@
11
package com.developersbreach.kotlindictionarymultiplatform.previews.topic
22

33
import androidx.compose.runtime.Composable
4-
import androidx.compose.runtime.collectAsState
5-
import androidx.compose.runtime.getValue
64
import androidx.compose.ui.tooling.preview.PreviewLightDark
7-
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
8-
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.TopicUi
9-
import com.developersbreach.kotlindictionarymultiplatform.previews.sampleTopicList
10-
import com.developersbreach.kotlindictionarymultiplatform.ui.components.UiState
11-
import com.developersbreach.kotlindictionarymultiplatform.ui.components.UiStateHandler
5+
import com.developersbreach.kotlindictionarymultiplatform.previews.sampleTopicUiList
126
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.TopicScreenUI
137
import com.developersbreach.kotlindictionarymultiplatform.ui.theme.KotlinDictionaryTheme
14-
import kotlinx.coroutines.flow.MutableStateFlow
15-
import kotlinx.coroutines.flow.StateFlow
16-
17-
// Fake ViewModel for previews
18-
class FakeTopicViewModel : TopicViewModelFakeBase() {
19-
override val topics = MutableStateFlow<UiState<List<Topic>>>(UiState.Success(sampleTopicList()))
20-
override val searchQuery = MutableStateFlow("")
21-
override val filteredTopics = MutableStateFlow(
22-
sampleTopicList().map { topic ->
23-
TopicUi(
24-
name = topic.name,
25-
initial = topic.name.firstOrNull()?.uppercase() ?: "",
26-
isBookmarked = true,
27-
)
28-
},
29-
)
30-
override val bookmarkedStates = MutableStateFlow(List(sampleTopicList().size) { true })
31-
32-
override fun updateSearchQuery(
33-
newQuery: String,
34-
) {}
35-
36-
override fun toggleBookmark(
37-
index: Int,
38-
) {}
39-
}
40-
41-
// Base class to avoid needing Android ViewModel
42-
abstract class TopicViewModelFakeBase {
43-
abstract val topics: StateFlow<UiState<List<Topic>>>
44-
abstract val searchQuery: StateFlow<String>
45-
abstract val filteredTopics: StateFlow<List<TopicUi>>
46-
abstract val bookmarkedStates: StateFlow<List<Boolean>>
47-
48-
abstract fun updateSearchQuery(
49-
newQuery: String,
50-
)
51-
52-
abstract fun toggleBookmark(
53-
index: Int,
54-
)
55-
}
56-
57-
@Composable
58-
fun TopicScreenContent(
59-
viewModel: TopicViewModelFakeBase,
60-
onTopicClick: (String) -> Unit = {},
61-
) {
62-
val topicState by viewModel.topics.collectAsState()
63-
val filteredTopics by viewModel.filteredTopics.collectAsState()
64-
val searchQuery by viewModel.searchQuery.collectAsState()
65-
val bookmarkedStates by viewModel.bookmarkedStates.collectAsState()
66-
67-
UiStateHandler(uiState = topicState) {
68-
TopicScreenUI(
69-
topics = filteredTopics,
70-
bookmarkedStates = bookmarkedStates,
71-
searchQuery = searchQuery,
72-
onQueryChange = viewModel::updateSearchQuery,
73-
onBookmarkClick = viewModel::toggleBookmark,
74-
onTopicClick = onTopicClick,
75-
)
76-
}
77-
}
788

799
@PreviewLightDark
8010
@Composable
81-
fun TopicScreenPreview() {
11+
private fun TopicScreenPreview() {
8212
KotlinDictionaryTheme {
83-
TopicScreenContent(viewModel = FakeTopicViewModel())
13+
TopicScreenUI(
14+
topics = sampleTopicUiList(),
15+
bookmarkedStates = listOf(),
16+
searchQuery = "Search",
17+
onQueryChange = { },
18+
onBookmarkClick = { },
19+
onTopicClick = { },
20+
)
8421
}
8522
}

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/data/topic/model/TopicUi.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)