From cf5140842dcf5d49f358d49c72a847a867c68fad Mon Sep 17 00:00:00 2001 From: Brandon McAnsh Date: Fri, 26 Jun 2026 17:48:25 -0400 Subject: [PATCH] feat: drop Cloudy; use Haze for blur effect when highlighting access key Signed-off-by: Brandon McAnsh --- .../internal/BackupKeyScreenContent.kt | 8 +-- .../features/discovery/build.gradle.kts | 2 - .../screens/AccessKeyScreenContent.kt | 4 +- .../internal/ShareAppScreenContent.kt | 4 +- .../flipcash/features/tokens/build.gradle.kts | 2 - .../app/accesskey/BaseAccessKeyViewModel.kt | 27 +++++----- gradle/libs.versions.toml | 2 - ui/components/build.gradle.kts | 2 +- .../getcode/ui/components/BlurredContent.kt | 52 +++++++++++++++++++ .../com/getcode/ui/components/Cloudy.kt | 21 -------- 10 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 ui/components/src/main/kotlin/com/getcode/ui/components/BlurredContent.kt delete mode 100644 ui/components/src/main/kotlin/com/getcode/ui/components/Cloudy.kt diff --git a/apps/flipcash/features/backupkey/src/main/kotlin/com/flipcash/app/backupkey/internal/BackupKeyScreenContent.kt b/apps/flipcash/features/backupkey/src/main/kotlin/com/flipcash/app/backupkey/internal/BackupKeyScreenContent.kt index 641a70e01..88d087298 100644 --- a/apps/flipcash/features/backupkey/src/main/kotlin/com/flipcash/app/backupkey/internal/BackupKeyScreenContent.kt +++ b/apps/flipcash/features/backupkey/src/main/kotlin/com/flipcash/app/backupkey/internal/BackupKeyScreenContent.kt @@ -44,7 +44,7 @@ import com.flipcash.features.backupkey.R import com.getcode.manager.BottomBarAction import com.getcode.manager.BottomBarManager import com.getcode.theme.CodeTheme -import com.getcode.ui.components.Cloudy +import com.getcode.ui.components.BlurredContent import com.getcode.ui.components.SelectionContainer import com.getcode.ui.components.rememberSelectionState import com.getcode.ui.core.addIf @@ -122,7 +122,7 @@ internal fun BackupKeyScreenContent(viewModel: BackupKeyScreenViewModel) { .windowInsetsPadding(WindowInsets.navigationBars), state = selectionState, ) { - Cloudy( + BlurredContent( modifier = Modifier .fillMaxSize(), enabled = selectionState.shown @@ -187,9 +187,9 @@ internal fun BackupKeyScreenContent(viewModel: BackupKeyScreenViewModel) { dataState.accessKeyCroppedBitmap?.let { bitmap -> Image( modifier = Modifier + .scale(selectionState.scale.value) .fillMaxWidth() - .weight(1f) - .scale(selectionState.scale.value), + .weight(1f), bitmap = bitmap.asImageBitmap(), contentScale = ContentScale.Crop, contentDescription = dataState.wordsFormatted, diff --git a/apps/flipcash/features/discovery/build.gradle.kts b/apps/flipcash/features/discovery/build.gradle.kts index 5a38231e3..5875ff709 100644 --- a/apps/flipcash/features/discovery/build.gradle.kts +++ b/apps/flipcash/features/discovery/build.gradle.kts @@ -7,8 +7,6 @@ android { } dependencies { - implementation(libs.bundles.haze) - implementation(project(":apps:flipcash:shared:analytics")) implementation(project(":apps:flipcash:shared:featureflags")) implementation(project(":apps:flipcash:shared:shareable")) diff --git a/apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/internal/screens/AccessKeyScreenContent.kt b/apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/internal/screens/AccessKeyScreenContent.kt index 0c741b026..5db82a529 100644 --- a/apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/internal/screens/AccessKeyScreenContent.kt +++ b/apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/internal/screens/AccessKeyScreenContent.kt @@ -54,7 +54,7 @@ import com.getcode.manager.BottomBarManager import com.getcode.navigation.core.LocalCodeNavigator import com.getcode.theme.CodeTheme import com.getcode.theme.White -import com.getcode.ui.components.Cloudy +import com.getcode.ui.components.BlurredContent import com.getcode.ui.components.SelectionContainer import com.getcode.ui.components.rememberSelectionState import com.getcode.ui.core.addIf @@ -174,7 +174,7 @@ private fun AccessKeyScreenContent( .windowInsetsPadding(WindowInsets.navigationBars), state = selectionState, ) { - Cloudy( + BlurredContent( modifier = Modifier .fillMaxSize(), enabled = selectionState.shown diff --git a/apps/flipcash/features/shareapp/src/main/kotlin/com/flipcash/app/shareapp/internal/ShareAppScreenContent.kt b/apps/flipcash/features/shareapp/src/main/kotlin/com/flipcash/app/shareapp/internal/ShareAppScreenContent.kt index a3755a536..59c0cf559 100644 --- a/apps/flipcash/features/shareapp/src/main/kotlin/com/flipcash/app/shareapp/internal/ShareAppScreenContent.kt +++ b/apps/flipcash/features/shareapp/src/main/kotlin/com/flipcash/app/shareapp/internal/ShareAppScreenContent.kt @@ -36,7 +36,7 @@ import com.flipcash.features.shareapp.R import com.getcode.libs.qr.rememberQrBitmapPainter import com.getcode.navigation.core.LocalCodeNavigator import com.getcode.theme.CodeTheme -import com.getcode.ui.components.Cloudy +import com.getcode.ui.components.BlurredContent import com.getcode.ui.components.SelectionContainer import com.getcode.ui.components.rememberSelectionState import com.getcode.ui.core.longClickable @@ -67,7 +67,7 @@ internal fun ShareAppScreenContent() { contentRect = contentRect, state = selectionState, ) { onClick -> - Cloudy( + BlurredContent( modifier = Modifier .fillMaxSize(), enabled = selectionState.shown diff --git a/apps/flipcash/features/tokens/build.gradle.kts b/apps/flipcash/features/tokens/build.gradle.kts index e9afa0f5e..66b92f74a 100644 --- a/apps/flipcash/features/tokens/build.gradle.kts +++ b/apps/flipcash/features/tokens/build.gradle.kts @@ -7,8 +7,6 @@ android { } dependencies { - implementation(libs.bundles.haze) - implementation(project(":apps:flipcash:shared:amount-entry")) implementation(project(":apps:flipcash:shared:analytics")) implementation(project(":apps:flipcash:shared:onramp:coinbase")) diff --git a/apps/flipcash/shared/accesskey/src/main/kotlin/com/flipcash/app/accesskey/BaseAccessKeyViewModel.kt b/apps/flipcash/shared/accesskey/src/main/kotlin/com/flipcash/app/accesskey/BaseAccessKeyViewModel.kt index 5d767e381..a48f66b69 100644 --- a/apps/flipcash/shared/accesskey/src/main/kotlin/com/flipcash/app/accesskey/BaseAccessKeyViewModel.kt +++ b/apps/flipcash/shared/accesskey/src/main/kotlin/com/flipcash/app/accesskey/BaseAccessKeyViewModel.kt @@ -82,23 +82,26 @@ abstract class BaseAccessKeyViewModel( val words = mnemonicManager.fromEntropyBase64(entropyB64).words val wordsFormatted = getAccessKeyText(words).joinToString("\n") - uiFlow.value = uiFlow.value.copy( - entropyB64 = entropyB64, - words = words, - wordsFormatted = wordsFormatted - ) + uiFlow.update { + it.copy( + entropyB64 = entropyB64, + words = words, + wordsFormatted = wordsFormatted + ) + } viewModelScope.launch(dispatchers.IO) { - val accessKeyBitmap = createBitmapForExport(words = words, entropyB64 = entropyB64) - val accessKeyBitmapDisplay = - createBitmapForExport(drawBackground = true, words, entropyB64) + val accessKeyBitmap = createBitmapForExport(drawBackground = true, words = words, entropyB64 = entropyB64) + val accessKeyBitmapDisplay = createBitmapForExport(drawBackground = false, words, entropyB64) val accessKeyCroppedBitmap = Bitmap.createBitmap(accessKeyBitmapDisplay, 0, 500, 1200, 1450) - uiFlow.value = uiFlow.value.copy( - accessKeyBitmap = accessKeyBitmap, - accessKeyCroppedBitmap = accessKeyCroppedBitmap - ) + uiFlow.update { + it.copy( + accessKeyBitmap = accessKeyBitmap, + accessKeyCroppedBitmap = accessKeyCroppedBitmap + ) + } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c8fff4458..7991b6fe6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -93,7 +93,6 @@ bugsnag-gradle-plugin = "1.1.0" rinku = "1.6.0" compose-unstyled = "2.8.0" haze = "2.0.0-alpha03" -cloudy = "0.5.0" phantom-connect-kmp = "2.0.2-1.0.0" vico = "3.2.3" @@ -258,7 +257,6 @@ sodium-bindings = { module = "com.ionspin.kotlin:multiplatform-crypto-libsodium- eddsa = { module = "net.i2p.crypto:eddsa", version = "0.3.0" } # Misc -cloudy = { module = "com.github.skydoves:cloudy", version.ref = "cloudy" } fingerprint-pro = { module = "com.fingerprint.android:pro", version = "2.4.0" } haze = { module = "dev.chrisbanes.haze:haze", version.ref = "haze" } haze-blur = { module = "dev.chrisbanes.haze:haze-blur", version.ref = "haze" } diff --git a/ui/components/build.gradle.kts b/ui/components/build.gradle.kts index 936547819..8b30a1f90 100644 --- a/ui/components/build.gradle.kts +++ b/ui/components/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { implementation(project(":ui:emojis")) implementation(project(":ui:theme")) implementation(project(":ui:resources")) - api(libs.cloudy) + implementation(libs.coil3) implementation(libs.coil3.network) implementation(libs.kotlinx.datetime) diff --git a/ui/components/src/main/kotlin/com/getcode/ui/components/BlurredContent.kt b/ui/components/src/main/kotlin/com/getcode/ui/components/BlurredContent.kt new file mode 100644 index 000000000..c4212b539 --- /dev/null +++ b/ui/components/src/main/kotlin/com/getcode/ui/components/BlurredContent.kt @@ -0,0 +1,52 @@ +package com.getcode.ui.components + +import androidx.annotation.IntRange +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.getcode.theme.CodeTheme +import dev.chrisbanes.haze.blur.blurEffect +import dev.chrisbanes.haze.blur.materials.HazeMaterials +import dev.chrisbanes.haze.hazeEffect +import dev.chrisbanes.haze.hazeSource +import dev.chrisbanes.haze.rememberHazeState + +@Composable +fun Cloudy( + modifier: Modifier = Modifier, + enabled: Boolean = true, + @IntRange(from = 0, to = 25) radius: Int = 25, + containerColor: Color = CodeTheme.colors.background, + content: @Composable BoxScope.() -> Unit +) { + val blurRadius by animateDpAsState( + targetValue = if (enabled) radius.dp else 0.dp, + label = "blur radius" + ) + + val hazeState = rememberHazeState() + val material = HazeMaterials.regular(containerColor = containerColor) + + Box(modifier) { + Box(Modifier.hazeSource(hazeState)) { + content() + } + if (enabled) { + Box( + Modifier + .matchParentSize() + .hazeEffect(hazeState) { + blurEffect { + this.blurRadius = blurRadius + style = material + } + } + ) + } + } +} diff --git a/ui/components/src/main/kotlin/com/getcode/ui/components/Cloudy.kt b/ui/components/src/main/kotlin/com/getcode/ui/components/Cloudy.kt deleted file mode 100644 index b05cd57fd..000000000 --- a/ui/components/src/main/kotlin/com/getcode/ui/components/Cloudy.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.getcode.ui.components - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.BoxScope -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import com.skydoves.cloudy.CloudyState -import com.skydoves.cloudy.cloudy - -@Composable -fun Cloudy( - modifier: Modifier = Modifier, - enabled: Boolean = true, - @androidx.annotation.IntRange(from = 0, to = 25) radius: Int = 25, - onStateChanged: (CloudyState) -> Unit = {}, - content: @Composable BoxScope.() -> Unit -) { - Box(modifier.cloudy(enabled = enabled, radius = radius, onStateChanged = onStateChanged)) { - content() - } -} \ No newline at end of file