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.

Spreadsheet: glass-bead colour palette, liquid row presses (no ripples) in editor panels and list dropdown, no grid/picker shadows

Chethan616b027a4669102
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassBead.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassBead.kt
new file mode 100644
index 0000000..8b5e188
--- /dev/null
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassBead.kt
@@ -0,0 +1,99 @@
+package com.chethan616.clearpdf.ui.components
+
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.spring
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.interaction.collectIsPressedAsState
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.size
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.rounded.Check
+import androidx.compose.material3.Icon
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.drawBehind
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.drawscope.Stroke
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.graphics.luminance
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.unit.dp
+
+/**
+ * A colour swatch in the liquid-glass family — a vivid tinted bead with a specular top-left glint, a
+ * light-to-dark rim and inner depth, springing down under the finger and up when selected — drawn
+ * entirely in one `drawBehind` (no backdrop sampling), so a palette of 80 of them stays free to show
+ * and scroll. Use real [LiquidIconButton] beads only for short rows (under ~10).
+ */
+@Composable
+fun GlassBead(
+ color: Color,
+ selected: Boolean,
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ contentDescription: String? = null
+) {
+ val interaction = remember { MutableInteractionSource() }
+ val pressed by interaction.collectIsPressedAsState()
+ val scale by animateFloatAsState(
+ when {
+ pressed -> 0.84f
+ selected -> 1.1f
+ else -> 1f
+ },
+ spring(dampingRatio = 0.45f, stiffness = 520f),
+ label = "beadScale"
+ )
+ Box(
+ modifier
+ .graphicsLayer { scaleX = scale; scaleY = scale }
+ .drawBehind {
+ val r = size.minDimension / 2f
+ val c = center
+ // Body: the "Get it" vivid recipe — a soft white base under the tint.
+ drawCircle(Color.White.copy(alpha = 0.35f), r, c)
+ drawCircle(if (color.alpha < 1f) color else color.copy(alpha = 0.92f), r, c)
+ // Inner depth toward the bottom.
+ drawCircle(
+ Brush.verticalGradient(listOf(Color.Transparent, Color.Black.copy(alpha = 0.16f)), startY = c.y, endY = c.y + r),
+ r, c
+ )
+ // Specular glint, top-left.
+ drawCircle(
+ Brush.radialGradient(
+ listOf(Color.White.copy(alpha = 0.55f), Color.Transparent),
+ center = Offset(c.x - r * 0.35f, c.y - r * 0.45f),
+ radius = r * 0.8f
+ ),
+ r, c
+ )
+ // Rim: bright on top, faint underneath — the lens edge.
+ val w = 1.4.dp.toPx()
+ drawCircle(
+ Brush.verticalGradient(listOf(Color.White.copy(alpha = 0.9f), Color.White.copy(alpha = 0.12f))),
+ r - w / 2f, c, style = Stroke(w)
+ )
+ if (selected) drawCircle(Color.White, r - 1.6.dp.toPx(), c, style = Stroke(2.2.dp.toPx()))
+ }
+ .semantics { if (contentDescription != null) this.contentDescription = contentDescription }
+ .clickable(interactionSource = interaction, indication = null, role = Role.Button, onClick = onClick),
+ contentAlignment = Alignment.Center
+ ) {
+ if (selected) {
+ Icon(
+ Icons.Rounded.Check,
+ null,
+ Modifier.size(13.dp),
+ if (color.luminance() > 0.6f) Color.Black else Color.White
+ )
+ }
+ }
+}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassColorPicker.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassColorPicker.kt
index 5a7c037..c78477b 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassColorPicker.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassColorPicker.kt
@@ -217,7 +217,7 @@ fun GlassColorPicker(
lens(16f.dp.toPx(), 32f.dp.toPx(), depthEffect = true)
},
highlight = { Highlight.Plain },
- shadow = { Shadow(radius = 16f.dp, color = Color.Black.copy(alpha = 0.12f)) },
+ shadow = null,
onDrawSurface = { drawRect(containerColor) }
)
.padding(16.dp),
@@ -341,46 +341,15 @@ private fun SwatchRow(
return@forEach
}
val isSel = c.copy(alpha = 1f).toArgb() == selArgb
- val swatchShape = RoundedCornerShape(if (tight) 3.dp else 6.dp)
- Box(
- Modifier
- .weight(1f)
- .aspectRatio(if (tight) 1.25f else 1f)
- .clip(swatchShape)
- .background(c)
- .border(
- width = if (isSel) 2.dp else 0.5.dp,
- color = if (isSel) ring else outline,
- shape = swatchShape
- )
- .semantics { contentDescription = "#" + c.hex(false) }
- .clickable(role = Role.Button) { onPick(c) },
- contentAlignment = Alignment.Center
- ) {
- // Lightweight specular sheen ties the dense Office palette to ClearPDF's glass
- // controls without putting a separate blur/lens layer on dozens of tiny swatches.
- Box(
- Modifier
- .fillMaxSize()
- .background(
- Brush.verticalGradient(
- listOf(
- Color.White.copy(alpha = 0.30f),
- Color.Transparent,
- Color.Black.copy(alpha = 0.10f)
- )
- ),
- swatchShape
- )
+ // Liquid-glass bead (drawn, no backdrop pass — the theme grid alone is 60 swatches).
+ Box(Modifier.weight(1f).aspectRatio(if (tight) 1.15f else 1f).padding(1.dp), contentAlignment = Alignment.Center) {
+ GlassBead(
+ color = c,
+ selected = isSel,
+ onClick = { onPick(c) },
+ contentDescription = "#" + c.hex(false),
+ modifier = Modifier.fillMaxSize()
)
- if (isSel && !tight) {
- Icon(
- Icons.Rounded.Check,
- contentDescription = null,
- tint = if (c.luminance() > 0.5f) Color.Black else Color.White,
- modifier = Modifier.size(14.dp)
- )
- }
}
}
}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidRowClick.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidRowClick.kt
new file mode 100644
index 0000000..ca44641
--- /dev/null
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidRowClick.kt
@@ -0,0 +1,45 @@
+package com.chethan616.clearpdf.ui.components
+
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.interaction.collectIsPressedAsState
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.hapticfeedback.HapticFeedbackType
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode
+import com.chethan616.clearpdf.ui.utils.liquidPressGlow
+
+/**
+ * The app's list-row tap: springs down a touch under the finger, the chips' press light blooms from
+ * the touch point, one light haptic — instead of a Material ripple, which reads as Android-stock
+ * next to liquid glass. Apply in place of `clickable` on menu / panel rows.
+ */
+@Composable
+fun Modifier.liquidRowClick(
+ enabled: Boolean = true,
+ corner: Dp = 14.dp,
+ onClick: () -> Unit
+): Modifier {
+ val interaction = remember { MutableInteractionSource() }
+ val pressed by interaction.collectIsPressedAsState()
+ val haptics = LocalHapticFeedback.current
+ val scale by animateFloatAsState(if (pressed) 0.97f else 1f, GlassMotion.press(), label = "rowPress")
+ return this
+ .graphicsLayer { scaleX = scale; scaleY = scale }
+ .clip(RoundedCornerShape(corner))
+ .liquidPressGlow(interaction, onLight = !LocalIsDarkMode.current)
+ .clickable(interactionSource = interaction, indication = null, enabled = enabled, role = Role.Button) {
+ haptics.performHapticFeedback(HapticFeedbackType.ContextClick)
+ onClick()
+ }
+}
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt
index fb311d5..50d00db 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SpreadsheetViewerScreen.kt
@@ -152,6 +152,7 @@ import com.chethan616.clearpdf.ui.components.OfficeStandardColors
import com.chethan616.clearpdf.ui.components.liquidGlassPanel
import com.chethan616.clearpdf.ui.components.viewerChromeGlass
import com.chethan616.clearpdf.ui.components.viewerGlass
+import com.chethan616.clearpdf.ui.components.liquidRowClick
import com.chethan616.clearpdf.ui.theme.LiquidGlassColors
import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode
import com.chethan616.clearpdf.data.repository.OnboardingManager
@@ -564,7 +565,6 @@ fun SpreadsheetViewerScreen(
// its gravity-tracking highlight re-rendered a screen-sized blur + lens on
// every sensor tick — continuous frames that made the share morph and every
// other animation in this viewer stutter while the PDF viewer stayed smooth.
- .shadow(10.dp, GlassPanelShape, clip = false, ambientColor = Color.Black.copy(0.10f), spotColor = Color.Black.copy(0.10f))
.clip(GlassPanelShape)
.background(surface)
.border(0.5.dp, if (isDark) Color.White.copy(0.10f) else Color.Black.copy(0.06f), GlassPanelShape)
@@ -1058,9 +1058,8 @@ private fun PanelRow(icon: ImageVector?, label: String, color: Color, tint: Colo
Modifier
.fillMaxWidth()
.heightIn(min = 48.dp)
- .clip(RoundedCornerShape(14.dp))
+ .liquidRowClick(enabled = enabled, onClick = onClick)
.background(if (selected) tint.copy(0.16f) else Color.Transparent)
- .clickable(enabled = enabled, onClick = onClick)
.padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
@@ -1095,9 +1094,10 @@ private fun NumberPanel(text: Color, sub: Color, accent: Color, current: String,
for ((label, code) in NumberFormats) {
val sample = com.chethan616.clearpdf.utils.ExcelCellFormat.apply(if (code.contains("d") && code.contains("y")) "45566" else "1234.5", code)
Row(
- Modifier.fillMaxWidth().heightIn(min = 48.dp).clip(RoundedCornerShape(14.dp))
+ Modifier.fillMaxWidth().heightIn(min = 48.dp)
+ .liquidRowClick { onPick(code) }
.background(if (current == code) accent.copy(0.16f) else Color.Transparent)
- .clickable { onPick(code) }.padding(horizontal = 12.dp),
+ .padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
BasicText(label, Modifier.weight(1f), style = TextStyle(if (current == code) accent else text, 16.sp, FontWeight.Medium))
@@ -1164,9 +1164,8 @@ private fun ValidationDropdown(
Modifier
.fillMaxWidth()
.height(46.dp)
- .clip(RoundedCornerShape(12.dp))
+ .liquidRowClick(corner = 12.dp) { onPick(item) }
.background(if (sel) accent.copy(0.16f) else Color.Transparent)
- .clickable { onPick(item) }
.padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {