Skip to content

Commit c9c7359

Browse files
Merge pull request #2 from DevelopersBreach/shreyas/topiclist-navigation
Update/Correct dependency, sourceSets, version, modules, navigation and entry points
2 parents f95e75d + f039f9c commit c9c7359

File tree

19 files changed

+289
-57
lines changed

19 files changed

+289
-57
lines changed

composeApp/build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,19 @@ kotlin {
5959
androidMain.dependencies {
6060
implementation(compose.preview)
6161
implementation(libs.androidx.activity.compose)
62+
implementation(libs.koin.android)
63+
implementation(libs.koin.androidx.compose)
64+
implementation(compose.components.uiToolingPreview)
6265
}
6366
commonMain.dependencies {
6467
implementation(compose.runtime)
6568
implementation(compose.foundation)
6669
implementation(compose.material)
6770
implementation(compose.ui)
6871
implementation(compose.components.resources)
69-
implementation(compose.components.uiToolingPreview)
7072
implementation(libs.androidx.lifecycle.viewmodel)
7173
implementation(libs.androidx.lifecycle.runtime.compose)
74+
implementation(libs.androidx.navigation.compose)
7275

7376
implementation(project.dependencies.platform(libs.ktor.bom))
7477
implementation(libs.ktor.client.android)
@@ -77,6 +80,12 @@ kotlin {
7780
implementation(libs.ktor.client.logging)
7881
implementation(libs.ktor.client.mock)
7982
implementation(libs.ktor.client.serialization)
83+
implementation(libs.kotlinx.serialization.json)
84+
85+
implementation(project.dependencies.platform(libs.koin.bom))
86+
api(libs.koin.core)
87+
implementation(libs.koin.compose)
88+
implementation(libs.koin.compose.viewmodel)
8089
}
8190
desktopMain.dependencies {
8291
implementation(compose.desktop.currentOs)

composeApp/src/androidMain/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33

4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
46
<application
57
android:allowBackup="true"
68
android:icon="@mipmap/ic_launcher"

composeApp/src/androidMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/MainActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
66
import androidx.compose.runtime.Composable
77
import androidx.compose.ui.tooling.preview.Preview
8+
import com.developersbreach.kotlindictionarymultiplatform.di.appModule
9+
import org.koin.android.ext.koin.androidContext
10+
import org.koin.core.context.startKoin
811

912
class MainActivity : ComponentActivity() {
1013
override fun onCreate(savedInstanceState: Bundle?) {
1114
super.onCreate(savedInstanceState)
1215

16+
startKoin {
17+
androidContext(this@MainActivity)
18+
modules(appModule)
19+
}
20+
1321
setContent {
1422
App()
1523
}
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
11
package com.developersbreach.kotlindictionarymultiplatform
22

3-
import androidx.compose.animation.AnimatedVisibility
4-
import androidx.compose.foundation.Image
5-
import androidx.compose.foundation.layout.Column
6-
import androidx.compose.foundation.layout.fillMaxWidth
7-
import androidx.compose.material.Button
83
import androidx.compose.material.MaterialTheme
9-
import androidx.compose.material.Text
104
import androidx.compose.runtime.*
11-
import androidx.compose.ui.Alignment
12-
import androidx.compose.ui.Modifier
13-
import org.jetbrains.compose.resources.painterResource
14-
import org.jetbrains.compose.ui.tooling.preview.Preview
15-
16-
import kotlindictionarymultiplatform.composeapp.generated.resources.Res
17-
import kotlindictionarymultiplatform.composeapp.generated.resources.compose_multiplatform
5+
import com.developersbreach.kotlindictionarymultiplatform.ui.navigation.AppNavigation
186

197
@Composable
20-
@Preview
218
fun App() {
229
MaterialTheme {
23-
var showContent by remember { mutableStateOf(false) }
24-
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
25-
Button(onClick = { showContent = !showContent }) {
26-
Text("Click me!")
27-
}
28-
AnimatedVisibility(showContent) {
29-
val greeting = remember { Greeting().greet() }
30-
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
31-
Image(painterResource(Res.drawable.compose_multiplatform), null)
32-
Text("Compose: $greeting")
33-
}
34-
}
35-
}
10+
AppNavigation()
3611
}
3712
}

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/Greeting.kt

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

composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/Runner.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.developersbreach.kotlindictionarymultiplatform.core
2+
3+
const val API_KEY =""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.developersbreach.kotlindictionarymultiplatform
1+
package com.developersbreach.kotlindictionarymultiplatform.core
22

33
import kotlinx.serialization.Serializable
44
import kotlinx.serialization.SerialName
@@ -71,7 +71,7 @@ data class ChatCompletionResponseMessage(
7171

7272
@Serializable
7373
data class ChatCompletionResponse(
74-
val choices: List<ChatCompletionChoice>
74+
val choices: List<ChatCompletionChoice>?
7575
)
7676

7777
@Serializable
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.developersbreach.kotlindictionarymultiplatform
1+
package com.developersbreach.kotlindictionarymultiplatform.core
22

33
import io.ktor.client.HttpClient
44
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
@@ -112,7 +112,8 @@ object KtorHttpClient {
112112

113113
// Parse response
114114
val chatResp = json.decodeFromString(ChatCompletionResponse.serializer(), text)
115-
val funcCall = chatResp.choices.first().message.functionCall ?: error("No function call in response")
115+
println(chatResp)
116+
val funcCall = chatResp.choices?.first()?.message?.functionCall ?: error("No function call in response")
116117

117118
// The arguments field is a JSON string: parse and decode into our DTO
118119
val argsJson = json.parseToJsonElement(funcCall.arguments)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.developersbreach.kotlindictionarymultiplatform.di
2+
3+
import org.koin.core.module.dsl.viewModel
4+
import com.developersbreach.kotlindictionarymultiplatform.ui.screens.DetailViewModel
5+
import org.koin.dsl.module
6+
7+
val appModule = module {
8+
9+
viewModel {
10+
DetailViewModel(get())
11+
}
12+
}

0 commit comments

Comments
 (0)