diff --git a/filekit-coil/src/commonMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.kt b/filekit-coil/src/commonMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.kt index 39f54cf..201e0c1 100644 --- a/filekit-coil/src/commonMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.kt +++ b/filekit-coil/src/commonMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.kt @@ -37,6 +37,41 @@ public expect fun AsyncImage( clipToBounds: Boolean = true, ) +@Composable +public expect fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + modifier: Modifier = Modifier, + placeholder: Painter? = null, + error: Painter? = null, + fallback: Painter? = error, + onLoading: ((State.Loading) -> Unit)? = null, + onSuccess: ((State.Success) -> Unit)? = null, + onError: ((State.Error) -> Unit)? = null, + alignment: Alignment = Alignment.Center, + contentScale: ContentScale = ContentScale.Fit, + alpha: Float = DefaultAlpha, + colorFilter: ColorFilter? = null, + filterQuality: FilterQuality = DefaultFilterQuality, + clipToBounds: Boolean = true, +) + +@Composable +public expect fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + imageLoader: ImageLoader, + modifier: Modifier = Modifier, + transform: (State) -> State = DefaultTransform, + onState: ((State) -> Unit)? = null, + alignment: Alignment = Alignment.Center, + contentScale: ContentScale = ContentScale.Fit, + alpha: Float = DefaultAlpha, + colorFilter: ColorFilter? = null, + filterQuality: FilterQuality = DefaultFilterQuality, + clipToBounds: Boolean = true, +) + @Composable public expect fun AsyncImage( file: PlatformFile?, diff --git a/filekit-coil/src/nonWebMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.nonWeb.kt b/filekit-coil/src/nonWebMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.nonWeb.kt index 66fb51c..760c6a3 100644 --- a/filekit-coil/src/nonWebMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.nonWeb.kt +++ b/filekit-coil/src/nonWebMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.nonWeb.kt @@ -60,6 +60,79 @@ public actual fun AsyncImage( ) } +@Composable +public actual fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + modifier: Modifier, + placeholder: Painter?, + error: Painter?, + fallback: Painter?, + onLoading: ((State.Loading) -> Unit)?, + onSuccess: ((State.Success) -> Unit)?, + onError: ((State.Error) -> Unit)?, + alignment: Alignment, + contentScale: ContentScale, + alpha: Float, + colorFilter: ColorFilter?, + filterQuality: FilterQuality, + clipToBounds: Boolean +) { + AsyncImagePlatformEffects(file) + + coil3.compose.AsyncImage( + model = file?.coilModel, + contentDescription = contentDescription, + imageLoader = SingletonImageLoader.get(LocalPlatformContext.current), + modifier = modifier, + placeholder = placeholder, + error = error, + fallback = fallback, + onLoading = onLoading, + onSuccess = onSuccess, + onError = onError, + alignment = alignment, + contentScale = contentScale, + alpha = alpha, + colorFilter = colorFilter, + filterQuality = filterQuality, + clipToBounds = clipToBounds, + ) +} + +@Composable +public actual fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + imageLoader: ImageLoader, + modifier: Modifier, + transform: (State) -> State, + onState: ((State) -> Unit)?, + alignment: Alignment, + contentScale: ContentScale, + alpha: Float, + colorFilter: ColorFilter?, + filterQuality: FilterQuality, + clipToBounds: Boolean +) { + AsyncImagePlatformEffects(file) + + coil3.compose.AsyncImage( + model = file?.coilModel, + contentDescription = contentDescription, + imageLoader = imageLoader, + modifier = modifier, + transform = transform, + onState = onState, + alignment = alignment, + contentScale = contentScale, + alpha = alpha, + colorFilter = colorFilter, + filterQuality = filterQuality, + clipToBounds = clipToBounds, + ) +} + @Composable public actual fun AsyncImage( file: PlatformFile?, diff --git a/filekit-coil/src/webMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.web.kt b/filekit-coil/src/webMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.web.kt index c19cca4..fc71b52 100644 --- a/filekit-coil/src/webMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.web.kt +++ b/filekit-coil/src/webMain/kotlin/io/github/vinceglb/filekit/coil/FileKitCoil.web.kt @@ -69,6 +69,78 @@ public actual fun AsyncImage( ) } +@Composable +public actual fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + modifier: Modifier, + placeholder: Painter?, + error: Painter?, + fallback: Painter?, + onLoading: ((AsyncImagePainter.State.Loading) -> Unit)?, + onSuccess: ((AsyncImagePainter.State.Success) -> Unit)?, + onError: ((AsyncImagePainter.State.Error) -> Unit)?, + alignment: Alignment, + contentScale: ContentScale, + alpha: Float, + colorFilter: ColorFilter?, + filterQuality: FilterQuality, + clipToBounds: Boolean +) { + val model = rememberPlatformFileCoilModel(file) + + coil3.compose.AsyncImage( + model = model, + contentDescription = contentDescription, + modifier = modifier, + placeholder = placeholder, + error = error, + fallback = fallback, + onLoading = onLoading, + onSuccess = onSuccess, + onError = onError, + alignment = alignment, + contentScale = contentScale, + alpha = alpha, + colorFilter = colorFilter, + filterQuality = filterQuality, + clipToBounds = clipToBounds, + ) +} + +@Composable +public actual fun AsyncImage( + file: PlatformFile?, + contentDescription: String?, + imageLoader: ImageLoader, + modifier: Modifier, + transform: (AsyncImagePainter.State) -> AsyncImagePainter.State, + onState: ((AsyncImagePainter.State) -> Unit)?, + alignment: Alignment, + contentScale: ContentScale, + alpha: Float, + colorFilter: ColorFilter?, + filterQuality: FilterQuality, + clipToBounds: Boolean +) { + val model = rememberPlatformFileCoilModel(file) + + coil3.compose.AsyncImage( + model = model, + contentDescription = contentDescription, + imageLoader = imageLoader, + modifier = modifier, + transform = transform, + onState = onState, + alignment = alignment, + contentScale = contentScale, + alpha = alpha, + colorFilter = colorFilter, + filterQuality = filterQuality, + clipToBounds = clipToBounds, + ) +} + @Composable public actual fun AsyncImage( file: PlatformFile?,