ImageTool is a Kotlin multiplatform library that provides the ability to download and cache images from network, storage and etc. Now library available on Android and IOS platforms
For Kotlin DSL :
implementation("io.github.tanexc:imagetool:[version]")For Groovy DSL :
implementation "io.github.tanexc:imagetool:[version]"For libs.version.toml :
Add implementation(libs.imagetool) to build.gradle.kts and
[versions]
imagetool-version="version"
#...
[libraries]
#...
imagetool = { module = "io.github.tanexc:imagetool", version.ref = "imagetool-version" }
At this moment available just one widget to use:
@Composable
fun ComposeImage(
model: String,
contentDescription: String?,
modifier: Modifier = Modifier,
alignment: Alignment = Alignment.Center,
contentScale: ContentScale = ContentScale.Fit,
alpha: Float = DefaultAlpha,
colorFilter: ColorFilter? = null,
filterQuality: FilterQuality = DefaultFilterQuality,
cacheQuality: CacheQuality = CacheQuality.NoCompressing,
onLoading: @Composable BoxScope.(progress: Float) -> Unit,
onError: @Composable BoxScope.() -> Unit,
)model - String URL to get image from network
contentDescription - Description of the image
modififer - Modifier that will be applied to box where image lies
alignment - Optional alignment parameter used to place the ImageBitmap in the given bounds defined by the width and height
contentScale - Represents a rule to apply to scale a source image to be inscribed into the box
alpha - Optional opacity to be applied to the ImageBitmap when it is rendered on screen
colorFilter - Optional ColorFilter to apply for the image when it is rendered
filterQuality - Sampling algorithm applied to the bitmap when it is scaled and drawn into the destination. The default is FilterQuality. Low which scales using a bilinear sampling algorithm
cacheQuality - Optional cache quality parameter used to set quality of cached image. Can be CacheQuality.NoCaching that says image would not be cached
onLoading - Composable that will be displayed on loading. Receives float progress from 0.0 to 1.0
onError - Composable that will be displayed when loading failed. Receives Throwable that represents Exception has been caught
- Add more type to use as model for image
- Add more target platfroms
-
Kotlin Multiplatform and Compose Multiplatform based
-
Coroutines for asynchronous work
-
Coin for dependency injection
-
Ktor for work with network
-
Gradle Maven publish plugin by vanniktech is the amazing plugin for easy publishing to maven central
Contact me here:
Support it by joining stargazers for this repository. ⭐
And follow me!
Designed and developed by 2024 Tanexc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.