Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use coil3 for image loading #37

Draft
wants to merge 1 commit into
base: amper
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The app uses the following multiplatform dependencies in its implementation:
- [Compose Multiplatform](https://jb.gg/compose) for UI
- [Ktor](https://ktor.io/) for networking
- [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) for JSON handling
- [Kamel](https://github.com/Kamel-Media/Kamel) for image loading
- [Coil](https://github.com/coil-kt/coil) for image loading
- [moko-resources](https://github.com/icerockdev/moko-resources) for string resources
- [Koin](https://github.com/InsertKoinIO/koin) for dependency injection
- [Voyager](https://github.com/adrielcafe/voyager) for navigation and screen models
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ androidx-activityCompose = "1.9.2"
androidx-ui-tooling = "1.7.0"
androidx-lifecycle = "2.8.4"
coroutines = "1.8.1"
kamel = "0.9.5"
coil = "3.0.0"
koin = "3.5.6"
ktor = "2.3.12"
voyager = "1.0.0"
Expand All @@ -12,7 +12,8 @@ voyager = "1.0.0"
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-ui-tooling" }
androidx-lifecycle-runtime-compose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
kamel = { module = "media.kamel:kamel-image", version.ref = "kamel" }
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
coil-network-ktor = { group = "io.coil-kt.coil3", name = "coil-network-ktor3", version.ref = "coil" }
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
Expand Down
3 changes: 2 additions & 1 deletion shared/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ dependencies:
- $libs.ktor.client.core
- $libs.ktor.client.content.negotiation
- $libs.ktor.serialization.kotlinx.json
- $libs.kamel
- $libs.coil.compose
- $libs.coil.network.ktor
- $libs.koin.core
- $libs.voyager.navigator
- $libs.voyager.koin
Expand Down
7 changes: 3 additions & 4 deletions shared/src/screens/detail/DetailScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.koin.getScreenModel
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import coil3.compose.AsyncImage
import com.jetbrains.kmpapp.data.MuseumObject
import com.jetbrains.kmpapp.screens.EmptyScreenContent
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource

data class DetailScreen(val objectId: Int) : Screen {
@Composable
Expand Down Expand Up @@ -85,8 +84,8 @@ private fun ObjectDetails(
.verticalScroll(rememberScrollState())
.padding(paddingValues)
) {
KamelImage(
resource = asyncPainterResource(data = obj.primaryImageSmall),
AsyncImage(
model = obj.primaryImageSmall,
contentDescription = obj.title,
contentScale = ContentScale.FillWidth,
modifier = Modifier
Expand Down
7 changes: 3 additions & 4 deletions shared/src/screens/list/ListScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.koin.getScreenModel
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import coil3.compose.AsyncImage
import com.jetbrains.kmpapp.data.MuseumObject
import com.jetbrains.kmpapp.screens.EmptyScreenContent
import com.jetbrains.kmpapp.screens.detail.DetailScreen
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource

data object ListScreen : Screen {
@Composable
Expand Down Expand Up @@ -94,8 +93,8 @@ private fun ObjectFrame(
.padding(8.dp)
.clickable { onClick() }
) {
KamelImage(
resource = asyncPainterResource(data = obj.primaryImageSmall),
AsyncImage(
model = obj.primaryImageSmall,
contentDescription = obj.title,
contentScale = ContentScale.Crop,
modifier = Modifier
Expand Down