diff --git a/README.md b/README.md
index 7221cd5..2988332 100644
--- a/README.md
+++ b/README.md
@@ -36,13 +36,14 @@ Access the latest APK for Kotlin Dictionary from the link below.
- [ ] Implement caching on the `Detail Screen` to store previously viewed topic data
- [x] Implement dynamic topic loading in `TopicRepository` to support scalability
- [ ] Add bookmark feature for topic cards to allow users to save and revisit important topics
-- [ ] Add a `Home Page` for navigation
+- [x] Add a `Home Page` for navigation
- [ ] Add a `Quiz Page` to host topic-based quizzes
- [ ] Add a button in `DetailScreen` to attempt a quiz for that topic
- [ ] Add a `Contributors Page` to showcase project contributors
- [ ] Add a `Settings Page` with basic preferences
- [ ] Implement a `Splash Screen`
- [x] Integrate multiplatform paging for `Topic Screen`
+- [ ] Add dark theme previews to the README
---
diff --git a/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/home/HomeScreenPreview.kt b/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/home/HomeScreenPreview.kt
new file mode 100644
index 0000000..9220564
--- /dev/null
+++ b/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/home/HomeScreenPreview.kt
@@ -0,0 +1,18 @@
+package com.developersbreach.kotlindictionarymultiplatform.previews.home
+
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.tooling.preview.PreviewLightDark
+import com.developersbreach.kotlindictionarymultiplatform.previews.sampleTopicUiList
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.home.HomeScreenUI
+import com.developersbreach.kotlindictionarymultiplatform.ui.theme.KotlinDictionaryTheme
+
+@PreviewLightDark
+@Composable
+private fun HomeScreenPreview() {
+ KotlinDictionaryTheme {
+ HomeScreenUI(
+ topics = sampleTopicUiList(),
+ onViewAllClick = {},
+ )
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/topic/TopicScreenPreview.kt b/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/topic/TopicScreenPreview.kt
index ffbe3d1..5eed989 100644
--- a/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/topic/TopicScreenPreview.kt
+++ b/composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/previews/topic/TopicScreenPreview.kt
@@ -17,6 +17,7 @@ private fun TopicScreenPreview() {
searchQuery = "Search",
onQueryChange = { },
onTopicClick = { },
+ onNavigateUp = { },
)
}
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/composeResources/values/string.xml b/composeApp/src/commonMain/composeResources/values/string.xml
index beb55cb..f984df0 100644
--- a/composeApp/src/commonMain/composeResources/values/string.xml
+++ b/composeApp/src/commonMain/composeResources/values/string.xml
@@ -25,4 +25,8 @@
Icon
Search Kotlin terms...
Search
+ Menu
+ Welcome,\nKotlin Enthusiast!
+ Quizzes
+ View all
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/di/ViewModelModule.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/di/ViewModelModule.kt
index 909a263..5a7021f 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/di/ViewModelModule.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/di/ViewModelModule.kt
@@ -2,6 +2,7 @@ package com.developersbreach.kotlindictionarymultiplatform.di
import androidx.lifecycle.SavedStateHandle
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.detail.DetailViewModel
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.home.HomeViewModel
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.TopicViewModel
import org.koin.core.module.dsl.viewModel
import org.koin.dsl.module
@@ -17,4 +18,10 @@ internal val viewModelModule = module {
viewModel {
TopicViewModel(get())
}
+
+ viewModel {
+ HomeViewModel(
+ topicRepository = get(),
+ )
+ }
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppDestinations.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppDestinations.kt
index d5674b3..5d9c335 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppDestinations.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppDestinations.kt
@@ -12,4 +12,7 @@ sealed interface AppDestinations {
data class Detail(
val topicId: String,
) : AppDestinations
+
+ @Serializable
+ data object Home : AppDestinations
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppNavigation.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppNavigation.kt
index 547e993..b75fbf4 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppNavigation.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppNavigation.kt
@@ -1,5 +1,6 @@
package com.developersbreach.kotlindictionarymultiplatform.ui.navigation
+import HomeScreen
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.compose.NavHost
@@ -7,13 +8,14 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.detail.DetailScreen
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.detail.DetailViewModel
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.home.HomeViewModel
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.TopicScreen
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.TopicViewModel
import org.koin.compose.viewmodel.koinViewModel
@Composable
fun AppNavigation(
- startDestination: AppDestinations = AppDestinations.TopicList,
+ startDestination: AppDestinations = AppDestinations.Home,
) {
val navController = rememberNavController()
val actions = remember(navController) { NavigationAction(navController) }
@@ -29,6 +31,7 @@ fun AppNavigation(
actions.navigateToDetail(selectedTopicId)
},
viewModel = viewModel,
+ onNavigateUp = { navController.navigateUp() },
)
}
@@ -39,5 +42,12 @@ fun AppNavigation(
navigateUp = { navController.navigateUp() },
)
}
+ composable {
+ val viewModel: HomeViewModel = koinViewModel()
+ HomeScreen(
+ viewModel = viewModel,
+ navigateToTopicList = actions.navigateToTopic,
+ )
+ }
}
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/NavigationAction.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/NavigationAction.kt
index eca0c35..e17ce98 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/NavigationAction.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/NavigationAction.kt
@@ -9,4 +9,7 @@ class NavigationAction(
val navigateToDetail: (String) -> Unit = { topicId ->
navController.navigate(AppDestinations.Detail(topicId))
}
+ val navigateToTopic: () -> Unit = {
+ navController.navigate(AppDestinations.TopicList)
+ }
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeCard.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeCard.kt
new file mode 100644
index 0000000..9a46289
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeCard.kt
@@ -0,0 +1,57 @@
+package com.developersbreach.kotlindictionarymultiplatform.ui.screens.home
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.unit.dp
+import com.developersbreach.designsystem.components.KdCard
+import com.developersbreach.designsystem.components.KdText
+
+@Composable
+fun HomeCard(
+ label: String,
+) {
+ KdCard(
+ modifier = Modifier
+ .size(120.dp)
+ .clip(RoundedCornerShape(22.dp)),
+ colors = CardDefaults.cardColors(
+ containerColor = MaterialTheme.colorScheme.secondaryContainer,
+ ),
+ elevation = CardDefaults.cardElevation(defaultElevation = 2.dp),
+ content = {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(
+ Brush.verticalGradient(
+ colors = listOf(
+ MaterialTheme.colorScheme.primary.copy(alpha = 0.8f),
+ MaterialTheme.colorScheme.primaryContainer,
+ ),
+ ),
+ ),
+ contentAlignment = Alignment.BottomStart,
+ ) {
+ KdText(
+ text = label,
+ maxLines = 1,
+ modifier = Modifier
+ .padding(12.dp)
+ .align(Alignment.BottomStart),
+ color = MaterialTheme.colorScheme.onSecondaryContainer,
+ )
+ }
+ },
+ )
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreen.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreen.kt
new file mode 100644
index 0000000..b824d13
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreen.kt
@@ -0,0 +1,17 @@
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.collectAsState
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.home.HomeScreenUI
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.home.HomeViewModel
+
+@Composable
+fun HomeScreen(
+ viewModel: HomeViewModel,
+ navigateToTopicList: () -> Unit,
+) {
+ val topicsState = viewModel.topics.collectAsState()
+
+ HomeScreenUI(
+ topics = topicsState.value,
+ onViewAllClick = navigateToTopicList,
+ )
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreenUI.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreenUI.kt
new file mode 100644
index 0000000..05c5dbf
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeScreenUI.kt
@@ -0,0 +1,48 @@
+package com.developersbreach.kotlindictionarymultiplatform.ui.screens.home
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import com.developersbreach.designsystem.components.KdScaffold
+import com.developersbreach.designsystem.components.KdText
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.Topic
+import kotlindictionarymultiplatform.composeapp.generated.resources.Res
+import kotlindictionarymultiplatform.composeapp.generated.resources.topics
+import kotlindictionarymultiplatform.composeapp.generated.resources.welcome
+import org.jetbrains.compose.resources.stringResource
+
+@Composable
+fun HomeScreenUI(
+ topics: List,
+ onViewAllClick: () -> Unit,
+) {
+ KdScaffold(
+ topBar = { HomeTopAppBar() },
+ modifier = Modifier,
+ ) { innerPadding ->
+ Column(
+ modifier = Modifier
+ .padding(horizontal = 16.dp)
+ .padding(top = innerPadding.calculateTopPadding()),
+ ) {
+ Spacer(modifier = Modifier.height(16.dp))
+ KdText(
+ text = stringResource(Res.string.welcome),
+ style = MaterialTheme.typography.displayLarge,
+ color = MaterialTheme.colorScheme.onBackground,
+ modifier = Modifier,
+ )
+ Spacer(modifier = Modifier.height(16.dp))
+ HorizontalScroll(
+ title = stringResource(Res.string.topics),
+ topics = topics,
+ onViewAllClick = onViewAllClick,
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeTopAppBar.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeTopAppBar.kt
new file mode 100644
index 0000000..c6f7f76
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeTopAppBar.kt
@@ -0,0 +1,47 @@
+package com.developersbreach.kotlindictionarymultiplatform.ui.screens.home
+
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Menu
+import kotlindictionarymultiplatform.composeapp.generated.resources.menu
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.TopAppBarDefaults
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.style.TextAlign
+import com.developersbreach.designsystem.components.KdIconButton
+import com.developersbreach.designsystem.components.KdText
+import com.developersbreach.designsystem.components.KdTopAppBar
+import kotlindictionarymultiplatform.composeapp.generated.resources.Res
+import org.jetbrains.compose.resources.stringResource
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun HomeTopAppBar() {
+ KdTopAppBar(
+ title = {
+ KdText(
+ text = "Kotlin Dictionary",
+ style = MaterialTheme.typography.displayMedium,
+ modifier = Modifier.fillMaxWidth(),
+ textAlign = TextAlign.Start,
+ color = MaterialTheme.colorScheme.onPrimary,
+ )
+ },
+ colors = TopAppBarDefaults.topAppBarColors(
+ containerColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ titleContentColor = MaterialTheme.colorScheme.onPrimary,
+ navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
+ ),
+ navigationIcon = {
+ KdIconButton(
+ onClick = {},
+ modifier = Modifier,
+ contentDescription = stringResource(Res.string.menu),
+ iconModifier = Modifier,
+ imageVector = Icons.Default.Menu,
+ )
+ },
+ )
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeViewModel.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeViewModel.kt
new file mode 100644
index 0000000..800f615
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HomeViewModel.kt
@@ -0,0 +1,29 @@
+package com.developersbreach.kotlindictionarymultiplatform.ui.screens.home
+
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.developersbreach.kotlindictionarymultiplatform.data.topic.repository.TopicRepository
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.Topic
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.launch
+
+class HomeViewModel(
+ private val topicRepository: TopicRepository,
+) : ViewModel() {
+
+ private val _topics = MutableStateFlow>(emptyList())
+ val topics: StateFlow> = _topics.asStateFlow()
+
+ init {
+ fetchTopics()
+ }
+
+ private fun fetchTopics() {
+ viewModelScope.launch {
+ val result = topicRepository.getTopicsPage(page = 1, pageSize = 5, query = "")
+ _topics.value = result
+ }
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HorizontalScroll.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HorizontalScroll.kt
new file mode 100644
index 0000000..669f11d
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/home/HorizontalScroll.kt
@@ -0,0 +1,55 @@
+package com.developersbreach.kotlindictionarymultiplatform.ui.screens.home
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import com.developersbreach.designsystem.components.KdText
+import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.Topic
+import kotlindictionarymultiplatform.composeapp.generated.resources.Res
+import kotlindictionarymultiplatform.composeapp.generated.resources.view_all
+import org.jetbrains.compose.resources.stringResource
+
+@Composable
+fun HorizontalScroll(
+ title: String,
+ topics: List,
+ onViewAllClick: () -> Unit,
+) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ KdText(
+ text = title,
+ style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold),
+ color = MaterialTheme.colorScheme.onBackground,
+ modifier = Modifier,
+ )
+ Spacer(modifier = Modifier.weight(1f))
+ KdText(
+ text = stringResource(Res.string.view_all),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onBackground,
+ modifier = Modifier
+ .clickable { onViewAllClick() },
+ )
+ }
+ Spacer(modifier = Modifier.height(8.dp))
+ LazyRow {
+ items(topics) { topics ->
+ HomeCard(label = topics.name)
+ Spacer(modifier = Modifier.width(12.dp))
+ }
+ }
+}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreen.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreen.kt
index f1788a9..d8402bd 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreen.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreen.kt
@@ -8,6 +8,7 @@ import app.cash.paging.compose.collectAsLazyPagingItems
fun TopicScreen(
viewModel: TopicViewModel,
onTopicClick: (String) -> Unit,
+ onNavigateUp: () -> Unit,
) {
val pagingItems = viewModel.topics.collectAsLazyPagingItems()
val searchQuery = viewModel.searchQuery.collectAsState().value
@@ -17,5 +18,6 @@ fun TopicScreen(
searchQuery = searchQuery,
onQueryChange = viewModel::updateSearchQuery,
onTopicClick = onTopicClick,
+ onNavigateUp = onNavigateUp,
)
}
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreenUI.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreenUI.kt
index 7084245..668ccca 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreenUI.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicScreenUI.kt
@@ -16,10 +16,11 @@ fun TopicScreenUI(
searchQuery: String,
onQueryChange: (String) -> Unit,
onTopicClick: (String) -> Unit,
+ onNavigateUp: () -> Unit,
) {
KdScaffold(
modifier = Modifier,
- topBar = { TopicTopBar() },
+ topBar = { TopicTopBar(onNavigateUp = onNavigateUp) },
) { paddingValues ->
Column(
modifier = Modifier
diff --git a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicTopAppBar.kt b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicTopAppBar.kt
index b1bb812..8208ee0 100644
--- a/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicTopAppBar.kt
+++ b/composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/topic/TopicTopAppBar.kt
@@ -19,7 +19,9 @@ import org.jetbrains.compose.resources.stringResource
@OptIn(ExperimentalMaterial3Api::class)
@Composable
-fun TopicTopBar() {
+fun TopicTopBar(
+ onNavigateUp: () -> Unit,
+) {
KdTopAppBar(
title = {
KdText(
@@ -33,7 +35,7 @@ fun TopicTopBar() {
KdIconButton(
modifier = Modifier,
iconModifier = Modifier,
- onClick = {},
+ onClick = onNavigateUp,
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(Res.string.back),
)
diff --git a/composeApp/src/desktopTest/kotlin/com/developersbreach/kotlindictionarymultiplatform/DesignSystemTest.kt b/composeApp/src/desktopTest/kotlin/com/developersbreach/kotlindictionarymultiplatform/DesignSystemTest.kt
index 8ee6686..f50af26 100644
--- a/composeApp/src/desktopTest/kotlin/com/developersbreach/kotlindictionarymultiplatform/DesignSystemTest.kt
+++ b/composeApp/src/desktopTest/kotlin/com/developersbreach/kotlindictionarymultiplatform/DesignSystemTest.kt
@@ -94,6 +94,14 @@ class DesignSystemTest {
)
}
+ @Test
+ fun `no direct usage of androidx compose card should be allowed except designSystem`() {
+ checkNoDirectUsageExceptAllowed(
+ componentName = "androidx.compose.material3.Card",
+ excludePaths = arrayOf("$DESIGN_SYSTEM_PATH/Card.kt"),
+ )
+ }
+
companion object {
private const val DESIGN_SYSTEM_PATH =
"design-system/src/commonMain/kotlin/com/developersbreach/designsystem/components"
diff --git a/design-system/src/commonMain/kotlin/com/developersbreach/designsystem/components/Card.kt b/design-system/src/commonMain/kotlin/com/developersbreach/designsystem/components/Card.kt
new file mode 100644
index 0000000..8e16ad2
--- /dev/null
+++ b/design-system/src/commonMain/kotlin/com/developersbreach/designsystem/components/Card.kt
@@ -0,0 +1,23 @@
+package com.developersbreach.designsystem.components
+
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardColors
+import androidx.compose.material3.CardElevation
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+
+@Composable
+fun KdCard(
+ modifier: Modifier,
+ colors: CardColors,
+ elevation: CardElevation,
+ content: @Composable ColumnScope.() -> Unit,
+) {
+ Card(
+ modifier = modifier,
+ content = content,
+ elevation = elevation,
+ colors = colors,
+ )
+}
\ No newline at end of file