Skip to content

Commit 0a9e7a5

Browse files
committed
- Format code to adhere to Kotlin coding conventions and set max_line_length to 100 in .editorconfig.
- Suppress ktlint warning in `Platform.ios.kt`.
1 parent a6fcdc9 commit 0a9e7a5

File tree

18 files changed

+211
-85
lines changed

18 files changed

+211
-85
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ insert_final_newline = false
77
ij_kotlin_packages_to_use_import_on_demand = false
88
ij_kotlin_allow_trailing_comma = true
99
ij_kotlin_allow_trailing_comma_on_call_site = true
10-
max_line_length = off
10+
max_line_length = 100
1111
ktlint_function_naming_ignore_when_annotated_with = Composable
1212
ktlint_standard_import-ordering = disabled
1313
ktlint_standard_no-empty-first-line-in-class-body = disabled

composeApp/build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,18 @@ compose.desktop {
159159
}
160160
}
161161

162-
fun ApplicationDefaultConfig.setupBuildConfigFields(
163-
properties: Properties,
164-
) {
162+
fun ApplicationDefaultConfig.setupBuildConfigFields(properties: Properties) {
165163
fun secret(key: String): String = System.getenv(key) ?: properties.getProperty(key, "")
166164

167165
if (secret("OPEN_API_KEY").isEmpty()) {
168166
error("OPEN_API_KEY not set in local.properties")
169167
}
170168

171-
buildConfigField(type = "String", name = "OPEN_API_KEY", value = "\"${secret("OPEN_API_KEY")}\"")
169+
buildConfigField(
170+
type = "String",
171+
name = "OPEN_API_KEY",
172+
value = "\"${secret("OPEN_API_KEY")}\"",
173+
)
172174
}
173175

174176
fun getLocalProperties(): Properties {

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

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Sect
66
import com.developersbreach.kotlindictionarymultiplatform.data.detail.model.Syntax
77
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
88

9-
fun sampleCodeSnippet(): String = """
9+
fun sampleCodeSnippet(): String =
10+
"""
1011
fun greet(name: String): String {
1112
return "Hello, Sam!"
1213
}
@@ -16,40 +17,42 @@ fun topic() = "Smart Casts"
1617

1718
fun subtitle() = "Automatic casting of immutable values"
1819

19-
fun fakeTopicDetails() = KotlinTopicDetails(
20-
topicId = "smart-cast",
21-
topicName = "Smart Cast",
22-
intro = "Smart casting allows the compiler to automatically cast types.",
23-
syntax = Syntax(
24-
signature = "if (x is String) println(x.length)",
25-
notes = "Works only with immutable vars",
26-
),
27-
sections = listOf(
28-
Section(
29-
heading = "Why Use It?",
30-
content = "Because it’s safer and reduces boilerplate.",
31-
codeExamples = listOf(
32-
CodeExample(
33-
description = "Basic usage of smart cast",
34-
code = """
20+
fun fakeTopicDetails() =
21+
KotlinTopicDetails(
22+
topicId = "smart-cast",
23+
topicName = "Smart Cast",
24+
intro = "Smart casting allows the compiler to automatically cast types.",
25+
syntax = Syntax(
26+
signature = "if (x is String) println(x.length)",
27+
notes = "Works only with immutable vars",
28+
),
29+
sections = listOf(
30+
Section(
31+
heading = "Why Use It?",
32+
content = "Because it’s safer and reduces boilerplate.",
33+
codeExamples = listOf(
34+
CodeExample(
35+
description = "Basic usage of smart cast",
36+
code = """
3537
fun printLength(obj: Any) {
3638
if (obj is String) {
3739
println(obj.length) // Smart cast
3840
}
3941
}
40-
""".trimIndent(),
42+
""".trimIndent(),
43+
),
4144
),
4245
),
4346
),
44-
),
45-
pitfalls = listOf("Doesn't work with mutable vars."),
46-
relatedTopics = listOf("Type Checking", "Safe Casts"),
47-
)
47+
pitfalls = listOf("Doesn't work with mutable vars."),
48+
relatedTopics = listOf("Type Checking", "Safe Casts"),
49+
)
4850

49-
fun sampleTopicList(): List<Topic> = listOf(
50-
Topic("Smart Casts"),
51-
Topic("Null Safety"),
52-
Topic("Coroutines"),
53-
Topic("Lambdas"),
54-
Topic("Sealed Classes"),
55-
)
51+
fun sampleTopicList(): List<Topic> =
52+
listOf(
53+
Topic("Smart Casts"),
54+
Topic("Null Safety"),
55+
Topic("Coroutines"),
56+
Topic("Lambdas"),
57+
Topic("Sealed Classes"),
58+
)

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/data/topic/repository/TopicRepository.kt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ import arrow.core.Either
44
import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
55

66
object TopicRepository {
7-
fun getTopics(): Either<Throwable, List<Topic>> = Either.catch {
8-
listOf(
9-
Topic("Variables"),
10-
Topic("Strings"),
11-
Topic("Functions"),
12-
Topic("Coroutines"),
13-
Topic("Classes"),
14-
Topic("Interfaces"),
15-
Topic("Objects"),
16-
Topic("Collections"),
17-
Topic("Null Safety"),
18-
Topic("Lambdas"),
19-
Topic("Higher-Order Functions"),
20-
Topic("Delegation"),
21-
Topic("Sealed Classes"),
22-
Topic("Generics"),
23-
Topic("Annotations"),
24-
)
25-
}
7+
fun getTopics(): Either<Throwable, List<Topic>> =
8+
Either.catch {
9+
listOf(
10+
Topic("Variables"),
11+
Topic("Strings"),
12+
Topic("Functions"),
13+
Topic("Coroutines"),
14+
Topic("Classes"),
15+
Topic("Interfaces"),
16+
Topic("Objects"),
17+
Topic("Collections"),
18+
Topic("Null Safety"),
19+
Topic("Lambdas"),
20+
Topic("Higher-Order Functions"),
21+
Topic("Delegation"),
22+
Topic("Sealed Classes"),
23+
Topic("Generics"),
24+
Topic("Annotations"),
25+
)
26+
}
2627
}

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/navigation/AppNavigation.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import com.developersbreach.kotlindictionarymultiplatform.ui.screens.topic.Topic
1212
import org.koin.compose.viewmodel.koinViewModel
1313

1414
@Composable
15-
fun AppNavigation(
16-
startDestination: AppDestinations = AppDestinations.TopicList,
17-
) {
15+
fun AppNavigation(startDestination: AppDestinations = AppDestinations.TopicList) {
1816
val navController = rememberNavController()
1917
val actions = remember(navController) { NavigationAction(navController) }
2018

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/detail/CodeExampleBox.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ fun CodeExampleBox(
6060
Box(
6161
modifier = Modifier
6262
.fillMaxWidth()
63-
.background(MaterialTheme.colorScheme.onPrimaryContainer, RoundedCornerShape(8.dp))
63+
.background(
64+
MaterialTheme.colorScheme.onPrimaryContainer,
65+
RoundedCornerShape(8.dp),
66+
)
6467
.padding(6.dp),
6568
) {
6669
Row(
@@ -90,13 +93,23 @@ fun CodeExampleBox(
9093
.padding(4.dp),
9194
) {
9295
Icon(
93-
imageVector = if (copied) Icons.Default.Check else Icons.Default.ContentCopy,
96+
imageVector = if (copied) {
97+
Icons.Default.Check
98+
} else {
99+
Icons.Default.ContentCopy
100+
},
94101
contentDescription = stringResource(Res.string.copy),
95102
tint = MaterialTheme.colorScheme.onPrimary,
96103
)
97104
Spacer(modifier = Modifier.width(4.dp))
98105
Text(
99-
text = if (copied) stringResource(Res.string.copied) else stringResource(Res.string.copy),
106+
text = if (copied) {
107+
stringResource(
108+
Res.string.copied,
109+
)
110+
} else {
111+
stringResource(Res.string.copy)
112+
},
100113
fontSize = 12.sp,
101114
color = MaterialTheme.colorScheme.onPrimary,
102115
)

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/detail/DetailTopAppBar.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ fun DetailTopBar(title: String) {
3030
},
3131
navigationIcon = {
3232
IconButton(onClick = { /* TODO: Navigate back */ }) {
33-
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(Res.string.back))
33+
Icon(
34+
Icons.AutoMirrored.Filled.ArrowBack,
35+
contentDescription = stringResource(Res.string.back),
36+
)
3437
}
3538
},
3639
colors = TopAppBarDefaults.topAppBarColors(

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/detail/components/IntroductionSection.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import org.jetbrains.compose.resources.stringResource
1414

1515
@Composable
1616
fun IntroductionSection(topic: KotlinTopicDetails) {
17-
Text(stringResource(Res.string.introduction), style = MaterialTheme.typography.headlineLarge, color = MaterialTheme.colorScheme.onPrimary)
17+
Text(
18+
stringResource(Res.string.introduction),
19+
style = MaterialTheme.typography.headlineLarge,
20+
color = MaterialTheme.colorScheme.onPrimary,
21+
)
1822
Spacer(modifier = Modifier.height(4.dp))
1923
Text(text = topic.intro, style = MaterialTheme.typography.bodyMedium)
2024
}

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/detail/components/PitfallsSection.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ import org.jetbrains.compose.resources.stringResource
1616
@Composable
1717
fun PitfallsSection(topic: KotlinTopicDetails) {
1818
if (topic.pitfalls.isNotEmpty()) {
19-
Text(stringResource(Res.string.pitfalls), style = MaterialTheme.typography.headlineLarge, color = MaterialTheme.colorScheme.onPrimary)
19+
Text(
20+
stringResource(Res.string.pitfalls),
21+
style = MaterialTheme.typography.headlineLarge,
22+
color = MaterialTheme.colorScheme.onPrimary,
23+
)
2024
Spacer(Modifier.height(4.dp))
2125
topic.pitfalls.forEach {
22-
Text(stringResource(Res.string.bullet_item, it), style = MaterialTheme.typography.bodyMedium)
26+
Text(
27+
stringResource(Res.string.bullet_item, it),
28+
style = MaterialTheme.typography.bodyMedium,
29+
)
2330
}
2431
Spacer(Modifier.height(16.dp))
2532
}

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/ui/screens/detail/components/RelatedTopicsSection.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ import org.jetbrains.compose.resources.stringResource
1616
@Composable
1717
fun RelatedTopicsSection(topic: KotlinTopicDetails) {
1818
if (topic.relatedTopics.isNotEmpty()) {
19-
Text(stringResource(Res.string.related_topics), style = MaterialTheme.typography.headlineLarge, color = MaterialTheme.colorScheme.onPrimary)
19+
Text(
20+
stringResource(Res.string.related_topics),
21+
style = MaterialTheme.typography.headlineLarge,
22+
color = MaterialTheme.colorScheme.onPrimary,
23+
)
2024
Spacer(Modifier.height(4.dp))
2125
topic.relatedTopics.forEach {
22-
Text(stringResource(Res.string.bullet_item, it), style = MaterialTheme.typography.bodyMedium)
26+
Text(
27+
stringResource(Res.string.bullet_item, it),
28+
style = MaterialTheme.typography.bodyMedium,
29+
)
2330
}
2431
}
2532
}

0 commit comments

Comments
 (0)