From 07b5ef4b42e9fae801bb82fbea4444b8571fb8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9luchu?= Date: Wed, 5 Jul 2023 17:46:00 +0200 Subject: [PATCH] Include BlurImage --- gradle/libs.versions.toml | 10 ++--- jchucomponents-core/build.gradle | 2 +- jchucomponents-ktx/build.gradle | 2 +- jchucomponents-qr/build.gradle | 2 +- jchucomponents-ui/build.gradle | 2 +- .../ui/composables/images/BlurImage.kt | 45 +++++++++++++++++++ 6 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/composables/images/BlurImage.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cb9076f6..6f2b79b0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,10 +10,10 @@ androidx-navigation = "2.6.0" com-google-accompanist = "0.30.1" com-squareup-okhttp3 = "4.11.0" com-squareup-retrofit2 = "2.9.0" -io-coil-kt = "2.3.0" +io-coil-kt = "2.4.0" org-jetbrains-kotlin = "1.8.21" -org-jetbrains-kotlinx = "1.7.0" -billing-ktx = "6.0.0" +org-jetbrains-kotlinx = "1.7.2" +billing-ktx = "6.0.1" [libraries] androidx-activity-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } @@ -23,7 +23,7 @@ androidx-compose-foundation = { module = "androidx.compose.foundation:foundation androidx-compose-foundation-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "androidx-compose-foundation" } androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "androidx-compose-material" } androidx-compose-material-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "androidx-compose-material" } -androidx-compose-material3 = "androidx.compose.material3:material3:1.1.0" +androidx-compose-material3 = "androidx.compose.material3:material3:1.1.1" androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "androidx-compose-runtime" } androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "androidx-compose-ui" } androidx-compose-ui-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "androidx-compose-ui" } @@ -49,7 +49,7 @@ org-jetbrains-kotlin-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kot org-jetbrains-kotlinx-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "org-jetbrains-kotlinx" } org-jetbrains-kotlinx-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "org-jetbrains-kotlinx" } com-android-billingclient-billing-ktx = { module = "com.android.billingclient:billing-ktx", version.ref = "billing-ktx" } -firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version = "2.9.5" } +firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version = "2.9.6" } [bundles] core-androidx = [ diff --git a/jchucomponents-core/build.gradle b/jchucomponents-core/build.gradle index ecb97248..37a2e510 100644 --- a/jchucomponents-core/build.gradle +++ b/jchucomponents-core/build.gradle @@ -77,7 +77,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-core" - version = "1.5.2" + version = "1.5.3" } } } diff --git a/jchucomponents-ktx/build.gradle b/jchucomponents-ktx/build.gradle index 10186ff1..eab0ef3d 100644 --- a/jchucomponents-ktx/build.gradle +++ b/jchucomponents-ktx/build.gradle @@ -64,7 +64,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-ktx" - version = "1.5.2" + version = "1.5.3" } } } diff --git a/jchucomponents-qr/build.gradle b/jchucomponents-qr/build.gradle index 555de9fe..2dde64c6 100644 --- a/jchucomponents-qr/build.gradle +++ b/jchucomponents-qr/build.gradle @@ -59,7 +59,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-qr" - version = "1.5.2" + version = "1.5.3" } } } diff --git a/jchucomponents-ui/build.gradle b/jchucomponents-ui/build.gradle index f74da4aa..3e39c340 100644 --- a/jchucomponents-ui/build.gradle +++ b/jchucomponents-ui/build.gradle @@ -66,7 +66,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-ui" - version = "1.5.2" + version = "1.5.3" } } } diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/composables/images/BlurImage.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/composables/images/BlurImage.kt new file mode 100644 index 00000000..81e0c0a8 --- /dev/null +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/composables/images/BlurImage.kt @@ -0,0 +1,45 @@ +package com.jeluchu.jchucomponents.ui.composables.images + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.DefaultAlpha +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.jeluchu.jchucomponents.ui.composables.images.transformations.BlurTransformation + +@Composable +fun BlurImage( + url: Any, + modifier: Modifier = Modifier, + isCrossfade: Boolean = true, + isAllowHardware: Boolean = true, + alpha: Float = DefaultAlpha, + blurTransformation: BlurImageTransformation = BlurImageTransformation(), + contentScale: ContentScale = ContentScale.Crop, + contentDescription: String? = null +) = AsyncImage( + modifier = modifier, + model = ImageRequest.Builder(LocalContext.current) + .data(url) + .transformations( + BlurTransformation( + scale = blurTransformation.scale, + radius = blurTransformation.radius + ) + ) + .crossfade(isCrossfade) + .allowHardware(isAllowHardware) + .build(), + alpha = alpha, + contentScale = contentScale, + contentDescription = null +) + +@Immutable +class BlurImageTransformation( + val scale: Float = 0.5f, + val radius: Int = 25 +) \ No newline at end of file