Skip to content
Merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- [x] Hide API key from code by using expect/actual for OpenAPI key
- [x] Switch AI integration from OpenAI to Gemini
- [x] Refactor network layer for cleaner architecture
- [ ] Create a separate module for reusable UI components
- [x] Create a separate module for reusable UI components

---

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ plugins {
alias(libs.plugins.serialization) apply false
alias(libs.plugins.googleSecrets) apply false
alias(libs.plugins.jetbrainsKotlinJvm) apply false
alias(libs.plugins.androidKotlinMultiplatformLibrary) apply false
}
10 changes: 10 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ kotlin {

sourceSets {
val desktopMain by getting
val commonMain by getting
val commonTest by getting

val desktopTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(libs.konsist)
}
}

androidMain.dependencies {
implementation(libs.androidx.activity.compose)
Expand Down Expand Up @@ -105,6 +114,7 @@ kotlin {
implementation(libs.kermit)
implementation(libs.arrow.core)
implementation(libs.arrow.fx.coroutines)
implementation(project(":design-system"))
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.developersbreach.kotlindictionarymultiplatform.ui.components

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.developersbreach.designsystem.components.KdText
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
import kotlindictionarymultiplatform.composeapp.generated.resources.ok
import org.jetbrains.compose.resources.stringResource
Expand All @@ -18,11 +18,11 @@ fun ShowAlertDialog(
) {
AlertDialog(
onDismissRequest = onButtonClick,
title = { Text(text = title) },
text = { Text(text = description) },
title = { KdText(text = title) },
text = { KdText(text = description) },
confirmButton = {
TextButton(onClick = onButtonClick) {
Text(text = stringResource(Res.string.ok))
KdText(text = stringResource(Res.string.ok))
}
},
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -32,6 +30,8 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.developersbreach.designsystem.components.KdIcon
import com.developersbreach.designsystem.components.KdText
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
import kotlindictionarymultiplatform.composeapp.generated.resources.copied
import kotlindictionarymultiplatform.composeapp.generated.resources.copy
Expand Down Expand Up @@ -78,7 +78,7 @@ fun CodeExampleBox(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
KdText(
text = stringResource(Res.string.kotlin),
color = MaterialTheme.colorScheme.onPrimary,
fontWeight = FontWeight.Bold,
Expand All @@ -99,13 +99,13 @@ fun CodeExampleBox(
}
.padding(4.dp),
) {
Icon(
KdIcon(
imageVector = if (copied) Icons.Default.Check else Icons.Default.ContentCopy,
contentDescription = stringResource(Res.string.copy),
tint = MaterialTheme.colorScheme.onPrimary,
)
Spacer(modifier = Modifier.width(4.dp))
Text(
KdText(
text = if (copied) stringResource(Res.string.copied) else stringResource(Res.string.copy),
fontSize = 12.sp,
color = MaterialTheme.colorScheme.onPrimary,
Expand All @@ -116,7 +116,7 @@ fun CodeExampleBox(

Spacer(modifier = Modifier.height(8.dp))

Text(
KdText(
text = code,
modifier = Modifier.padding(
start = 12.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.data.detail.model.Section
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Syntax
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
Expand All @@ -25,7 +25,7 @@ fun TableOfContents(
item: String,
onClick: () -> Unit,
) {
Text(
KdText(
text = item,
modifier = Modifier.clickable { onClick() },
color = MaterialTheme.colorScheme.onSurface,
Expand All @@ -37,13 +37,13 @@ fun TableOfContents(
fun IntroductionSection(
intro: String,
) {
Text(
KdText(
text = stringResource(resource = Res.string.introduction),
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
)
Spacer(Modifier.height(4.dp))
Text(
KdText(
text = intro,
style = MaterialTheme.typography.bodyMedium,
)
Expand All @@ -54,19 +54,19 @@ fun IntroductionSection(
fun SyntaxSection(
syntax: Syntax,
) {
Text(
KdText(
text = stringResource(resource = Res.string.syntax),
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
)
Spacer(Modifier.height(4.dp))
Text(
KdText(
text = syntax.signature,
style = MaterialTheme.typography.bodyMedium,
)
syntax.notes?.let {
Spacer(Modifier.height(4.dp))
Text(
KdText(
text = stringResource(
Res.string.notes_with_value,
it,
Expand All @@ -82,7 +82,7 @@ fun SectionBlock(
section: Section,
) {
section.heading?.let {
Text(
KdText(
text = it,
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
Expand All @@ -91,7 +91,7 @@ fun SectionBlock(
}

section.content?.let {
Text(
KdText(
text = it,
style = MaterialTheme.typography.bodyMedium,
)
Expand All @@ -100,7 +100,7 @@ fun SectionBlock(

section.codeExamples.forEach { example ->
example.description?.let {
Text(
KdText(
text = it,
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.bodyMedium,
Expand All @@ -116,14 +116,14 @@ fun SectionBlock(
fun PitfallsSection(
pitfalls: List<String>,
) {
Text(
KdText(
text = stringResource(resource = Res.string.pitfalls),
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
)
Spacer(Modifier.height(4.dp))
pitfalls.forEach {
Text(
KdText(
text = stringResource(
Res.string.bullet_item,
it,
Expand All @@ -138,14 +138,14 @@ fun PitfallsSection(
fun RelatedTopicsSection(
relatedTopics: List<String>,
) {
Text(
KdText(
text = stringResource(resource = Res.string.related_topics),
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onPrimary,
)
Spacer(Modifier.height(4.dp))
relatedTopics.forEach {
Text(
KdText(
text = stringResource(
Res.string.bullet_item,
it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.developersbreach.designsystem.components.KdScaffold
import com.developersbreach.designsystem.components.KdText
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
import kotlindictionarymultiplatform.composeapp.generated.resources.table_of_contents
import kotlinx.coroutines.launch
Expand All @@ -24,20 +24,20 @@ fun DetailScreenUI(
detailUiState: DetailUiState,
navigateUp: () -> Unit,
) {
Scaffold(
KdScaffold(
topBar = {
DetailTopBar(
title = detailUiState.topicName,
navigateUp = navigateUp,
)
},
containerColor = MaterialTheme.colorScheme.background,
) { innerPadding ->
DetailContent(
detailUiState = detailUiState,
modifier = Modifier.padding(innerPadding),
)
}
content = { innerPadding ->
DetailContent(
detailUiState = detailUiState,
modifier = Modifier.padding(innerPadding),
)
},
)
}

@Composable
Expand All @@ -55,7 +55,7 @@ private fun DetailContent(
.padding(horizontal = 16.dp),
) {
item {
Text(
KdText(
text = stringResource(Res.string.table_of_contents),
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onPrimary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.developersbreach.designsystem.components.KdIconButton
import com.developersbreach.designsystem.components.KdText
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
import kotlindictionarymultiplatform.composeapp.generated.resources.back
import org.jetbrains.compose.resources.stringResource
Expand All @@ -24,20 +23,19 @@ fun DetailTopBar(
) {
TopAppBar(
title = {
Text(
KdText(
text = title,
style = MaterialTheme.typography.displayMedium,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.fillMaxWidth(),
)
},
navigationIcon = {
IconButton(onClick = navigateUp) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(Res.string.back),
)
}
KdIconButton(
onClick = navigateUp,
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(Res.string.back),
)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -20,6 +17,9 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.developersbreach.designsystem.components.KdIcon
import com.developersbreach.designsystem.components.KdText
import com.developersbreach.designsystem.components.KdTextField
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
import kotlindictionarymultiplatform.composeapp.generated.resources.search
import kotlindictionarymultiplatform.composeapp.generated.resources.search_kotlin_terms
Expand All @@ -30,23 +30,23 @@ fun SearchField(
searchQuery: String,
onQueryChange: (String) -> Unit,
) {
TextField(
KdTextField(
value = searchQuery,
onValueChange = onQueryChange,
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(25.dp))
.padding(4.dp),
placeholder = {
Text(
KdText(
stringResource(Res.string.search_kotlin_terms),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.onBackground,
)
},
leadingIcon = {
Icon(
KdIcon(
imageVector = Icons.Filled.Search,
contentDescription = stringResource(Res.string.search),
tint = MaterialTheme.colorScheme.onBackground,
Expand Down
Loading
Loading