From dded4f529fe365da892616e4f1e2ea007c4a0b72 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:04:08 -0600 Subject: [PATCH] refactor(ui): refactor glow effect drawing (#3988) --- .../main/java/com/geeksville/mesh/ui/Main.kt | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/Main.kt b/app/src/main/java/com/geeksville/mesh/ui/Main.kt index fd22b1da5..bf1235d79 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/Main.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/Main.kt @@ -322,27 +322,30 @@ fun MainScreen(uIViewModel: UIViewModel = hiltViewModel(), scanModel: BTScanMode Box( modifier = Modifier.drawWithCache { + val glowRadius = size.minDimension + val glowBrush = + Brush.radialGradient( + colors = + listOf( + currentGlowColor.copy(alpha = 0.8f), + currentGlowColor.copy(alpha = 0.4f), + Color.Transparent, + ), + center = + androidx.compose.ui.geometry.Offset( + size.width / 2, + size.height / 2, + ), + radius = glowRadius, + ) onDrawWithContent { drawContent() - if (animatedGlowAlpha.value > 0f) { - val glowRadius = size.minDimension + val alpha = animatedGlowAlpha.value + if (alpha > 0f) { drawCircle( - brush = - Brush.radialGradient( - colors = - listOf( - currentGlowColor.copy( - alpha = 0.8f * animatedGlowAlpha.value, - ), - currentGlowColor.copy( - alpha = 0.4f * animatedGlowAlpha.value, - ), - Color.Transparent, - ), - center = center, - radius = glowRadius, - ), + brush = glowBrush, radius = glowRadius, + alpha = alpha, blendMode = BlendMode.Screen, ) }