Skip to content

Commit

Permalink
compose 1.6
Browse files Browse the repository at this point in the history
can't build js #98
  • Loading branch information
luca992 committed Mar 7, 2024
1 parent 077b960 commit 92ca183
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ com-android-application = { id = "com.android.application", version.ref = "agp"

kotlin = "1.9.22"
agp = "8.2.2"
##⬆= "8.3.0"

okio = "3.8.0"
startup-runtime = "1.1.1"
vanniktech-publish = "0.27.0"
compose = "1.5.12"
compose = "1.6.0"
coroutines = "1.8.0"
ktor = "2.3.8"
ktor = "2.3.9"
cache4k = "0.13.0"
xmlutil = "0.86.3"
activity-compose = "1.8.2"
Expand All @@ -45,7 +46,6 @@ ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }

compose-components-resources = { module = "org.jetbrains.compose.components:components-resources", version.ref = "compose" }
jetbrains-compose-ui-ui-test-junit4 = { module = "org.jetbrains.compose.ui:ui-test-junit4", version.ref = "compose" }

pdvrieze-xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }
Expand Down
4 changes: 3 additions & 1 deletion kamel-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ kotlin {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.runtime)
// move resources to commonTest if possible eventually
// https://github.com/JetBrains/compose-multiplatform/issues/4442
implementation(compose.components.resources)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.ktor.client.core)
implementation(libs.okio)
Expand All @@ -51,7 +54,6 @@ kotlin {
implementation(libs.ktor.client.mock)
implementation(libs.kotlinx.coroutines.test)
implementation(libs.okio.fakefilesystem)
implementation(libs.compose.components.resources)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.kamel.core.tests
import io.ktor.client.engine.mock.*
import io.ktor.http.*
import io.ktor.utils.io.*
import org.jetbrains.compose.resources.resource
import media.kamel.`kamel-core`.generated.resources.Res

val HttpMockEngine = MockEngine { request ->
when (request.url.encodedPath) {
Expand All @@ -17,11 +17,11 @@ val HttpMockEngine = MockEngine { request ->
const val TestStringUrl = "https://www.example.com"

suspend fun resourceImage(): ByteReadChannel {
val bytes = resource("Compose.png").readBytes()
val bytes = Res.readBytes("files/Compose.png")
return ByteReadChannel(bytes)
}

suspend fun svgImage(): ByteReadChannel {
val bytes = resource("Kotlin.svg").readBytes()
val bytes = Res.readBytes("files/Kotlin.svg")
return ByteReadChannel(bytes)
}
2 changes: 1 addition & 1 deletion kamel-samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ kotlin {
implementation(project(":kamel-image"))
implementation(compose.foundation)
implementation(compose.material)
implementation(libs.compose.components.resources)
implementation(compose.components.resources)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.kamel.samples

import io.kamel.core.utils.File
import org.jetbrains.compose.resources.resource
import media.kamel.`kamel-samples`.generated.resources.Res
import java.io.FileOutputStream


public actual suspend fun getResourceFile(fileResourcePath: String): File {
val file = java.io.File.createTempFile("temp", ".${fileResourcePath.substringAfterLast(".")}")
FileOutputStream(file).use { os ->
val buffer = resource(fileResourcePath).readBytes()
val buffer = Res.readBytes(fileResourcePath)
os.write(buffer, 0, buffer.size)
}
return file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public fun launcher(kamelConfig: KamelConfig) {
}
when (tabIndex) {
0 -> Gallery()
1 -> FileSample("Compose.png")
2 -> FileSample("XlImage.png")
3 -> FileSample("ComposeXml.xml")
4 -> FileSample("Kotlin.svg")
1 -> FileSample("files/Compose.png")
2 -> FileSample("files/XlImage.png")
3 -> FileSample("files/ComposeXml.xml")
4 -> FileSample("files/Kotlin.svg")

else -> Text("Invalid Sample Index")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import platform.Foundation.NSFileManager

public actual suspend fun getResourceFile(fileResourcePath: String): File {
val currentDirectoryPath = NSFileManager.defaultManager().currentDirectoryPath
return File("$currentDirectoryPath/src/commonMain/resources/$fileResourcePath")
return File("$currentDirectoryPath/src/commonMain/composeResources/$fileResourcePath")
}

0 comments on commit 92ca183

Please sign in to comment.