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

🔧 The problem of flickering icons has been addressed by caching ImageRequests. #923

Merged
merged 3 commits into from
Sep 2, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.droidkaigi.confsched.droidkaigiui.component

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.LocalContext
import coil3.request.ImageRequest
Expand All @@ -10,13 +11,17 @@ import io.github.droidkaigi.confsched.droidkaigiui.rememberAsyncImagePainter

@Composable
actual fun speakerPainter(url: String): Painter {
// TODO Use DrawableResource
// https://github.com/DroidKaigi/conference-app-2024/pull/864/files#r1736437080
// https://github.com/coil-kt/coil/issues/2077
return rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
val context = LocalContext.current

val imageRequest = remember(url, context) {
// TODO Use DrawableResource
// https://github.com/DroidKaigi/conference-app-2024/pull/864/files#r1736437080
// https://github.com/coil-kt/coil/issues/2077
ImageRequest.Builder(context)
.data(url)
.placeholder(R.drawable.icon_place_hoolder)
.build(),
)
.build()
}

return rememberAsyncImagePainter(model = imageRequest)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.droidkaigi.confsched.droidkaigiui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.painter.Painter
import coil3.request.ImageRequest

Expand All @@ -13,7 +14,9 @@ fun rememberAsyncImagePainter(url: String): Painter {

@Composable
fun rememberAsyncImagePainter(model: ImageRequest): Painter {
val requestModel = remember(model) { model }

return coil3.compose.rememberAsyncImagePainter(
model = model,
model = requestModel,
)
}
Loading