Skip to content

Commit

Permalink
👽️ Manage more AsyncImage signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceglb committed Jan 14, 2025
1 parent 93f368d commit cc22f61
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down

0 comments on commit cc22f61

Please sign in to comment.