Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

feat: complete porting of reference AndroidLiquidGlass-kmp catalog components (LiquidBottomTabs, LiquidButton, LiquidSlider, LiquidToggle)

Chethan616804f0fe25fb3
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
index 7fc2a19..8a94792 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt
@@ -67,8 +67,8 @@ fun LiquidBottomTabs(
) {
val isDarkMode = LocalIsDarkMode.current
val isLightTheme = !isDarkMode
- val accentColor = Color(0xFF0A84FF)
- val containerColor = if (isLightTheme) Color.White.copy(0.40f) else Color(0xFF111216).copy(0.48f)
+ val accentColor = if (isLightTheme) Color(0xFF0088FF) else Color(0xFF0091FF)
+ val containerColor = if (isLightTheme) Color(0xFFFAFAFA).copy(0.40f) else Color(0xFF121212).copy(0.40f)
val tabsBackdrop = rememberLayerBackdrop()
@@ -163,8 +163,8 @@ fun LiquidBottomTabs(
shape = { Capsule },
effects = {
vibrancy()
- blur(6f.dp.toPx())
- lens(18f.dp.toPx(), 20f.dp.toPx())
+ blur(8f.dp.toPx())
+ lens(24f.dp.toPx(), 24f.dp.toPx())
},
layerBlock = {
val progress = dampedDragAnimation.pressProgress
@@ -200,7 +200,7 @@ fun LiquidBottomTabs(
effects = {
val progress = dampedDragAnimation.pressProgress
vibrancy()
- blur(6f.dp.toPx())
+ blur(8f.dp.toPx())
lens(
24f.dp.toPx() * progress,
24f.dp.toPx() * progress
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt
index 00d7c03..bb29e4a 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidButton.kt
@@ -1,6 +1,7 @@
package com.chethan616.clearpdf.ui.components
import androidx.compose.foundation.clickable
+import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
@@ -126,7 +127,7 @@ fun LiquidButton(
)
.clickable(
interactionSource = null,
- indication = null,
+ indication = if (isInteractive) null else LocalIndication.current,
role = Role.Button,
onClick = onClick
)
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt
index 50088ef..4c603bf 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt
@@ -136,7 +136,7 @@ fun LiquidSlider(
onValueChangeState.value(targetValue)
}
}
- .height(8f.dp)
+ .height(6f.dp)
.fillMaxWidth()
)
@@ -144,7 +144,7 @@ fun LiquidSlider(
Modifier
.clip(Capsule)
.background(accentColor)
- .height(8f.dp)
+ .height(6f.dp)
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
val width = (constraints.maxWidth * dampedDragAnimation.progress).fastRoundToInt()
@@ -176,14 +176,12 @@ fun LiquidSlider(
shape = { Capsule },
effects = {
val progress = dampedDragAnimation.pressProgress
- // Optimize blur & lens effect dynamically when dragging to avoid dropped frames (120fps smooth performance)
- val blurPx = if (isDragging) 2f.dp.toPx() else (5f.dp.toPx() * (1f - progress))
- val lensRad = if (isDragging) 4f.dp.toPx() else (10f.dp.toPx() * progress)
- blur(blurPx)
+ // Reference catalog recipe: soft blur at rest, refraction on press.
+ blur(8f.dp.toPx() * (1f - progress))
lens(
- lensRad,
- lensRad * 1.4f,
- chromaticAberration = !isDragging
+ 10f.dp.toPx() * progress,
+ 14f.dp.toPx() * progress,
+ chromaticAberration = true
)
},
highlight = {
@@ -191,7 +189,7 @@ fun LiquidSlider(
Highlight.Ambient.copy(
width = Highlight.Ambient.width / 1.5f,
blurRadius = Highlight.Ambient.blurRadius / 1.5f,
- alpha = 0.42f + (progress * 0.58f)
+ alpha = progress
)
},
shadow = {
@@ -213,7 +211,7 @@ fun LiquidSlider(
drawRect(Color.White.copy(alpha = 1f - progress))
}
)
- .size(44f.dp, 28f.dp)
+ .size(40f.dp, 24f.dp)
)
}
}