Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
Apple-level glass pass: liquid glass dropdown, chip glass everywhere, long-press bloom, smoother opens
Chethan6168185e3a558be
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.ktindex 6ef0cfc..1af29c4 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt@@ -69,6 +69,9 @@ import com.chethan616.clearpdf.ui.utils.StarPromptEventBusimport com.chethan616.clearpdf.ui.utils.rememberUISensorimport com.chethan616.clearpdf.ui.components.GlassDialogimport com.chethan616.clearpdf.ui.components.GlassDialogAction+import com.chethan616.clearpdf.ui.components.GlassOverlayHost+import com.chethan616.clearpdf.ui.components.GlassOverlayLayer+import com.chethan616.clearpdf.ui.components.LocalGlassOverlayHostimport com.chethan616.clearpdf.ui.components.LocalBackToLibraryActionimport com.kyant.backdrop.backdrops.layerBackdropimport com.kyant.backdrop.backdrops.rememberLayerBackdrop@@ -247,12 +250,23 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu}val contentBackdrop = rememberLayerBackdrop()+ // With the wallpaper off, `backdrop` records nothing but one solid colour (the Box below), so+ // every glass surface sampling it can draw that colour directly instead of blurring it.+ val flatWallpaperColor = if (!isDarkMode) Color(0xFFE9E9EE) else Color(0xFF1C1C1E)+ val flatBackdrop = remember(showWallpaper, flatWallpaperColor, backdrop) {+ if (showWallpaper) null else com.chethan616.clearpdf.ui.components.FlatBackdrop(backdrop, flatWallpaperColor)+ }+ // Floating glass (dropdown menus, contextual bars) from any depth renders here, above every+ // screen, refracting the live screen — see GlassOverlayHost.+ val overlayHost = remember { GlassOverlayHost() }CompositionLocalProvider(LocalResources provides localizedContext.resources,LocalIsDarkMode provides isDarkMode,LocalReducedGlassMotion provides reduceGlassMotion,- LocalBackToLibraryAction provides backToLibrary+ LocalBackToLibraryAction provides backToLibrary,+ com.chethan616.clearpdf.ui.components.LocalFlatBackdrop provides flatBackdrop,+ LocalGlassOverlayHost provides overlayHost) {Box(Modifier.fillMaxSize()) {// Captured layer = wallpaper + the live screen. The floating tab bar@@ -283,11 +297,13 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu// Apple never puts glass on pure #FFF or #000 — the translucent surfaces// would vanish. A light grey (#E9E9EE) / elevated dark grey (#1C1C1E) keeps// the liquid-glass panels and buttons legible with real depth.+ // Must stay a single solid fill: LocalFlatBackdrop (above) promises glass that+ // this layer contains exactly `flatWallpaperColor` and nothing else.Box(Modifier.layerBackdrop(backdrop).fillMaxSize()- .background(if (!isDarkMode) Color(0xFFE9E9EE) else Color(0xFF1C1C1E))+ .background(flatWallpaperColor))}DocsNavGraph(@@ -463,6 +479,9 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu}}}++ // Last child: above the tab bar and dialogs, outside the layer it samples.+ GlassOverlayLayer(overlayHost, contentBackdrop)}}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.ktnew file mode 100644index 0000000..ec99016--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/FlatBackdrop.kt@@ -0,0 +1,66 @@+package com.chethan616.clearpdf.ui.components++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.staticCompositionLocalOf+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.ColorMatrix+import androidx.compose.ui.graphics.drawscope.DrawScope+import com.kyant.backdrop.Backdrop++/**+ * The app's wallpaper layer when it is a single solid colour (Settings → Background off, the+ * default), so glass sampling it can skip work that provably changes no pixels.+ *+ * Every `liquidGlassPanel` / `LiquidButton` / `LiquidIconButton` runs `vibrancy → blur → lens` over+ * what it samples. Over a uniform colour, blur (clamped edges) returns that colour, and the lens+ * shader only *displaces* sample coordinates (`content.eval(refractedCoord)`, no shading) — so it+ * returns that colour too. The visible result is exactly `vibrancy(colour)`, everywhere. Yet each+ * surface was still recording the wallpaper into an offscreen layer and running a blur pass plus an+ * AGSL shader on it every frame, and re-recording on every scroll step because the sample position+ * is coordinate-dependent. Settings alone has ~25 such surfaces.+ *+ * The fast path draws `vibrancy(colour)` directly. Highlight, shadows, inner shadow, shape clip and+ * surface tint are untouched, and only surfaces whose backdrop *is* this exact wallpaper object take+ * it — anything sampling live content (headers, nav bar, dialogs, viewer chrome) keeps the full+ * pipeline.+ */+@Immutable+class FlatBackdrop(val backdrop: Backdrop, val color: Color)++val LocalFlatBackdrop = staticCompositionLocalOf<FlatBackdrop?> { null }++/** The flat wallpaper colour if [backdrop] is that flat wallpaper, else null (use the full glass). */+@Composable+fun flatColorOf(backdrop: Backdrop): Color? {+ val flat = LocalFlatBackdrop.current ?: return null+ return if (flat.backdrop === backdrop) flat.color else null+}++/**+ * Compose twin of the backdrop library's `vibrancy()` filter (`colorControls(saturation = 1.5f)`):+ * the same 4x5 matrix, so drawing a colour through it rounds exactly as the RenderEffect would.+ */+val VibrancyColorFilter: ColorFilter = run {+ val saturation = 1.5f+ val invSat = 1f - saturation+ val r = 0.213f * invSat+ val g = 0.715f * invSat+ val b = 0.072f * invSat+ ColorFilter.colorMatrix(+ ColorMatrix(+ floatArrayOf(+ r + saturation, g, b, 0f, 0f,+ r, g + saturation, b, 0f, 0f,+ r, g, b + saturation, 0f, 0f,+ 0f, 0f, 0f, 1f, 0f+ )+ )+ )+}++/** What `vibrancy → blur → lens` produces over a flat [color]: drawn straight, no layer, no shader. */+fun DrawScope.drawFlatVibrantBackdrop(color: Color) {+ drawRect(color, colorFilter = VibrancyColorFilter)+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.ktindex b2216a8..3629ab2 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassDialog.kt@@ -69,6 +69,20 @@ import com.kyant.backdrop.effects.lensimport com.kyant.backdrop.highlight.Highlightimport com.kyant.backdrop.shadow.Shadowimport com.kyant.shapes.RoundedRectangle+import com.kyant.shapes.Capsule+import com.kyant.backdrop.effects.vibrancy+import androidx.compose.foundation.gestures.awaitEachGesture+import androidx.compose.foundation.gestures.awaitFirstDown+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.rememberUpdatedState+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.input.pointer.changedToUp+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.semantics.onClick+import androidx.compose.ui.semantics.role+import androidx.compose.ui.semantics.selected+import kotlin.math.abs/** Backdrop the dialog panel samples, handed to [GlassDialogAction]s so the pills refract the same scene. */private val LocalDialogBackdrop = staticCompositionLocalOf<Backdrop?> { null }@@ -181,23 +195,25 @@ fun GlassDialog().semantics { if (title != null) paneTitle = title }) {- if (title != null) {- BasicText(- title,- Modifier.padding(28f.dp, 24f.dp, 28f.dp, 8f.dp),- style = TextStyle(contentColor, 22f.sp, FontWeight.SemiBold)- )- } else {- Box(Modifier.height(16.dp))- }- Column(Modifier.fillMaxWidth().padding(horizontal = 24f.dp, vertical = 8f.dp)) {- content()- }+ // Content controls (segmented choices, dropdown triggers) get the same scene as the+ // action pills, so every control in the sheet is the same liquid glass.CompositionLocalProvider(LocalDialogBackdrop provides backdrop,LocalDialogBlur provides blurDp,LocalDialogSurface provides containerColor) {+ if (title != null) {+ BasicText(+ title,+ Modifier.padding(28f.dp, 24f.dp, 28f.dp, 8f.dp),+ style = TextStyle(contentColor, 22f.sp, FontWeight.SemiBold)+ )+ } else {+ Box(Modifier.height(16.dp))+ }+ Column(Modifier.fillMaxWidth().padding(horizontal = 24f.dp, vertical = 8f.dp)) {+ content()+ }Row(Modifier.padding(24f.dp, 12f.dp, 24f.dp, 24f.dp)@@ -335,9 +351,16 @@ fun GlassDialogField(}/**- * Segmented choice for [GlassDialog] content: a solid capsule track with a vivid sliding thumb- * (the "Get it" tint), springing between segments. Solid on purpose — a glass thumb inside a glass- * panel would refract the page behind the dialog, not the panel.+ * Segmented choice for [GlassDialog] content, in the same liquid glass as the dialog's action pills:+ * a lensed capsule track on the solid dialog platter (so labels stay legible over any page) with a+ * vivid "Get it" glass thumb.+ *+ * The thumb is liquid: it slides on the morph spring and stretches along its travel in proportion to+ * its speed, squashing slightly in height, then wobbles back into shape as it lands — the iOS 26+ * segmented-control feel. A finger can also slide across the track; the selection follows it with a+ * tick per segment. The pressed segment's label dips like a pressed button.+ *+ * Outside a [GlassDialog] (no dialog backdrop to refract) it falls back to the solid track.*/@Composablefun GlassDialogSegmented(@@ -351,48 +374,137 @@ fun GlassDialogSegmented(val isDark = LocalIsDarkMode.currentval ink = LiquidGlassColors.text(isDark)val haptics = LocalHapticFeedback.current+ val backdrop = LocalDialogBackdrop.current+ val blurDp = LocalDialogBlur.current+ val platter = glassDialogPlatter(isDark)val index = selectedIndex.coerceIn(0, options.lastIndex)- val thumb by animateFloatAsState(index.toFloat(), GlassMotion.morph(), label = "dialogSegment")+ val currentIndex by rememberUpdatedState(index)+ val currentOnSelect by rememberUpdatedState(onSelect)+ val thumb = remember { Animatable(index.toFloat()) }+ LaunchedEffect(index) { thumb.animateTo(index.toFloat(), GlassMotion.morph()) }+ val thumbAccent by animateColorAsState(accent, GlassMotion.fade(), label = "segAccent")+ var pressed by remember { mutableIntStateOf(-1) }+BoxWithConstraints(modifier.fillMaxWidth()- .height(46.dp)- .clip(RoundedCornerShape(50))- .background(glassDialogPlatter(isDark))+ .height(48.dp)+ .then(+ if (backdrop != null) {+ Modifier.drawBackdrop(+ backdrop = backdrop,+ shape = { Capsule },+ effects = {+ vibrancy()+ blur(blurDp.toPx())+ lens(12f.dp.toPx(), 24f.dp.toPx())+ },+ onDrawSurface = { drawRect(platter) }+ )+ } else {+ Modifier.clip(RoundedCornerShape(50)).background(platter)+ }+ )+ .pointerInput(options.size) {+ // Tap a segment, or slide across them: the selection tracks the finger.+ val count = options.size+ fun segmentAt(x: Float): Int = ((x / size.width) * count).toInt().coerceIn(0, count - 1)+ awaitEachGesture {+ val down = awaitFirstDown()+ var current = segmentAt(down.position.x)+ pressed = current+ while (true) {+ val event = awaitPointerEvent()+ val change = event.changes.firstOrNull { it.id == down.id } ?: break+ val i = segmentAt(change.position.x)+ if (change.changedToUp()) {+ if (i != currentIndex) {+ haptics.performHapticFeedback(HapticFeedbackType.SegmentTick)+ currentOnSelect(i)+ }+ break+ }+ if (i != current) {+ current = i+ pressed = i+ if (i != currentIndex) {+ haptics.performHapticFeedback(HapticFeedbackType.SegmentFrequentTick)+ currentOnSelect(i)+ }+ }+ }+ pressed = -1+ }+ }.padding(4.dp)) {val segment = maxWidth / options.size- Box(- Modifier- .width(segment)- .fillMaxHeight()- .graphicsLayer { translationX = thumb * segment.toPx() }- .clip(RoundedCornerShape(50))- .background(accent)- .background(Brush.verticalGradient(listOf(Color.White.copy(0.22f), Color.Transparent)))- )+ val thumbModifier = Modifier+ .width(segment)+ .fillMaxHeight()+ .graphicsLayer {+ translationX = thumb.value * segment.toPx()+ // Stretch with speed (segments/s), capped so a fast flick reads as liquid, not a bug.+ val stretch = (abs(thumb.velocity) * 0.02f).fastCoerceIn(0f, 0.2f)+ scaleX = 1f + stretch+ scaleY = 1f - stretch * 0.35f+ }+ if (backdrop != null) {+ Box(+ thumbModifier.drawBackdrop(+ backdrop = backdrop,+ shape = { Capsule },+ effects = {+ vibrancy()+ blur(blurDp.toPx())+ lens(10f.dp.toPx(), 20f.dp.toPx())+ },+ highlight = { Highlight.Default },+ onDrawSurface = {+ // LiquidButton's vivid tint recipe, so the thumb matches the primary pill.+ drawRect(Color.White.copy(alpha = 0.42f))+ drawRect(thumbAccent, blendMode = BlendMode.Hue)+ drawRect(thumbAccent.copy(alpha = 0.8f))+ }+ )+ )+ } else {+ Box(+ thumbModifier+ .clip(RoundedCornerShape(50))+ .background(thumbAccent)+ .background(Brush.verticalGradient(listOf(Color.White.copy(0.22f), Color.Transparent)))+ )+ }Row(Modifier.fillMaxSize()) {options.forEachIndexed { i, label ->val sel = i == indexval labelColor by animateColorAsState(if (sel) Color.White else ink, label = "segInk$i")+ val labelScale by animateFloatAsState(+ if (pressed == i) GlassMotion.PressedScale else 1f,+ GlassMotion.press(),+ label = "segPress$i"+ )Box(Modifier.weight(1f).fillMaxHeight()- .clip(RoundedCornerShape(50))- .clickable(- interactionSource = remember { MutableInteractionSource() },- indication = null- ) {- if (i != index) {- haptics.performHapticFeedback(HapticFeedbackType.SegmentTick)- onSelect(i)+ .semantics(mergeDescendants = true) {+ role = Role.Tab+ selected = sel+ onClick(label = label) {+ if (i != currentIndex) currentOnSelect(i)+ true}},contentAlignment = Alignment.Center) {BasicText(label,+ modifier = Modifier.graphicsLayer {+ scaleX = labelScale+ scaleY = labelScale+ },style = TextStyle(labelColor, 15.sp, if (sel) FontWeight.SemiBold else FontWeight.Medium),maxLines = 1)diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassOverlayHost.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassOverlayHost.ktnew file mode 100644index 0000000..85f1e1e--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/GlassOverlayHost.kt@@ -0,0 +1,106 @@+package com.chethan616.clearpdf.ui.components++import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.Stable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.key+import androidx.compose.runtime.mutableStateListOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberUpdatedState+import androidx.compose.runtime.setValue+import androidx.compose.runtime.staticCompositionLocalOf+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.layout.onGloballyPositioned+import androidx.compose.ui.layout.positionInWindow+import androidx.compose.ui.unit.IntSize+import com.kyant.backdrop.Backdrop++/**+ * An in-window portal for floating glass: dropdown menus, contextual action bars.+ *+ * Why it exists: glass can only refract a layer it is *not* part of. A menu opened from inside a+ * screen's scrolling content lives inside the layer that content records into, so it could only ever+ * sample the wallpaper — over the default flat background that reads as a grey card, not glass. The+ * floating tab bar solves the same problem by being a sibling of that layer at the app root; this+ * gives any component, however deep, the same position. Content registered here is composed in+ * [GlassOverlayLayer], drawn above every screen (and the tab bar), and handed the app's live-screen+ * backdrop, so a menu really bends whatever is under it.+ *+ * Entries take window coordinates (e.g. `boundsInWindow()` of a trigger) and convert with+ * [GlassOverlayScope.windowToLocal].+ */+@Stable+class GlassOverlayHost {+ internal val entries = mutableStateListOf<OverlayEntry>()+ internal var originInWindow by mutableStateOf(Offset.Zero)+ internal var layerSize by mutableStateOf(IntSize.Zero)++ internal fun register(entry: OverlayEntry) {+ entries.removeAll { it.key === entry.key }+ entries.add(entry)+ }++ internal fun unregister(key: Any) {+ entries.removeAll { it.key === key }+ }+}++internal class OverlayEntry(val key: Any, val content: @Composable GlassOverlayScope.() -> Unit)++@Stable+class GlassOverlayScope internal constructor(+ /** The live screen (wallpaper + everything drawn by the app) — what overlay glass refracts. */+ val backdrop: Backdrop,+ private val host: GlassOverlayHost+) {+ /** A window-space point in this layer's local space. Read in layout/draw, not composition. */+ fun windowToLocal(point: Offset): Offset = point - host.originInWindow++ /** The overlay layer's size in px — the area floating content may occupy. */+ val layerSize: IntSize get() = host.layerSize+}++val LocalGlassOverlayHost = staticCompositionLocalOf<GlassOverlayHost?> { null }++/**+ * Renders everything registered with [host]. Place it as a late child of the app's root Box, OUTSIDE+ * the layer that records into [backdrop] (the same rule as the tab bar), so overlay glass can sample+ * the whole screen without sampling itself.+ */+@Composable+fun GlassOverlayLayer(host: GlassOverlayHost, backdrop: Backdrop, modifier: Modifier = Modifier) {+ val scope = remember(host, backdrop) { GlassOverlayScope(backdrop, host) }+ Box(+ modifier+ .fillMaxSize()+ .onGloballyPositioned {+ host.originInWindow = it.positionInWindow()+ host.layerSize = it.size+ }+ ) {+ host.entries.forEach { entry ->+ key(entry.key) { entry.content(scope) }+ }+ }+}++/**+ * Hosts [content] in the app's [GlassOverlayLayer] for as long as the calling composable is in+ * composition. No-op where no host is provided. [content] should draw nothing while it has nothing to+ * show — it stays registered, so the cost of an idle entry must be ~zero.+ */+@Composable+fun GlassOverlay(content: @Composable GlassOverlayScope.() -> Unit) {+ val host = LocalGlassOverlayHost.current ?: return+ val latest by rememberUpdatedState(content)+ val key = remember { Any() }+ DisposableEffect(host, key) {+ host.register(OverlayEntry(key) { latest(this) })+ onDispose { host.unregister(key) }+ }+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LanguageOptions.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LanguageOptions.ktnew file mode 100644index 0000000..fd41d19--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LanguageOptions.kt@@ -0,0 +1,33 @@+package com.chethan616.clearpdf.ui.components++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.chethan616.clearpdf.R+import com.chethan616.clearpdf.ui.utils.LocaleHelper++/** The app's UI languages, in order, keyed by the tags [LocaleHelper.normalizeForUi] produces. */+val AppLanguageTags = listOf("en", "pt-BR", "es", "it", "ru")++/**+ * [AppLanguageTags] as dropdown rows, iOS-style: the name in the current UI language, with the+ * language's own name underneath whenever it differs — so someone who landed in the wrong language+ * can still find theirs.+ */+@Composable+fun rememberLanguageOptions(): List<GlassDropdownOption<String>> {+ val localized = listOf(+ stringResource(R.string.language_english),+ stringResource(R.string.language_portuguese),+ stringResource(R.string.language_spanish),+ stringResource(R.string.language_italian),+ stringResource(R.string.language_russian)+ )+ return AppLanguageTags.mapIndexed { i, tag ->+ val native = LocaleHelper.getLanguageDisplayName(tag)+ GlassDropdownOption(+ value = tag,+ label = localized[i],+ supporting = native.takeIf { !it.startsWith(localized[i], ignoreCase = true) }+ )+ }+}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.ktindex 7400fa6..ab9070d 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@@ -8,13 +8,17 @@ import androidx.compose.foundation.layout.RowScopeimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.runtime.Composable+import androidx.compose.runtime.getValueimport androidx.compose.runtime.rememberimport androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.rememberUpdatedStateimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.BlendModeimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.isSpecified+import androidx.compose.ui.hapticfeedback.HapticFeedbackType+import androidx.compose.ui.platform.LocalHapticFeedbackimport androidx.compose.ui.semantics.Roleimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.dp@@ -81,27 +85,40 @@ fun LiquidButton(content: @Composable RowScope.() -> Unit) {val animationScope = rememberCoroutineScope()+ val haptics = LocalHapticFeedback.current+ val currentHaptics by rememberUpdatedState(haptics)val interactiveHighlight = remember(animationScope) {- InteractiveHighlight(animationScope = animationScope)+ InteractiveHighlight(+ animationScope = animationScope,+ longPressExpand = true,+ onLongPressExpand = { currentHaptics.performHapticFeedback(HapticFeedbackType.LongPress) }+ )}+ // Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.+ val flat = flatColorOf(backdrop)Row(modifier.drawBackdrop(backdrop = backdrop,shape = { Capsule },- effects = {+ effects = if (flat != null) ({}) else ({vibrancy()blur(blurRadius.toPx())lens(12f.dp.toPx(), 24f.dp.toPx())- },+ }),+ onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),layerBlock = if (isInteractive) {{val width = size.widthval height = size.heightval progress = interactiveHighlight.pressProgress- val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress)+ // Long-press bloom: grows by at most ~14 dp along the long side (≤ 12 %), so a+ // small chip pops playfully while a full-width button only swells a touch.+ val bloom = interactiveHighlight.expandProgress *+ (14f.dp.toPx() / size.maxDimension).fastCoerceAtMost(0.12f)+ val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress) + bloomval maxOffset = size.minDimensionval initialDerivative = 0.05fdiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.ktnew file mode 100644index 0000000..508765e--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassDropdown.kt@@ -0,0 +1,434 @@+package com.chethan616.clearpdf.ui.components++import androidx.activity.compose.BackHandler+import androidx.compose.animation.AnimatedContent+import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.animateFloat+import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.core.spring+import androidx.compose.animation.core.updateTransition+import androidx.compose.animation.fadeIn+import androidx.compose.animation.fadeOut+import androidx.compose.animation.slideInVertically+import androidx.compose.animation.slideOutVertically+import androidx.compose.animation.togetherWith+import androidx.compose.foundation.gestures.awaitEachGesture+import androidx.compose.foundation.gestures.awaitFirstDown+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.WindowInsets+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.navigationBars+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBars+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.text.BasicText+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.rounded.Check+import androidx.compose.material.icons.rounded.KeyboardArrowDown+import androidx.compose.material3.Icon+import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberUpdatedState+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.draw.drawBehind+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.geometry.Rect+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.TransformOrigin+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.isSpecified+import androidx.compose.ui.graphics.vector.ImageVector+import androidx.compose.ui.hapticfeedback.HapticFeedbackType+import androidx.compose.ui.input.pointer.changedToUp+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.layout.Layout+import androidx.compose.ui.layout.boundsInWindow+import androidx.compose.ui.layout.onGloballyPositioned+import androidx.compose.ui.layout.positionInWindow+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.platform.LocalHapticFeedback+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.semantics.onClick+import androidx.compose.ui.semantics.role+import androidx.compose.ui.semantics.selected+import androidx.compose.ui.semantics.semantics+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.Constraints+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.chethan616.clearpdf.ui.theme.LiquidGlassColors+import com.chethan616.clearpdf.ui.theme.LocalIsDarkMode+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.shadow.Shadow+import com.kyant.shapes.RoundedRectangle+import kotlinx.coroutines.delay+import kotlin.math.roundToInt++/**+ * The floating-menu material, shared by every glass menu (this dropdown, the text-selection toolbar's+ * overflow): the chip's vibrancy + lens rim, but frosted harder (10 dp blur, 62% tint) so rows of text+ * stay legible over whatever they float on, with a soft deep shadow to lift it off the content.+ */+fun Modifier.glassMenu(+ backdrop: Backdrop,+ dark: Boolean,+ shape: () -> Shape = { RoundedRectangle(24.dp) }+): Modifier = drawBackdrop(+ backdrop = backdrop,+ shape = shape,+ effects = {+ vibrancy()+ blur(10f.dp.toPx())+ lens(14f.dp.toPx(), 28f.dp.toPx())+ },+ highlight = { Highlight.Default },+ shadow = { Shadow(radius = 28.dp, color = Color.Black.copy(alpha = if (dark) 0.34f else 0.16f)) },+ onDrawSurface = { drawRect(if (dark) Color(0xFF1E1E1E).copy(0.62f) else Color(0xFFFAFAFA).copy(0.62f)) }+)++/** One choice in a [LiquidGlassDropdown]. [supporting] is an optional second line (e.g. a native name). */+@Immutable+data class GlassDropdownOption<T>(+ val value: T,+ val label: String,+ val supporting: String? = null,+ val icon: ImageVector? = null+)++/**+ * The share sheet's bouncy dropdown (commit 248ab19), generalised: a chip-glass trigger showing the+ * current value with a chevron that turns on the morph spring, and a frosted liquid-glass menu that+ * springs open out of it.+ *+ * The menu lives in the app's [GlassOverlayLayer], not under the trigger, so (a) opening it never+ * grows the panel the trigger sits in — resizing a glass panel re-blurs it every frame, which is the+ * original "expand lag" this pattern was invented to avoid — and (b) it refracts the real screen+ * beneath it rather than the wallpaper.+ *+ * Motion: the menu unfolds from the trigger (scale + a short slide, overshooting on a soft spring) and+ * its rows land one after another. Rows support iOS-style press-and-slide: put a finger down, slide+ * across the options (a light tick on each), lift to choose. The trigger's value rolls to the new+ * choice. Back, or a touch anywhere outside, closes it.+ */+@Composable+fun <T> LiquidGlassDropdown(+ options: List<GlassDropdownOption<T>>,+ selected: T,+ onSelect: (T) -> Unit,+ backdrop: Backdrop,+ modifier: Modifier = Modifier,+ leadingIcon: ImageVector? = null,+ accent: Color = LiquidGlassColors.Blue,+ /** Trigger surface; defaults to the neutral chip wash used by unselected [GlassChoiceChip]s. */+ triggerSurface: Color = Color.Unspecified,+ contentColor: Color = Color.Unspecified+) {+ val isDark = LocalIsDarkMode.current+ val ink = if (contentColor.isSpecified) contentColor else LiquidGlassColors.text(isDark)+ val haptics = LocalHapticFeedback.current+ var open by remember { mutableStateOf(false) }+ // Window-space bounds of the trigger, read by the menu at layout time only.+ val anchor = remember { mutableStateOf(Rect.Zero) }+ val current = options.firstOrNull { it.value == selected } ?: options.firstOrNull()+ val chevron by animateFloatAsState(if (open) 180f else 0f, GlassMotion.morph(), label = "dropdownChevron")++ BackHandler(enabled = open) { open = false }++ LiquidButton(+ onClick = {+ haptics.performHapticFeedback(HapticFeedbackType.ContextClick)+ open = !open+ },+ backdrop = backdrop,+ surfaceColor = if (triggerSurface.isSpecified) triggerSurface else LiquidGlassColors.neutralSurface(isDark),+ modifier = modifier+ .onGloballyPositioned { anchor.value = it.boundsInWindow() }+ .semantics { role = Role.DropdownList }+ ) {+ if (leadingIcon != null) Icon(leadingIcon, null, Modifier.size(18.dp), accent)+ AnimatedContent(+ targetState = current,+ transitionSpec = {+ (fadeIn(GlassMotion.fade()) + slideInVertically(GlassMotion.morph()) { it / 2 }) togetherWith+ (fadeOut(GlassMotion.fade()) + slideOutVertically(GlassMotion.settle()) { -it / 2 })+ },+ contentAlignment = Alignment.CenterStart,+ modifier = Modifier.weight(1f),+ label = "dropdownValue"+ ) { opt ->+ BasicText(+ opt?.label.orEmpty(),+ style = TextStyle(ink, 15.sp, FontWeight.SemiBold),+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ }+ Icon(+ Icons.Rounded.KeyboardArrowDown,+ null,+ Modifier.size(20.dp).graphicsLayer { rotationZ = chevron },+ ink.copy(alpha = 0.6f)+ )+ }++ GlassOverlay {+ DropdownMenu(+ open = open,+ anchor = { anchor.value },+ options = options,+ selected = selected,+ accent = accent,+ onPick = { value ->+ haptics.performHapticFeedback(HapticFeedbackType.SegmentTick)+ open = false+ if (value != selected) onSelect(value)+ },+ onHover = { haptics.performHapticFeedback(HapticFeedbackType.SegmentFrequentTick) },+ onDismiss = { open = false }+ )+ }+}++@Composable+private fun <T> GlassOverlayScope.DropdownMenu(+ open: Boolean,+ anchor: () -> Rect,+ options: List<GlassDropdownOption<T>>,+ selected: T,+ accent: Color,+ onPick: (T) -> Unit,+ onHover: () -> Unit,+ onDismiss: () -> Unit+) {+ // Open on a soft, underdamped spring (a little overshoot = the "unfold"); close critically damped+ // and fast, so dismissal never wobbles.+ val transition = updateTransition(open, label = "dropdownMenu")+ val reveal by transition.animateFloat(+ transitionSpec = {+ if (targetState) spring(dampingRatio = 0.62f, stiffness = 460f)+ else spring(dampingRatio = 1f, stiffness = 900f)+ },+ label = "dropdownReveal"+ ) { if (it) 1f else 0f }+ // Idle cost ~zero: nothing composes while fully closed.+ if (!open && transition.currentState == transition.targetState && reveal <= 0f) return++ val density = LocalDensity.current+ val isDark = LocalIsDarkMode.current+ val ink = LiquidGlassColors.text(isDark)+ val inkSoft = LiquidGlassColors.secondary(isDark)+ val topSafe = WindowInsets.statusBars.getTop(density) + with(density) { 8.dp.roundToPx() }+ val bottomSafe = WindowInsets.navigationBars.getBottom(density) + with(density) { 8.dp.roundToPx() }+ val currentDismiss by rememberUpdatedState(onDismiss)+ val currentPick by rememberUpdatedState(onPick)+ val currentHover by rememberUpdatedState(onHover)++ var hovered by remember { mutableIntStateOf(-1) }+ // Row extents in window space, written at layout and read only by the gesture.+ val rowTops = remember(options.size) { FloatArray(options.size) }+ val rowBottoms = remember(options.size) { FloatArray(options.size) }+ val menuOrigin = remember { arrayOf(Offset.Zero) }+ val menuWidth = remember { floatArrayOf(0f) }+ fun indexAt(windowY: Float): Int {+ for (i in options.indices) if (windowY >= rowTops[i] && windowY < rowBottoms[i]) return i+ return -1+ }++ Box(Modifier.fillMaxSize()) {+ if (open) {+ // A touch anywhere outside the menu dismisses it, and is swallowed so nothing underneath+ // (a scroll, a button) reacts to the same touch.+ Box(+ Modifier+ .fillMaxSize()+ .pointerInput(Unit) {+ awaitEachGesture {+ awaitFirstDown(requireUnconsumed = false).consume()+ currentDismiss()+ }+ }+ )+ }++ Layout(+ content = {+ Column(+ Modifier+ .glassMenu(backdrop, dark = isDark)+ .onGloballyPositioned {+ menuOrigin[0] = it.positionInWindow()+ menuWidth[0] = it.size.width.toFloat()+ }+ .pointerInput(options) {+ // Press-and-slide selection: the row under the finger highlights as it+ // moves (a tick per row); lifting on a row picks it.+ awaitEachGesture {+ val down = awaitFirstDown(requireUnconsumed = false)+ down.consume()+ fun hit(p: Offset): Int =+ if (p.x < 0f || p.x > menuWidth[0]) -1 else indexAt(menuOrigin[0].y + p.y)+ hovered = hit(down.position)+ while (true) {+ val event = awaitPointerEvent()+ val change = event.changes.firstOrNull { it.id == down.id } ?: break+ if (change.changedToUp()) {+ change.consume()+ val i = hit(change.position)+ if (i >= 0) currentPick(options[i].value)+ break+ }+ change.consume()+ val i = hit(change.position)+ if (i != hovered) {+ if (i >= 0) currentHover()+ hovered = i+ }+ }+ hovered = -1+ }+ }+ .padding(vertical = 6.dp)+ ) {+ options.forEachIndexed { i, opt ->+ DropdownRow(+ option = opt,+ index = i,+ isSelected = opt.value == selected,+ isHovered = hovered == i,+ ink = ink,+ inkSoft = inkSoft,+ accent = accent,+ onBounds = { top, bottom -> rowTops[i] = top; rowBottoms[i] = bottom },+ onPickA11y = { currentPick(opt.value) }+ )+ }+ }+ }+ ) { measurables, constraints ->+ val margin = 12.dp.roundToPx()+ val gap = 8.dp.roundToPx()+ val layerW = constraints.maxWidth+ val layerH = constraints.maxHeight+ val a = anchor()+ val aTopLeft = windowToLocal(a.topLeft)+ // Match the trigger's width (never narrower than a comfortable menu, never wider than the+ // screen) — the dropdown reads as the trigger opening, not a separate popup.+ val maxW = (layerW - 2 * margin).coerceAtLeast(0)+ val w = a.width.roundToInt().coerceAtLeast(200.dp.roundToPx()).coerceAtMost(maxW)+ val placeable = measurables.first().measure(+ Constraints.fixedWidth(w).copy(maxHeight = (layerH - topSafe - bottomSafe).coerceAtLeast(0))+ )+ val h = placeable.height+ val belowY = aTopLeft.y + a.height + gap+ val fitsBelow = belowY + h <= layerH - bottomSafe+ val y = if (fitsBelow) belowY else (aTopLeft.y - gap - h).coerceAtLeast(topSafe.toFloat())+ val x = aTopLeft.x.coerceIn(margin.toFloat(), (layerW - margin - w).toFloat().coerceAtLeast(margin.toFloat()))+ val pivotX = if (w > 0) ((aTopLeft.x + a.width / 2f - x) / w).coerceIn(0f, 1f) else 0.5f+ val slide = 10.dp.toPx() * if (fitsBelow) -1f else 1f+ layout(layerW, layerH) {+ placeable.placeWithLayer(x.roundToInt(), y.roundToInt()) {+ val r = reveal+ alpha = r.coerceIn(0f, 1f)+ scaleX = 0.9f + 0.1f * r+ scaleY = 0.8f + 0.2f * r+ translationY = (1f - r) * slide+ transformOrigin = TransformOrigin(pivotX, if (fitsBelow) 0f else 1f)+ }+ }+ }+ }+}++@Composable+private fun <T> DropdownRow(+ option: GlassDropdownOption<T>,+ index: Int,+ isSelected: Boolean,+ isHovered: Boolean,+ ink: Color,+ inkSoft: Color,+ accent: Color,+ onBounds: (top: Float, bottom: Float) -> Unit,+ onPickA11y: () -> Unit+) {+ // Rows land one after another (~24 ms apart) as the glass unfolds, like an iOS menu.+ val enter = remember { Animatable(0f) }+ LaunchedEffect(Unit) {+ delay(24L + 24L * index.coerceAtMost(8))+ enter.animateTo(1f, spring(dampingRatio = 0.8f, stiffness = 520f))+ }+ val press by animateFloatAsState(if (isHovered) 0.97f else 1f, GlassMotion.press(), label = "dropRowPress")+ val wash by animateFloatAsState(if (isHovered) 1f else 0f, GlassMotion.fade(), label = "dropRowWash")+ val slidePx = with(LocalDensity.current) { 6.dp.toPx() }+ Row(+ Modifier+ .fillMaxWidth()+ .onGloballyPositioned { c ->+ val b = c.boundsInWindow()+ onBounds(b.top, b.bottom)+ }+ .graphicsLayer {+ val e = enter.value+ alpha = e.coerceIn(0f, 1f)+ translationY = (1f - e) * slidePx+ scaleX = press+ scaleY = press+ }+ .padding(horizontal = 6.dp)+ .clip(RoundedCornerShape(16.dp))+ .drawBehind { if (wash > 0f) drawRect(ink.copy(alpha = 0.08f * wash)) }+ .semantics(mergeDescendants = true) {+ role = Role.Button+ selected = isSelected+ onClick(label = option.label) { onPickA11y(); true }+ }+ .padding(horizontal = 12.dp, vertical = if (option.supporting != null) 9.dp else 13.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(10.dp)+ ) {+ Box(Modifier.width(20.dp), contentAlignment = Alignment.Center) {+ if (isSelected) Icon(Icons.Rounded.Check, null, Modifier.size(18.dp), accent)+ }+ if (option.icon != null) Icon(option.icon, null, Modifier.size(18.dp), if (isSelected) accent else ink)+ Column(Modifier.weight(1f)) {+ BasicText(+ option.label,+ style = TextStyle(ink, 15.sp, if (isSelected) FontWeight.SemiBold else FontWeight.Medium),+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ if (option.supporting != null) {+ Spacer(Modifier.size(1.dp))+ BasicText(+ option.supporting,+ style = TextStyle(inkSoft, 12.sp),+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ }+ }+ }+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.ktindex e0330ca..da366b7 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt@@ -13,7 +13,6 @@ import com.kyant.backdrop.effects.lensimport com.kyant.backdrop.effects.vibrancyimport com.kyant.backdrop.highlight.Highlightimport com.kyant.backdrop.highlight.HighlightStyle-import com.kyant.backdrop.shadow.InnerShadowimport com.kyant.backdrop.shadow.Shadowimport com.kyant.shapes.RoundedRectangle@@ -32,19 +31,28 @@ fun Modifier.liquidGlassPanel(): Modifier {val isDarkMode = LocalIsDarkMode.currentval isLightTheme = !isDarkMode+ // The title chips' tint (GlassTitlePill: 0.35), so a panel and the chip above it read as one+ // material rather than a card under a lens.val containerColor = containerColorOverride- ?: if (isLightTheme) Color(0xFFFAFAFA).copy(0.4f) else Color(0xFF1E1E1E).copy(0.4f)+ ?: if (isLightTheme) Color(0xFFFAFAFA).copy(0.35f) else Color(0xFF1E1E1E).copy(0.35f)+ // Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.+ val flat = flatColorOf(backdrop)return this.drawBackdrop(backdrop = backdrop,shape = { RoundedRectangle(28f.dp) },- effects = {+ // Heavier frost than a chip on purpose: panels carry paragraphs of text, which a 2 dp blur+ // over a busy custom wallpaper would leave unreadable.+ effects = if (flat != null) ({}) else ({vibrancy()blur(8f.dp.toPx())lens(20f.dp.toPx(), 40f.dp.toPx(), depthEffect = true)- },- highlight = { Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f)) },+ }),+ // The chips' bright specular rim (falloff 1, LiquidButton's default) instead of the old narrow+ // falloff-2 sheen plus a dark 3 dp inner shadow — that inset edge was what made panels read as+ // tinted cards next to the glassy title chips. Still turns with the device tilt.+ highlight = { Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle)) },shadow = { Shadow(radius = 8f.dp, color = Color.Black.copy(alpha = 0.1f)) },- innerShadow = { InnerShadow(radius = 3f.dp, alpha = 0.3f) },+ onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),onDrawSurface = { drawRect(containerColor) })}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.ktindex 2bf1460..3a94450 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidIconButton.kt@@ -6,13 +6,17 @@ import androidx.compose.foundation.combinedClickableimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.sizeimport androidx.compose.runtime.Composable+import androidx.compose.runtime.getValueimport androidx.compose.runtime.rememberimport androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.rememberUpdatedStateimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.BlendModeimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.isSpecified+import androidx.compose.ui.hapticfeedback.HapticFeedbackType+import androidx.compose.ui.platform.LocalHapticFeedbackimport androidx.compose.ui.semantics.Roleimport androidx.compose.ui.unit.dpimport androidx.compose.ui.util.fastCoerceAtMost@@ -47,9 +51,21 @@ fun LiquidIconButton(content: @Composable () -> Unit) {val animationScope = rememberCoroutineScope()+ val haptics = LocalHapticFeedback.current+ val currentHaptics by rememberUpdatedState(haptics)+ // combinedClickable already buzzes when its own onLongClick fires; only add ours when there is none.+ val hasOwnLongClick by rememberUpdatedState(onLongClick != null)val interactiveHighlight = remember(animationScope) {- InteractiveHighlight(animationScope = animationScope)+ InteractiveHighlight(+ animationScope = animationScope,+ longPressExpand = true,+ onLongPressExpand = {+ if (!hasOwnLongClick) currentHaptics.performHapticFeedback(HapticFeedbackType.LongPress)+ }+ )}+ // Flat wallpaper: same pixels, none of the blur/lens/offscreen work — see FlatBackdrop.+ val flat = flatColorOf(backdrop)Box(modifier@@ -57,18 +73,22 @@ fun LiquidIconButton(.drawBackdrop(backdrop = backdrop,shape = { CircleShape },- effects = {+ effects = if (flat != null) ({}) else ({vibrancy()blur(2f.dp.toPx())lens(12f.dp.toPx(), 24f.dp.toPx())- },+ }),+ onDrawBackdrop = if (flat != null) ({ _ -> drawFlatVibrantBackdrop(flat) }) else ({ it() }),layerBlock = if (isInteractive) {{val width = size.widthval height = size.heightval progress = interactiveHighlight.pressProgress- val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress)+ // Long-press bloom, same rule as LiquidButton (≤ ~14 dp, ≤ 12 %).+ val bloom = interactiveHighlight.expandProgress *+ (14f.dp.toPx() / size.maxDimension).fastCoerceAtMost(0.12f)+ val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress) + bloomval maxOffset = size.minDimensionval initialDerivative = 0.05fdiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolTile.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolTile.ktindex 9e04a90..4a9bb87 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolTile.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/ToolTile.kt@@ -40,6 +40,7 @@ import androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkMode+import com.chethan616.clearpdf.ui.utils.liquidPressGlow/** Uniform height for the square-ish grid tiles, sized to fit two lines of Portuguese. */val ToolTileHeight = 120.dp@@ -88,6 +89,7 @@ fun ToolTile(.graphicsLayer { val s = scale.value; scaleX = s; scaleY = s }.clip(RoundedCornerShape(20.dp)).background(accent.copy(alpha = if (isLight) 0.10f else 0.15f))+ .liquidPressGlow(interaction, onLight = isLight).clickable(interactionSource = interaction,indication = null,@@ -144,6 +146,7 @@ fun ToolTileWide(.graphicsLayer { val s = scale.value; scaleX = s; scaleY = s }.clip(RoundedCornerShape(22.dp)).background(accent.copy(alpha = if (isLight) 0.12f else 0.18f))+ .liquidPressGlow(interaction, onLight = isLight).clickable(interactionSource = interaction,indication = null,diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.ktindex fafa27a..e45245c 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt@@ -143,3 +143,14 @@ fun Modifier.carouselEdges(*/fun viewerChromeGlass(isDark: Boolean): Color =if (isDark) Color(0xFF20242C).copy(0.7f) else Color.White.copy(0.55f)++/**+ * The "chip" material's tint — GlassTitlePill / the viewer's top-bar pills — for content that is light+ * ([onLight]) or dark behind it. Paired with [viewerGlass] it is the same glass as the ClearPDF and+ * Settings title chips: mostly pure refraction with a whisper of frost.+ */+fun chipGlass(onLight: Boolean): Color =+ if (onLight) Color(0xFFFAFAFA).copy(0.35f) else Color(0xFF1E1E1E).copy(0.35f)++/** Ink for a [chipGlass] surface: it is translucent, so it follows the content behind, not the theme. */+fun chipInk(onLight: Boolean): Color = if (onLight) Color(0xFF15171C) else Color.Whitediff --git a/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt b/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.ktindex 7ae93e9..423cce5 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/navigation/DocsNavGraph.kt@@ -69,6 +69,7 @@ import com.chethan616.clearpdf.ui.viewmodel.PdfViewerViewModelimport com.chethan616.clearpdf.ui.viewmodel.SplitPdfViewModelimport com.chethan616.clearpdf.ui.viewmodel.ScanViewModelimport com.kyant.backdrop.backdrops.LayerBackdrop+import com.chethan616.clearpdf.ui.utils.DocumentOpenOrigin/** Public so `DocsApp` can pick it as the start destination on a first run. */const val ROUTE_ONBOARDING = "onboarding"@@ -182,6 +183,28 @@ private fun isDocViewerRoute(route: String?): Boolean =route.startsWith(ROUTE_IMAGE_EDITOR_BASE))+/**+ * A document viewer opening: it grows out of the row that was tapped ([DocumentOpenOrigin]; the+ * centre otherwise) on a soft, barely-overshooting spring while it fades up — an iOS-style zoom that+ * keeps the file you tapped and the page you get spatially connected.+ */+private fun documentLiftIn(): EnterTransition =+ androidx.compose.animation.fadeIn(tween(220, easing = androidx.compose.animation.core.FastOutSlowInEasing)) ++ androidx.compose.animation.scaleIn(+ initialScale = 0.88f,+ transformOrigin = DocumentOpenOrigin.takeForEnter(),+ animationSpec = androidx.compose.animation.core.spring(dampingRatio = 0.82f, stiffness = 380f)+ )++/** A document viewer closing: the inverse of [documentLiftIn], settling back into where it came from. */+private fun documentSettleOut(): ExitTransition =+ androidx.compose.animation.fadeOut(tween(210, easing = androidx.compose.animation.core.FastOutSlowInEasing)) ++ androidx.compose.animation.scaleOut(+ targetScale = 0.9f,+ transformOrigin = DocumentOpenOrigin.current,+ animationSpec = tween(230, easing = androidx.compose.animation.core.FastOutSlowInEasing)+ )+@Composablefun DocsNavGraph(navController: NavHostController,@@ -454,28 +477,15 @@ fun DocsNavGraph(defaultValue = null}),- // "Document lifts open": one coordinated fade + soft-spring zoom-up from slightly- // smaller. The screen behind is held static+opaque (see [isDocViewerRoute]), so the- // lift reads against a stable backdrop with no edge flash. The earlier vertical slide is- // gone — a single centered scale settling on a spring is cleaner and flicker-free.- enterTransition = {- androidx.compose.animation.fadeIn(tween(200, easing = androidx.compose.animation.core.FastOutSlowInEasing)) +- androidx.compose.animation.scaleIn(- initialScale = 0.92f,- animationSpec = androidx.compose.animation.core.spring(- dampingRatio = 0.85f,- stiffness = androidx.compose.animation.core.Spring.StiffnessMediumLow- )- )- },+ // "Document lifts open" out of the row that was tapped (see [DocumentOpenOrigin]): one+ // coordinated fade + soft-spring zoom. The screen behind is held static+opaque (see+ // [isDocViewerRoute]), so the lift reads against a stable backdrop with no edge flash.+ enterTransition = { documentLiftIn() },exitTransition = { androidx.compose.animation.fadeOut(tween(160)) },popEnterTransition = { androidx.compose.animation.fadeIn(tween(200)) },- // Closing: the viewer settles back down + fades, revealing the (already-present) screen- // underneath. Symmetric with the open so back feels like the inverse of the lift.- popExitTransition = {- androidx.compose.animation.fadeOut(tween(210, easing = androidx.compose.animation.core.FastOutSlowInEasing)) +- androidx.compose.animation.scaleOut(targetScale = 0.94f, animationSpec = tween(220, easing = androidx.compose.animation.core.FastOutSlowInEasing))- }+ // Closing: the viewer settles back into the row it came from + fades, revealing the+ // (already-present) screen underneath — the inverse of the lift.+ popExitTransition = { documentSettleOut() }) { backStackEntry ->val context = LocalContext.currentval vm: PdfViewerViewModel = viewModel(@@ -512,16 +522,7 @@ fun DocsNavGraph(route = ROUTE_SPREADSHEET,arguments = listOf(navArgument(ARG_PDF_URI) { type = NavType.StringType; nullable = true; defaultValue = null }),// Same "document lifts open" as the PDF viewer (see that route) for a uniform feel.- enterTransition = {- androidx.compose.animation.fadeIn(tween(200, easing = androidx.compose.animation.core.FastOutSlowInEasing)) +- androidx.compose.animation.scaleIn(- initialScale = 0.92f,- animationSpec = androidx.compose.animation.core.spring(- dampingRatio = 0.85f,- stiffness = androidx.compose.animation.core.Spring.StiffnessMediumLow- )- )- },+ enterTransition = { documentLiftIn() },// Fade only: scaling the sheet makes every glass surface (full-screen grid panel, tabs,// share capsule, header) recompute its lens + blur each frame, which is what made Back feel// laggy here. An alpha-only exit reuses the cached layers.@@ -548,20 +549,8 @@ fun DocsNavGraph(route = ROUTE_IMAGE_EDITOR,arguments = listOf(navArgument(ARG_PDF_URI) { type = NavType.StringType; nullable = true; defaultValue = null }),// Same "document lifts open" as the PDF viewer (see that route) for a uniform feel.- enterTransition = {- androidx.compose.animation.fadeIn(tween(200, easing = androidx.compose.animation.core.FastOutSlowInEasing)) +- androidx.compose.animation.scaleIn(- initialScale = 0.92f,- animationSpec = androidx.compose.animation.core.spring(- dampingRatio = 0.85f,- stiffness = androidx.compose.animation.core.Spring.StiffnessMediumLow- )- )- },- popExitTransition = {- androidx.compose.animation.fadeOut(tween(210, easing = androidx.compose.animation.core.FastOutSlowInEasing)) +- androidx.compose.animation.scaleOut(targetScale = 0.94f, animationSpec = tween(220, easing = androidx.compose.animation.core.FastOutSlowInEasing))- }+ enterTransition = { documentLiftIn() },+ popExitTransition = { documentSettleOut() }) { backStackEntry ->val context = LocalContext.currentval vm: ImageEditorViewModel = viewModel()diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.ktindex e75bfed..8338e13 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt@@ -125,6 +125,8 @@ import com.chethan616.clearpdf.ui.components.GlassSearchHeaderimport com.chethan616.clearpdf.ui.components.LiquidButtonimport com.chethan616.clearpdf.ui.components.LiquidIconButtonimport com.chethan616.clearpdf.ui.components.liquidGlassPanel+import com.chethan616.clearpdf.ui.utils.liquidPressGlow+import com.chethan616.clearpdf.ui.utils.DocumentOpenOriginimport com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.rememberUISensor@@ -351,29 +353,26 @@ fun HomeScreen(// secondary control and shouldn't compete with the list.if (recents.isNotEmpty()) {val filterActive = recentFilter != null- Box(- Modifier- .size(28.dp)+ // A glass chip like the clear-all button beside it: vivid+ // accent while a filter is on, clear glass otherwise.+ LiquidIconButton(+ onClick = { filterMenuOpen = !filterMenuOpen },+ backdrop = backdrop,+ tint = if (filterActive) accent else Color.Unspecified,+ surfaceColor = if (filterActive) Color.Unspecified+ else if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.10f),+ modifier = Modifier+ .size(32.dp).onGloballyPositioned {val o = it.localToRoot(androidx.compose.ui.geometry.Offset.Zero)filterAnchorY = o.y + it.size.height}- .clip(RoundedCornerShape(50))- .background(- if (filterActive) accent.copy(0.20f)- else if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.10f)- )- .clickable(- interactionSource = remember { MutableInteractionSource() },- indication = null- ) { filterMenuOpen = !filterMenuOpen },- contentAlignment = Alignment.Center) {Icon(Icons.Rounded.FilterList,stringResource(R.string.recents_filter),Modifier.size(16.dp),- if (filterActive) accent else sub+ if (filterActive) Color.White else sub)}}@@ -1141,10 +1140,22 @@ private fun RecentRow(}.clip(RoundedCornerShape(16.dp)).background(if (isLight) Color.White.copy(0.18f) else Color.White.copy(0.06f))+ .liquidPressGlow(rowInteraction, onLight = isLight).combinedClickable(interactionSource = rowInteraction,indication = null,- onClick = onClick,+ onClick = {+ // The viewer grows out of this row (see DocumentOpenOrigin).+ val vw = view.width.toFloat()+ val vh = view.height.toFloat()+ if (vw > 0f && vh > 0f) {+ DocumentOpenOrigin.set(+ (metrics.leftX + metrics.width / 2f) / vw,+ (metrics.topY + metrics.height / 2f) / vh+ )+ }+ onClick()+ },onLongClick = {onLongClick(androidx.compose.ui.geometry.Rect(diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/OnboardingScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/OnboardingScreen.ktindex 9888a74..5cdfa11 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/OnboardingScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/OnboardingScreen.kt@@ -37,6 +37,7 @@ import androidx.compose.material.icons.automirrored.rounded.CallSplitimport androidx.compose.material.icons.automirrored.rounded.MergeTypeimport androidx.compose.material.icons.rounded.Compressimport androidx.compose.material.icons.rounded.DarkMode+import androidx.compose.material.icons.rounded.Languageimport androidx.compose.material.icons.rounded.LightModeimport androidx.compose.material.icons.rounded.PhoneAndroidimport androidx.compose.material.icons.rounded.PhotoLibrary@@ -74,7 +75,9 @@ import com.chethan616.clearpdf.ui.components.DemoToolsMenuimport com.chethan616.clearpdf.ui.components.GlassMenuActionimport com.chethan616.clearpdf.ui.components.GlassMotionimport com.chethan616.clearpdf.ui.components.LiquidButton+import com.chethan616.clearpdf.ui.components.LiquidGlassDropdownimport com.chethan616.clearpdf.ui.components.LiquidIconButton+import com.chethan616.clearpdf.ui.components.rememberLanguageOptionsimport com.chethan616.clearpdf.ui.components.LiquidToggleimport com.chethan616.clearpdf.ui.components.viewerChromeGlassimport com.chethan616.clearpdf.ui.components.viewerGlass@@ -428,7 +431,7 @@ private fun OnboardingPage(}/**- * Page 2 is the only interactive one — the real segmented control from Settings, not a replay.+ * Page 2 is the only interactive one — the real language dropdown from Settings, not a replay.** Selecting here does **not** restart the Activity; the caller updates the hoisted locale state and* re-provides `LocalResources`, so this whole screen re-composes translated. The restart, if the@@ -456,33 +459,17 @@ private fun LanguageChooser(stringResource(R.string.onboarding_language_label),style = TextStyle(inkSoft, 13.sp, fontWeight = FontWeight.SemiBold))- listOf(- "en" to R.string.language_english,- "pt-BR" to R.string.language_portuguese,- "es" to R.string.language_spanish,- "it" to R.string.language_italian,- "ru" to R.string.language_russian- ).forEach { (code, res) ->- val selected = selectedLocale == code- LiquidButton(- onClick = { onLocaleSelected(code) },- backdrop = backdrop,- tint = if (selected) accent else Color.Unspecified,- surfaceColor = if (selected) Color.Unspecified else (if (isDark) Color.White.copy(0.10f) else Color.Black.copy(0.06f)),- modifier = Modifier.fillMaxWidth()- ) {- BasicText(- stringResource(res),- style = TextStyle(- if (selected) Color.White else ink,- 15.sp,- fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium- ),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- }- }+ LiquidGlassDropdown(+ options = rememberLanguageOptions(),+ selected = selectedLocale,+ onSelect = onLocaleSelected,+ backdrop = backdrop,+ leadingIcon = Icons.Rounded.Language,+ accent = accent,+ triggerSurface = if (isDark) Color.White.copy(0.10f) else Color.Black.copy(0.06f),+ contentColor = ink,+ modifier = Modifier.fillMaxWidth()+ )}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfContinuousPage.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfContinuousPage.ktindex b3f4b80..512b6bb 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfContinuousPage.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfContinuousPage.kt@@ -97,6 +97,15 @@ import com.chethan616.clearpdf.ui.viewmodel.FindMatchimport com.chethan616.clearpdf.ui.viewmodel.OcrTextBlockimport com.chethan616.clearpdf.ui.viewmodel.OcrTextRangeimport com.chethan616.clearpdf.ui.components.viewerGlass+import com.chethan616.clearpdf.ui.components.liquidStretchOnDrag+import androidx.compose.runtime.SideEffect+import androidx.compose.runtime.Stable+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.ui.draw.drawBehind+import androidx.compose.foundation.layout.statusBars+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.navigationBars+import kotlinx.coroutines.launchimport com.kyant.backdrop.backdrops.LayerBackdropimport kotlin.math.maximport kotlin.math.min@@ -145,7 +154,9 @@ internal fun PdfContinuousPage(onMoveMarkups: (Set<Int>, Offset) -> Unit = { _, _ -> },onDeleteMarkup: (Int) -> Unit = {},/** The viewer's text selection: this page draws its slice of the highlight and registers its coordinates. */- textSelection: PdfTextSelectionState+ textSelection: PdfTextSelectionState,+ /** Where this page publishes its contextual Edit / Delete bar; the viewer draws it. */+ markupBar: MarkupBarHost) {var draftPoints by remember(page, activeTool) { mutableStateOf<List<Offset>>(emptyList()) }var draftRectStart by remember(page, activeTool) { mutableStateOf<Offset?>(null) }@@ -692,21 +703,15 @@ internal fun PdfContinuousPage(val csz = pageCanvasSizes[page]// ── Contextual Edit / Delete bar for the selected shape / text / note ──────+ // Published to the viewer, which draws it outside the content layer (see MarkupBarHost).if (activeTool == PdfEditTool.None && csz != null && csz.width > 0f) {marks.getOrNull(selectedMarkupIndex)?.takeIf { it.isTransformable() }?.let { selM ->selM.movableBounds()?.let { b ->- val density = LocalDensity.current- val gapPx = with(density) { 12.dp.toPx() }- val barHpx = with(density) { MarkupBarHeight.toPx() }- val barWpx = with(density) { MarkupBarWidth.toPx() }- val placeBelow = b.top < barHpx + gapPx- val by = (if (placeBelow) b.bottom + gapPx else b.top - barHpx - gapPx)- .coerceIn(0f, (csz.height - barHpx).coerceAtLeast(0f))- val bx = ((b.left + b.right) / 2f - barWpx / 2f)- .coerceIn(0f, (csz.width - barWpx).coerceAtLeast(0f))-- MarkupActionBar(- backdrop = backdrop,+ PublishMarkupBar(+ host = markupBar,+ page = page,+ token = selectedMarkupIndex,+ anchor = b,onEdit = {when (selM) {is PdfMarkup.TextBoxMarkup -> onEditAnnotation(selM.id)@@ -715,8 +720,7 @@ internal fun PdfContinuousPage(}},onDelete = { onDeleteMarkup(selectedMarkupIndex) },- onDismiss = { onSelectMarkup(-1) },- modifier = Modifier.offset { IntOffset(bx.roundToInt(), by.roundToInt()) }+ onDismiss = { onSelectMarkup(-1) })}}@@ -733,22 +737,14 @@ internal fun PdfContinuousPage(val y = selected.textMarkupLineY(rangeRect) ?: rangeRect.bottomRect(rangeRect.left, y - 4f, rangeRect.right, y + 4f)} else rangeRect- val density = LocalDensity.current- val gapPx = with(density) { 10.dp.toPx() }- val barHpx = with(density) { MarkupBarHeight.toPx() }- val barWpx = with(density) { MarkupBarWidth.toPx() }- val placeBelow = anchorRect.top < barHpx + gapPx- val by = (if (placeBelow) anchorRect.bottom + gapPx else anchorRect.top - barHpx - gapPx)- .coerceIn(0f, (csz.height - barHpx).coerceAtLeast(0f))- val bx = ((anchorRect.left + anchorRect.right) / 2f - barWpx / 2f)- .coerceIn(0f, (csz.width - barWpx).coerceAtLeast(0f))-- MarkupActionBar(- backdrop = backdrop,+ PublishMarkupBar(+ host = markupBar,+ page = page,+ token = selectedMarkupIndex,+ anchor = anchorRect,onEdit = { onEditShape(selectedMarkupIndex) },onDelete = { onDeleteMarkup(selectedMarkupIndex) },- onDismiss = { onSelectMarkup(-1) },- modifier = Modifier.offset { IntOffset(bx.roundToInt(), by.roundToInt()) }+ onDismiss = { onSelectMarkup(-1) })}}@@ -759,51 +755,184 @@ private val MarkupBarWidth = 236.dpprivate val MarkupBarHeight = 48.dp/**- * Contextual Edit / Delete / dismiss capsule for a selected markup (shape, text box, note, text- * highlight/underline/strike). Clear chrome glass — pure refraction, like the bottom toolbar's own- * circles and [com.chethan616.clearpdf.ui.components.ShareMorphButton]'s idle state — instead of a- * dialog-weight platter, since this floats over the document the same way that chrome does. The- * entrance is the same family of spring ShareMorph uses: a real overshoot on scale (not clamped away)- * while alpha stays critically damped, so it springs in with actual weight instead of a flat fade.- * Dismissal also works by tapping anywhere else in the viewer or pressing Back.+ * Hand-off for the contextual Edit / Delete bar. The page owning the selected markup publishes where+ * it is ([PublishMarkupBar]); the viewer draws the bar ([PdfMarkupBarLayer]) as a sibling of its+ * content layer, beside the text-selection toolbar.+ *+ * Why: drawn inside the page, the bar was inside the very layer the viewer's glass records, so it+ * could only sample the wallpaper — with the default flat background that is one grey colour, which+ * is why it read as a flat pill instead of glass. Outside, it refracts the live page like the title+ * chips refract the home screen. It also stops scaling with zoom: a floating control keeps its size.+ */+@Stable+internal class MarkupBarHost {+ internal var owner by mutableStateOf<Any?>(null)+ internal var token by mutableIntStateOf(-1)+ internal var page by mutableIntStateOf(-1)+ /** The markup's bounds in the owning page's px (its layout coordinates). Read at layout only. */+ internal var anchor by mutableStateOf(Rect.Zero)+ internal var onEdit: () -> Unit = {}+ internal var onDelete: () -> Unit = {}+ internal var onDismiss: () -> Unit = {}+}++@Composable+private fun PublishMarkupBar(+ host: MarkupBarHost,+ page: Int,+ token: Int,+ anchor: Rect,+ onEdit: () -> Unit,+ onDelete: () -> Unit,+ onDismiss: () -> Unit+) {+ val key = remember { Any() }+ // Plain fields for the callbacks (read at click time); state for what the bar lays out from.+ // Same-value writes are no-ops, so an idle recomposition invalidates nothing.+ SideEffect {+ host.onEdit = onEdit+ host.onDelete = onDelete+ host.onDismiss = onDismiss+ host.page = page+ host.token = token+ host.anchor = anchor+ host.owner = key+ }+ DisposableEffect(host) { onDispose { if (host.owner === key) host.owner = null } }+}++/**+ * Viewer-level Edit / Delete / dismiss capsule for the markup a page published to [host], in the+ * title-chip glass ([com.chethan616.clearpdf.ui.components.chipGlass]) with ink picked from the page+ * behind it. Fills the viewer; only the capsule takes touches.+ *+ * Placement follows the platform's floating toolbar: centred above the markup, below it when there is+ * no room, clamped clear of the screen edges and system bars; it follows the markup through scroll,+ * zoom and drag (geometry is read at layout, so none of that recomposes).+ *+ * Motion: springs in with a real overshoot on scale from the markup's side while alpha stays+ * critically damped; selecting another markup gives it a small "boop" in place; it settles away+ * without a wobble.+ */+@Composable+internal fun PdfMarkupBarLayer(+ host: MarkupBarHost,+ textSelection: PdfTextSelectionState,+ listState: androidx.compose.foundation.lazy.LazyListState,+ backdrop: Backdrop,+ luminanceAt: (top: Float, bottom: Float) -> Float,+ modifier: Modifier = Modifier+) {+ val owner = host.owner+ val shown = owner != null+ val density = LocalDensity.current+ val alpha = remember { androidx.compose.animation.core.Animatable(0f) }+ val scale = remember { androidx.compose.animation.core.Animatable(0.72f) }+ var onLight by remember { mutableStateOf(true) }+ val currentLuminance by rememberUpdatedState(luminanceAt)+ // Side of the markup the bar sits on; written at layout, reset to "above" per new selection.+ val placedAbove = remember { booleanArrayOf(true) }+ LaunchedEffect(owner, host.token) {+ placedAbove[0] = true+ if (owner == null) {+ launch { scale.animateTo(0.9f, com.chethan616.clearpdf.ui.components.GlassMotion.settle()) }+ alpha.animateTo(0f, com.chethan616.clearpdf.ui.components.GlassMotion.settle())+ return@LaunchedEffect+ }+ // Ink from the page around the markup (the bar may land above or below it).+ val origin = textSelection.pageOrigin(host.page)+ if (origin != null) {+ val r = textSelection.transform.pageRectToScreen(host.anchor, origin)+ val pad = with(density) { 72.dp.toPx() }+ onLight = currentLuminance(r.top - pad, r.bottom + pad) > 0.6f+ }+ // First appearance pops from 0.72; a new selection while visible gives a smaller boop.+ if (alpha.value > 0.5f) scale.snapTo(0.9f) else scale.snapTo(0.72f)+ launch { alpha.animateTo(1f, com.chethan616.clearpdf.ui.components.GlassMotion.fade()) }+ scale.animateTo(1f, com.chethan616.clearpdf.ui.components.GlassMotion.pop())+ }+ if (!shown && alpha.value <= 0.01f) return++ val glass by androidx.compose.animation.animateColorAsState(+ com.chethan616.clearpdf.ui.components.chipGlass(onLight),+ com.chethan616.clearpdf.ui.components.GlassMotion.fade(),+ label = "markupBarGlass"+ )+ val ink by androidx.compose.animation.animateColorAsState(+ com.chethan616.clearpdf.ui.components.chipInk(onLight),+ com.chethan616.clearpdf.ui.components.GlassMotion.fade(),+ label = "markupBarInk"+ )+ val statusTop = androidx.compose.foundation.layout.WindowInsets.statusBars.getTop(density)+ val navBottom = androidx.compose.foundation.layout.WindowInsets.navigationBars.getBottom(density)++ androidx.compose.ui.layout.Layout(+ content = {+ MarkupActionBar(+ backdrop = backdrop,+ glass = glass,+ ink = ink,+ onEdit = { host.onEdit() },+ onDelete = { host.onDelete() },+ onDismiss = { host.onDismiss() }+ )+ },+ modifier = modifier.fillMaxSize()+ ) { measurables, constraints ->+ val bar = measurables.first().measure(androidx.compose.ui.unit.Constraints())+ layout(constraints.maxWidth, constraints.maxHeight) {+ // Subscribe the placement (not composition) to scroll and zoom.+ listState.firstVisibleItemIndex; listState.firstVisibleItemScrollOffset+ val t = textSelection.transform+ val origin = textSelection.pageOrigin(host.page) ?: return@layout+ val r = t.pageRectToScreen(host.anchor, origin)+ val margin = 12.dp.toPx()+ val gap = 12.dp.toPx()+ val topSafe = statusTop + margin+ val bottomSafe = constraints.maxHeight - navBottom - margin+ val aboveY = r.top - gap - bar.height+ // Decide the side once per appearance-ish: only flip when the preferred side truly+ // stops fitting, so a markup dragged near the edge doesn't make the bar hop.+ val fitsAbove = aboveY >= topSafe+ val fitsBelow = r.bottom + gap + bar.height <= bottomSafe+ val above = if (placedAbove[0]) fitsAbove || !fitsBelow else !fitsBelow && fitsAbove+ placedAbove[0] = above+ val y = (if (above) aboveY else r.bottom + gap)+ .coerceIn(topSafe, (bottomSafe - bar.height).coerceAtLeast(topSafe))+ val x = (r.center.x - bar.width / 2f)+ .coerceIn(margin, (constraints.maxWidth - bar.width - margin).coerceAtLeast(margin))+ val pivotX = if (bar.width > 0) ((r.center.x - x) / bar.width).coerceIn(0f, 1f) else 0.5f+ bar.placeWithLayer(x.roundToInt(), y.roundToInt()) {+ this.alpha = alpha.value.coerceIn(0f, 1f)+ scaleX = scale.value; scaleY = scale.value+ transformOrigin = androidx.compose.ui.graphics.TransformOrigin(pivotX, if (above) 1f else 0f)+ }+ }+ }+}++/**+ * The Edit / Delete / dismiss capsule itself, in the title-chip glass: [glass] tint over the lensed+ * live page, [ink] chosen for the page behind it. Dismissal also works by tapping anywhere else in the+ * viewer or pressing Back.*/@Composableprivate fun MarkupActionBar(backdrop: Backdrop,+ glass: Color,+ ink: Color,onEdit: () -> Unit,onDelete: () -> Unit,onDismiss: () -> Unit,modifier: Modifier = Modifier) {- val isDark = com.chethan616.clearpdf.ui.theme.LocalIsDarkMode.current- val ink = com.chethan616.clearpdf.ui.theme.LiquidGlassColors.text(isDark)val red = com.chethan616.clearpdf.ui.theme.LiquidGlassColors.Redval haptics = androidx.compose.ui.platform.LocalHapticFeedback.current- var shown by remember { mutableStateOf(false) }- LaunchedEffect(Unit) { shown = true }- // Alpha settles critically damped (a bouncing alpha reads as a flicker, per GlassMotion's own- // rule); scale is left to overshoot past 1 and spring back — the actual "pop" ShareMorph has.- val alpha by androidx.compose.animation.core.animateFloatAsState(- if (shown) 1f else 0f,- com.chethan616.clearpdf.ui.components.GlassMotion.fade(),- label = "markupBarAlpha"- )- val scale by androidx.compose.animation.core.animateFloatAsState(- if (shown) 1f else 0.72f,- com.chethan616.clearpdf.ui.components.GlassMotion.pop(),- label = "markupBarScale"- )Row(modifier.width(MarkupBarWidth).height(MarkupBarHeight)- .graphicsLayer {- this.alpha = alpha.coerceIn(0f, 1f)- scaleX = scale; scaleY = scale- }- // Clear glass: only the backdrop refraction + lens carry the material, same as the- // toolbar's own circles. A tinted/opaque fill here is what read as "not liquid glass".- .viewerGlass(backdrop, Color.Transparent, shape = { com.kyant.shapes.Capsule })+ .viewerGlass(backdrop, glass, shape = { com.kyant.shapes.Capsule }).padding(horizontal = 4.dp),verticalAlignment = Alignment.CenterVertically) {@@ -843,12 +972,22 @@ private fun MarkupBarItem(com.chethan616.clearpdf.ui.components.GlassMotion.press(),label = "markupItemPress")+ // A soft tinted well under the finger, like the selection toolbar's items.+ val wash by androidx.compose.animation.core.animateFloatAsState(+ if (pressed) 0.12f else 0f,+ com.chethan616.clearpdf.ui.components.GlassMotion.fade(),+ label = "markupItemWash"+ )Row(modifier.fillMaxHeight().padding(vertical = 4.dp)+ // Draw-time only: sliding a finger across squashes the pill along the drag, like a drop+ // of the glass it sits on.+ .liquidStretchOnDrag(stretchFactor = 0.18f, minScale = 0.88f, maxScale = 1.12f).graphicsLayer { scaleX = press; scaleY = press }.clip(com.kyant.shapes.Capsule)+ .drawBehind { if (wash > 0f) drawRect(color.copy(alpha = wash)) }.clickable(interactionSource = interaction, indication = null, onClick = onClick).padding(horizontal = if (iconOnly) 0.dp else 8.dp),horizontalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterHorizontally),diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.ktindex 4821e41..12cac62 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerDialogs.kt@@ -7,6 +7,10 @@ import com.chethan616.clearpdf.ui.components.glassDialogPlatterimport com.chethan616.clearpdf.ui.components.glassDialogInkSoftimport com.chethan616.clearpdf.ui.components.glassDialogInkimport com.chethan616.clearpdf.ui.components.GlassDialogSegmented+import com.chethan616.clearpdf.ui.components.GlassDropdownOption+import com.chethan616.clearpdf.ui.components.LiquidGlassDropdown+import androidx.compose.material.icons.rounded.Description+import androidx.compose.material.icons.rounded.PictureAsPdfimport com.chethan616.clearpdf.ui.components.GlassDialogFieldimport com.chethan616.clearpdf.ui.components.GlassDialogActionimport com.chethan616.clearpdf.ui.components.GlassDialog@@ -282,9 +286,10 @@ internal enum class ShareFormat { ORIGINAL, PDF }/*** Share/export chooser on the shared [GlassDialog] card. For a converted document (a .docx opened as- * a PDF) it offers the original file or a PDF; when PDF is the target it can encrypt with a password.- * Both choices are [GlassDialogSegmented] controls — solid tracks with a vivid sliding thumb — so- * every option is legible over any page (the old glass pills went blank on light pages).+ * a PDF) it offers the original file or a PDF in a [LiquidGlassDropdown]; when PDF is the target it+ * can encrypt with a password, chosen on a [GlassDialogSegmented]. Both controls sit on the solid+ * dialog platter so every option is legible over any page (the old glass pills went blank on light+ * pages) while their lensed rims still refract the screen.** The dialog only collects intent — the file work (encrypt, wrap, chooser) runs off the UI thread in* the caller.@@ -340,10 +345,18 @@ internal fun ExportShareDialog(stringResource(R.string.viewer_share_format),style = TextStyle(soft, 13.sp, FontWeight.Medium))- GlassDialogSegmented(- options = listOf(originalExt.orEmpty(), stringResource(R.string.viewer_share_pdf)),- selectedIndex = formatIndex,- onSelect = { formatIndex = it }+ // The share sheet's original bouncy glass dropdown (v3), back on the shared component.+ LiquidGlassDropdown(+ options = listOf(+ GlassDropdownOption(0, originalExt.orEmpty(), icon = Icons.Rounded.Description),+ GlassDropdownOption(1, stringResource(R.string.viewer_share_pdf), icon = Icons.Rounded.PictureAsPdf)+ ),+ selected = formatIndex,+ onSelect = { formatIndex = it },+ backdrop = backdrop,+ leadingIcon = if (formatIndex == 1) Icons.Rounded.PictureAsPdf else Icons.Rounded.Description,+ triggerSurface = glassDialogPlatter(LocalIsDarkMode.current),+ modifier = Modifier.fillMaxWidth())}AnimatedVisibility(diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.ktindex 4786ce6..e14c073 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt@@ -354,6 +354,7 @@ fun PdfViewerScreen(// ── Text selection (long-press, native-style handles, glass toolbar) ─────────────────────val textSelection = remember { PdfTextSelectionState() }+ val markupBarHost = remember { MarkupBarHost() }textSelection.blocksProvider = { p -> viewModel.uiState.value.ocrBlocksByPage[p].orEmpty() }var containerWidthPx by remember { mutableIntStateOf(0) }textSelection.transformProvider = { PdfViewportTransform(containerWidthPx.toFloat(), scale, offsetX) }@@ -1219,7 +1220,8 @@ fun PdfViewerScreen(selectedAnnoPage = null; selectedAnnoIndex = -1selectedMarkupGroupPage = null; selectedMarkupGroup = emptySet()},- textSelection = textSelection+ textSelection = textSelection,+ markupBar = markupBarHost)}}@@ -1760,18 +1762,32 @@ fun PdfViewerScreen(}}}+ // Floating contextual chrome, in the title-chip glass over the live page, with ink sampled from+ // the document behind each control (same band sampling as the bars).+ val pageLuminanceAt: (Float, Float) -> Float = { top, bottom ->+ bandLuminance(listState.layoutInfo, state.pageBitmaps, scale, top, bottom, darkPageAppearance)+ }+ PdfMarkupBarLayer(+ host = markupBarHost,+ textSelection = textSelection,+ listState = listState,+ backdrop = contentBackdrop,+ luminanceAt = pageLuminanceAt+ )PdfSelectionToolbar(state = textSelection,listState = listState,backdrop = contentBackdrop,actions = selectionActions,highlightColor = currentColor,- hasHighlightOverlap = hasHighlightOverlap+ hasHighlightOverlap = hasHighlightOverlap,+ luminanceAt = pageLuminanceAt)PdfCopiedToast(trigger = copiedTick,backdrop = contentBackdrop,- modifier = Modifier.align(Alignment.BottomCenter).navigationBarsPadding().padding(bottom = 112.dp)+ modifier = Modifier.align(Alignment.BottomCenter).navigationBarsPadding().padding(bottom = 112.dp),+ onLight = bottomBarLight)// ── Page-jump popup (in-window, so it samples the liquid-glass backdrop) ──@@ -1974,13 +1990,17 @@ fun PdfViewerScreen(var revealDocument by remember { mutableStateOf(false) }LaunchedEffect(firstPageRendered) {if (firstPageRendered && !revealDocument) {- delay(140) // let the page paint a frame before we lift the curtain+ // Lift the curtain once the page has actually been drawn — two frames, not a fixed+ // 140 ms guess that left a fast-loading file waiting behind an empty curtain.+ androidx.compose.runtime.withFrameNanos { }+ androidx.compose.runtime.withFrameNanos { }revealDocument = true}}AnimatedVisibility(visible = !revealDocument,- exit = fadeOut(tween(420, easing = androidx.compose.animation.core.FastOutSlowInEasing)),+ // A quicker, ease-out dissolve: the page is ready, so get out of its way.+ exit = fadeOut(tween(300, easing = androidx.compose.animation.core.LinearOutSlowInEasing)),modifier = Modifier.fillMaxSize()) {ViewerLoadingCurtain(isLight = isLight)diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.ktindex 2908d31..39de11f 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt@@ -88,7 +88,9 @@ import com.chethan616.clearpdf.ui.components.GlassDialogActionimport com.chethan616.clearpdf.ui.components.GlassScreenHeaderRowimport com.chethan616.clearpdf.ui.components.GlassScreenScaffoldimport com.chethan616.clearpdf.ui.components.LiquidButton+import com.chethan616.clearpdf.ui.components.LiquidGlassDropdownimport com.chethan616.clearpdf.ui.components.LiquidIconButton+import com.chethan616.clearpdf.ui.components.rememberLanguageOptionsimport com.chethan616.clearpdf.ui.components.LiquidSliderimport com.chethan616.clearpdf.ui.components.LiquidToggleimport com.chethan616.clearpdf.ui.components.ToolInk@@ -248,28 +250,14 @@ fun SettingsScreen(// ── Language ──SettingsSection(backdrop, uiSensor, entrance.sectionFade(2)) {SettingsSectionHeader(Icons.Rounded.Language, stringResource(R.string.settings_language), ink)- data class LangOption(val code: String, val label: String)- val langs = listOf(- LangOption("en", stringResource(R.string.language_english)),- LangOption("pt-BR", stringResource(R.string.language_portuguese)),- LangOption("es", stringResource(R.string.language_spanish)),- LangOption("it", stringResource(R.string.language_italian)),- LangOption("ru", stringResource(R.string.language_russian))+ LiquidGlassDropdown(+ options = rememberLanguageOptions(),+ selected = selectedLocale,+ onSelect = onLocaleChanged,+ backdrop = backdrop,+ leadingIcon = Icons.Rounded.Language,+ modifier = Modifier.fillMaxWidth())- Row(- Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),- horizontalArrangement = Arrangement.spacedBy(10.dp)- ) {- langs.forEach { opt ->- GlassChoiceChip(- label = opt.label,- selected = selectedLocale == opt.code,- onClick = { onLocaleChanged(opt.code) },- backdrop = backdrop,- accent = LiquidGlassColors.Blue- )- }- }}// ── Save Location + File Handling + Default Quality ── one panel: three relateddiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/selection/PdfSelectionToolbar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/selection/PdfSelectionToolbar.ktindex bf71545..aa70ddf 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/selection/PdfSelectionToolbar.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/selection/PdfSelectionToolbar.kt@@ -93,11 +93,17 @@ import androidx.compose.ui.unit.spimport androidx.core.graphics.drawable.toBitmapimport com.chethan616.clearpdf.Rimport com.chethan616.clearpdf.ui.components.GlassMotion+import com.chethan616.clearpdf.ui.components.chipGlass+import com.chethan616.clearpdf.ui.components.chipInk+import com.chethan616.clearpdf.ui.components.glassMenuimport com.chethan616.clearpdf.ui.components.viewerGlassimport com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.kyant.backdrop.Backdrop+import com.kyant.shapes.Capsuleimport com.kyant.shapes.RoundedRectangle+import androidx.compose.animation.animateColorAsState+import androidx.compose.runtime.rememberUpdatedStateimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.delayimport kotlinx.coroutines.flow.collectLatest@@ -174,11 +180,15 @@ fun PdfSelectionToolbar(actions: PdfSelectionActions,highlightColor: Color,hasHighlightOverlap: () -> Boolean,- modifier: Modifier = Modifier+ modifier: Modifier = Modifier,+ /**+ * Luminance (0..1) of the document inside a screen-space band. With it the capsule wears the+ * title-chip glass ([chipGlass]) — nearly clear — and picks its ink from the page behind it, like+ * the viewer's top bar; without it, the theme's dense platter.+ */+ luminanceAt: ((top: Float, bottom: Float) -> Float)? = null) {val isDark = LocalIsDarkMode.current- val fg = LiquidGlassColors.text(isDark)- val glass = if (isDark) Color(0xFF1C1D22).copy(alpha = 0.72f) else Color.White.copy(alpha = 0.74f)val density = LocalDensity.currentval haptics = LocalHapticFeedback.currentval context = LocalContext.current@@ -219,6 +229,32 @@ fun PdfSelectionToolbar(// A new selection (not a toolbar action) resets the menu back to the capsule.LaunchedEffect(state.start, state.end) { page = ToolbarPage.Main }+ // Ink follows the page under the capsule (it may sit above or below the selection, so sample a+ // band spanning both), decided once per appearance — the capsule is hidden while anything moves.+ var onLight by remember { mutableStateOf(!isDark) }+ val currentLuminance by rememberUpdatedState(luminanceAt)+ LaunchedEffect(shown) {+ val lum = currentLuminance ?: return@LaunchedEffect+ if (!shown) return@LaunchedEffect+ val rects = state.selectionScreenRects()+ if (rects.isEmpty()) return@LaunchedEffect+ val top = rects.minOf { it.top } - with(density) { 72.dp.toPx() }+ val bottom = rects.maxOf { it.bottom } + with(density) { 96.dp.toPx() }+ onLight = lum(top, bottom) > 0.6f+ }+ val fg by animateColorAsState(+ if (luminanceAt != null) chipInk(onLight) else LiquidGlassColors.text(isDark),+ GlassMotion.fade(),+ label = "selToolbarInk"+ )+ val glass by animateColorAsState(+ if (luminanceAt != null) chipGlass(onLight)+ else if (isDark) Color(0xFF1C1D22).copy(alpha = 0.72f) else Color.White.copy(alpha = 0.74f),+ GlassMotion.fade(),+ label = "selToolbarGlass"+ )+ val menuDark = if (luminanceAt != null) !onLight else isDark+val alpha by animateFloatAsState(if (shown) 1f else 0f, GlassMotion.fade(), label = "selToolbarAlpha")val scale by animateFloatAsState(if (shown) 1f else 0.9f,@@ -320,7 +356,7 @@ fun PdfSelectionToolbar(when (p) {ToolbarPage.Main -> Row(Modifier- .viewerGlass(backdrop, glass, shape = { RoundedRectangle(24.dp) })+ .viewerGlass(backdrop, glass, shape = { Capsule }).height(48.dp).padding(horizontal = 4.dp),verticalAlignment = Alignment.CenterVertically@@ -332,7 +368,9 @@ fun PdfSelectionToolbar(}ToolbarPage.Overflow -> Column(Modifier- .viewerGlass(backdrop, glass, shape = { RoundedRectangle(22.dp) })+ // A menu of text rows: the frosted menu material (same as dropdowns),+ // so labels stay legible over page text.+ .glassMenu(backdrop, dark = menuDark, shape = { RoundedRectangle(22.dp) }).widthIn(min = 200.dp, max = 280.dp).verticalScroll(rememberScrollState()).padding(vertical = 6.dp)@@ -342,7 +380,7 @@ fun PdfSelectionToolbar(}ToolbarPage.Colors -> Row(Modifier- .viewerGlass(backdrop, glass, shape = { RoundedRectangle(24.dp) })+ .viewerGlass(backdrop, glass, shape = { Capsule }).height(48.dp).padding(horizontal = 4.dp).semantics { contentDescription = colorL },@@ -545,10 +583,18 @@ private fun ColorDot(backdrop: Backdrop, color: Color, selected: Boolean, ring:/** A brief liquid-glass "Copied" confirmation near the bottom of the viewer. [trigger] > 0 shows it. */@Composable-fun PdfCopiedToast(trigger: Int, backdrop: Backdrop, modifier: Modifier = Modifier) {+fun PdfCopiedToast(+ trigger: Int,+ backdrop: Backdrop,+ modifier: Modifier = Modifier,+ // Whether the content behind the toast is light; when given, it wears the chip glass with ink+ // that follows the page (like the toolbar above), otherwise the theme platter.+ onLight: Boolean? = null+) {val isDark = LocalIsDarkMode.current- val fg = LiquidGlassColors.text(isDark)- val glass = if (isDark) Color(0xFF1C1D22).copy(alpha = 0.72f) else Color.White.copy(alpha = 0.74f)+ val fg = if (onLight != null) chipInk(onLight) else LiquidGlassColors.text(isDark)+ val glass = if (onLight != null) chipGlass(onLight)+ else if (isDark) Color(0xFF1C1D22).copy(alpha = 0.72f) else Color.White.copy(alpha = 0.74f)var visible by remember { mutableStateOf(false) }LaunchedEffect(trigger) {if (trigger > 0) { visible = true; delay(1400); visible = false }@@ -560,7 +606,7 @@ fun PdfCopiedToast(trigger: Int, backdrop: Backdrop, modifier: Modifier = ModifiRow(modifier.graphicsLayer { this.alpha = alpha; scaleX = scale; scaleY = scale }- .viewerGlass(backdrop, glass, shape = { RoundedRectangle(20.dp) })+ .viewerGlass(backdrop, glass, shape = { Capsule }).height(40.dp).padding(horizontal = 16.dp).semantics { contentDescription = label; liveRegion = LiveRegionMode.Polite },diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/DocumentOpenOrigin.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/DocumentOpenOrigin.ktnew file mode 100644index 0000000..f0a5b83--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/DocumentOpenOrigin.kt@@ -0,0 +1,37 @@+package com.chethan616.clearpdf.ui.utils++import android.os.SystemClock+import androidx.compose.ui.graphics.TransformOrigin++/**+ * Where on screen a document was opened from, so its viewer grows out of that spot — and shrinks+ * back into it on Back — instead of zooming from the screen's centre: the iOS "zoom from the+ * thumbnail" cue that ties the page you get to the row you tapped.+ *+ * The tapped element calls [set] right before navigating; the viewer routes' transitions read it.+ * Anything that opens a viewer without setting it (a tool's output, a share intent, the picker) gets+ * the centre, because a pending origin expires after a moment.+ */+object DocumentOpenOrigin {+ private const val VALID_MS = 1500L++ private var pending: TransformOrigin? = null+ private var pendingAt = 0L++ /** The origin the current viewer opened from; Back shrinks toward it. */+ var current: TransformOrigin = TransformOrigin.Center+ private set++ /** [pivotX]/[pivotY] are fractions (0..1) of the window, e.g. the tapped row's centre. */+ fun set(pivotX: Float, pivotY: Float) {+ pending = TransformOrigin(pivotX.coerceIn(0f, 1f), pivotY.coerceIn(0f, 1f))+ pendingAt = SystemClock.uptimeMillis()+ }++ /** For a viewer route's enter transition. Idempotent within one navigation. */+ fun takeForEnter(): TransformOrigin {+ val fresh = pending?.takeIf { SystemClock.uptimeMillis() - pendingAt < VALID_MS }+ current = fresh ?: TransformOrigin.Center+ return current+ }+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.ktindex dbc8f57..6ca9b89 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/InteractiveHighlight.kt@@ -18,22 +18,39 @@ import androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.util.fastCoerceInimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.Job+import kotlinx.coroutines.delayimport kotlinx.coroutines.launchclass InteractiveHighlight(val animationScope: CoroutineScope,- val position: (size: Size, offset: Offset) -> Offset = { _, offset -> offset }+ val position: (size: Size, offset: Offset) -> Offset = { _, offset -> offset },+ /**+ * Holding a finger still past the platform long-press timeout "blooms" the control: [expandProgress]+ * springs to 1 (the owner grows a little further on top of the press scale and glows brighter)+ * and [onLongPressExpand] fires once — the owner's haptic. Off by default: tab bars and cards+ * own their own long-press meaning.+ */+ private val longPressExpand: Boolean = false,+ private val onLongPressExpand: (() -> Unit)? = null) {private val pressProgressAnimationSpec = spring(0.5f, 300f, 0.001f)private val positionAnimationSpec = spring(0.5f, 300f, Offset.VisibilityThreshold)+ // Bloom in on a soft, slightly slower spring; let go on a livelier one that undershoots rest+ // a touch before settling — the "boing" that makes the release feel physical.+ private val expandInSpec = spring(dampingRatio = 0.52f, stiffness = 340f, visibilityThreshold = 0.001f)+ private val expandOutSpec = spring(dampingRatio = 0.46f, stiffness = 420f, visibilityThreshold = 0.001f)private val pressProgressAnimation = Animatable(0f, 0.001f)private val positionAnimation = Animatable(Offset.Zero, Offset.VectorConverter, Offset.VisibilityThreshold)+ private val expandAnimation = Animatable(0f, 0.001f)private var startPosition = Offset.Zeroprivate var positionUpdateJob: Job? = null+ private var longPressJob: Job? = nullval pressProgress: Float get() = pressProgressAnimation.valueval offset: Offset get() = positionAnimation.value - startPosition+ /** 0 at rest, 1 once a long-press has bloomed; briefly dips below 0 on the release bounce. */+ val expandProgress: Float get() = expandAnimation.value// Built on first press, not at construction. Every LiquidButton / LiquidIconButton / glass card// owns one of these, and `RuntimeShader(...)` compiles its AGSL on the calling thread — so a@@ -62,15 +79,17 @@ half4 main(float2 coord) {val modifier: Modifier =Modifier.drawWithContent {val progress = pressProgressAnimation.value+ // A bloomed long-press lifts the glow a little further, so the control reads as "picked up".+ val bloom = expandAnimation.value.fastCoerceIn(0f, 1f)if (progress > 0f) {val shader = [email protected]if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && shader != null) {- drawRect(Color.White.copy(0.08f * progress), blendMode = BlendMode.Plus)+ drawRect(Color.White.copy(0.08f * progress + 0.05f * bloom), blendMode = BlendMode.Plus)shader.apply {val position = position(size, positionAnimation.value)setFloatUniform("size", size.width, size.height)- setColorUniform("color", Color.White.copy(0.15f * progress).toArgb())- setFloatUniform("radius", size.minDimension * 1.5f)+ setColorUniform("color", Color.White.copy(0.15f * progress + 0.10f * bloom).toArgb())+ setFloatUniform("radius", size.minDimension * (1.5f + 0.5f * bloom))setFloatUniform("position",position.x.fastCoerceIn(0f, size.width),@@ -85,32 +104,50 @@ half4 main(float2 coord) {drawContent()}+ private fun release() {+ positionUpdateJob?.cancel()+ longPressJob?.cancel()+ animationScope.launch {+ launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }+ launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }+ if (expandAnimation.value != 0f || expandAnimation.targetValue != 0f) {+ launch { expandAnimation.animateTo(0f, expandOutSpec) }+ }+ }+ }+val gestureModifier: Modifier =Modifier.pointerInput(animationScope) {+ val longPressMs = viewConfiguration.longPressTimeoutMillis+ val slop = viewConfiguration.touchSlopinspectDragGestures(onDragStart = { down ->startPosition = down.positionpositionUpdateJob?.cancel()+ longPressJob?.cancel()animationScope.launch {launch { pressProgressAnimation.animateTo(1f, pressProgressAnimationSpec) }launch { positionAnimation.snapTo(startPosition) }}- },- onDragEnd = {- positionUpdateJob?.cancel()- animationScope.launch {- launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }- launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }+ if (longPressExpand) {+ // Same timeout the platform uses for long-click, so a button that also has an+ // onLongClick blooms exactly as its own long-press fires.+ longPressJob = animationScope.launch {+ delay(longPressMs)+ onLongPressExpand?.invoke()+ expandAnimation.animateTo(1f, expandInSpec)+ }}},- onDragCancel = {- positionUpdateJob?.cancel()- animationScope.launch {- launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }- launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }- }- }+ onDragEnd = { release() },+ onDragCancel = { release() }) { change, _ ->+ // A finger that wanders before the bloom is a drag/scroll, not a hold.+ if (longPressJob?.isActive == true && expandAnimation.targetValue == 0f &&+ (change.position - startPosition).getDistance() > slop+ ) {+ longPressJob?.cancel()+ }// Pointer events can arrive faster than a frame. Keep only the// newest position instead of queuing one coroutine per sample.positionUpdateJob?.cancel()diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/utils/LiquidPressGlow.kt b/app/src/main/java/com/chethan616/clearpdf/ui/utils/LiquidPressGlow.ktnew file mode 100644index 0000000..ff28f25--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/utils/LiquidPressGlow.kt@@ -0,0 +1,76 @@+package com.chethan616.clearpdf.ui.utils++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.spring+import androidx.compose.animation.core.tween+import androidx.compose.foundation.interaction.InteractionSource+import androidx.compose.foundation.interaction.PressInteraction+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.drawWithContent+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.geometry.isSpecified+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Brush+import androidx.compose.ui.graphics.Color+import kotlinx.coroutines.flow.collectLatest++/**+ * The glass chips' press light — a soft wash plus a radial glow blooming from the touch point — for+ * surfaces that are not [com.chethan616.clearpdf.ui.components.LiquidButton]s, such as list rows.+ *+ * Driven by [interactionSource]'s press interactions rather than raw pointer input, so it inherits+ * the clickable's scroll tap-delay: starting a scroll on a row never flashes it. A quick tap still+ * gets a visible pulse (it rises to half strength before fading), like an iOS cell highlight.+ *+ * Draws under the content. Over a light surface the glow is a gentle darkening (a white Plus glow is+ * invisible on white); over a dark one it is light, as on the chips.+ */+@Composable+fun Modifier.liquidPressGlow(interactionSource: InteractionSource, onLight: Boolean): Modifier {+ val progress = remember { Animatable(0f, 0.001f) }+ // Not state: read in draw only, alongside `progress`, which already invalidates the draw.+ val origin = remember { arrayOf(Offset.Unspecified) }+ LaunchedEffect(interactionSource) {+ interactionSource.interactions.collectLatest { interaction ->+ when (interaction) {+ is PressInteraction.Press -> {+ origin[0] = interaction.pressPosition+ progress.animateTo(1f, spring(dampingRatio = 0.7f, stiffness = 420f))+ }+ is PressInteraction.Release, is PressInteraction.Cancel -> {+ if (interaction is PressInteraction.Release && progress.value < 0.5f) {+ progress.animateTo(0.5f, tween(70))+ }+ progress.animateTo(0f, spring(dampingRatio = 1f, stiffness = 260f))+ }+ }+ }+ }+ return drawWithContent {+ val p = progress.value+ if (p > 0f) {+ val c = origin[0].takeIf { it.isSpecified } ?: center+ val radius = size.minDimension * 1.6f+ if (onLight) {+ drawRect(Color.Black.copy(alpha = 0.035f * p))+ drawCircle(+ Brush.radialGradient(listOf(Color.Black.copy(alpha = 0.06f * p), Color.Transparent), c, radius),+ radius = radius,+ center = c+ )+ } else {+ drawRect(Color.White.copy(alpha = 0.06f * p), blendMode = BlendMode.Plus)+ drawCircle(+ Brush.radialGradient(listOf(Color.White.copy(alpha = 0.16f * p), Color.Transparent), c, radius),+ radius = radius,+ center = c,+ blendMode = BlendMode.Plus+ )+ }+ }+ drawContent()+ }+}