mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 12:57:04 +05:30
android: use AsyncImage for images
* Coil recommends using clip instead of CircleCropTransformation for compose. * Enable crossfade by default * Allow caching images * Run spotlessApply Closes #320 Signed-off-by: Rahul Krishna <Rahulkrishna585@gmail.com>
This commit is contained in:
parent
bb2213ff86
commit
642484a9a9
4 changed files with 29 additions and 19 deletions
|
@ -1,31 +1,20 @@
|
|||
package dev.msfjarvis.claw.common.ui
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import coil.annotation.ExperimentalCoilApi
|
||||
import coil.compose.rememberAsyncImagePainter
|
||||
import coil.request.ImageRequest
|
||||
import coil.transform.CircleCropTransformation
|
||||
import androidx.compose.ui.draw.clip
|
||||
import coil.compose.AsyncImage
|
||||
|
||||
@Composable
|
||||
@OptIn(ExperimentalCoilApi::class)
|
||||
actual fun NetworkImage(
|
||||
url: String,
|
||||
contentDescription: String,
|
||||
modifier: Modifier,
|
||||
) {
|
||||
Image(
|
||||
painter =
|
||||
rememberAsyncImagePainter(
|
||||
ImageRequest.Builder(LocalContext.current)
|
||||
.data(data = url)
|
||||
.transformations(CircleCropTransformation())
|
||||
.crossfade(true)
|
||||
.build()
|
||||
),
|
||||
AsyncImage(
|
||||
model = url,
|
||||
contentDescription = contentDescription,
|
||||
modifier = modifier,
|
||||
modifier = modifier.clip(CircleShape)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue