Skip to content

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

fix: recents pill above row, share icon order, decoupled editor-tools expand

Chethan6163684abddac81
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.kt
index 0540c16..0b6522d 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,7 +125,8 @@ fun HomeScreen(
var selectedRecent by remember { mutableStateOf<com.chethan616.clearpdf.data.repository.RecentFile?>(null) }
// Root-space vertical center of the long-pressed row, so the popup can rise
// from the item instead of floating dead-center.
- var selectedRecentAnchorY by remember { mutableStateOf(0f) }
+ var selectedRecentAnchorY by remember { mutableStateOf(0f) } // root-space TOP of the pressed row
+ var selectedRecentRowHeight by remember { mutableStateOf(0f) }
var recentPopupHeightPx by remember { mutableStateOf(0) }
var infoRecent by remember { mutableStateOf<com.chethan616.clearpdf.data.repository.RecentFile?>(null) }
val lifecycleOwner = LocalLifecycleOwner.current
@@ -384,16 +385,20 @@ fun HomeScreen(
} else {
val visibleRecents = if (showAllRecents) recents else recents.take(homeRecentLimit)
visibleRecents.forEach { recent ->
- var rowCenterY by remember { mutableStateOf(0f) }
+ var rowTopY by remember { mutableStateOf(0f) }
+ var rowHeightPx by remember { mutableStateOf(0f) }
Row(
Modifier
.fillMaxWidth()
- .onGloballyPositioned { rowCenterY = it.localToRoot(androidx.compose.ui.geometry.Offset.Zero).y + it.size.height / 2f }
+ .onGloballyPositioned {
+ rowTopY = it.localToRoot(androidx.compose.ui.geometry.Offset.Zero).y
+ rowHeightPx = it.size.height.toFloat()
+ }
.clip(RoundedCornerShape(16.dp))
.background(if (isLight) Color.White.copy(0.18f) else Color.White.copy(0.06f))
.combinedClickable(
onClick = { onRecentFileSelected(recent.uri) },
- onLongClick = { selectedRecent = recent; selectedRecentAnchorY = rowCenterY }
+ onLongClick = { selectedRecent = recent; selectedRecentAnchorY = rowTopY; selectedRecentRowHeight = rowHeightPx }
)
.padding(horizontal = 12.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -466,8 +471,14 @@ fun HomeScreen(
val maxH = constraints.maxHeight
val padPx = 16f * density
selectedRecent?.let { recent ->
- val targetY = (selectedRecentAnchorY - recentPopupHeightPx / 2f)
- .coerceIn(padPx * 5f, (maxH - recentPopupHeightPx - padPx * 5f).coerceAtLeast(padPx))
+ // Float the pill ABOVE the pressed row (WhatsApp-style); flip below only if
+ // there isn't enough room above.
+ val gap = 10f * density
+ val minY = padPx * 3f
+ val maxY = (maxH - recentPopupHeightPx - padPx * 3f).coerceAtLeast(minY)
+ val aboveY = selectedRecentAnchorY - recentPopupHeightPx - gap
+ val belowY = selectedRecentAnchorY + selectedRecentRowHeight + gap
+ val targetY = (if (aboveY >= minY) aboveY else belowY).coerceIn(minY, maxY)
// WhatsApp-style reaction pill: a compact floating capsule of round glass
// action buttons that pops up from the long-pressed row.
Row(
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
index 0554a63..b5809d5 100644
--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt
@@ -17,6 +17,8 @@ import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
+import androidx.compose.animation.expandVertically
+import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background
@@ -154,10 +156,10 @@ internal fun PdfViewerBottomToolbar(
// Only this panel moves, so re-blur is confined to one surface.
AnimatedVisibility(
visible = editorOpen && (showDrawTools || showOcrTools || showImageTools) && !showFindBar && !showSignaturePad,
- enter = fadeIn(tween(220)) +
- slideInVertically(spring(dampingRatio = 0.9f, stiffness = Spring.StiffnessMediumLow)) { it },
- exit = fadeOut(tween(150)) +
- slideOutVertically(spring(dampingRatio = 1f, stiffness = Spring.StiffnessMedium)) { it }
+ // Grow UPWARD from the pinned "Editor Tools" bar (expandVertically from Bottom) so the
+ // bar itself never moves — the panel unfolds above it. No slide = no coupled shift.
+ enter = fadeIn(tween(200)) + expandVertically(tween(240), expandFrom = Alignment.Bottom),
+ exit = fadeOut(tween(140)) + shrinkVertically(tween(160), shrinkTowards = Alignment.Bottom)
) {
Column(
Modifier.fillMaxWidth().liquidGlassPanel(backdrop, uiSensor, glass).padding(12.dp),
@@ -362,8 +364,8 @@ internal fun PdfViewerBottomToolbar(
// screen isn't stacked with panels — the sub-toolbar's ✕ returns here.
AnimatedVisibility(
visible = editorOpen && !showDrawTools && !showOcrTools && !showFindBar && !showSignaturePad && activeImageId == null,
- enter = fadeIn(tween(200)) +
- slideInVertically(spring(dampingRatio = 0.9f, stiffness = Spring.StiffnessMediumLow)) { it },
+ // Unfold UPWARD from the pinned bar (no slide) so the "Editor Tools" pill stays put.
+ enter = fadeIn(tween(200)) + expandVertically(tween(240), expandFrom = Alignment.Bottom),
// Instant exit → releases its layout space immediately so the sub-toolbar
// below never gets pushed up and then dropped ("stays top, then comes down").
exit = ExitTransition.None
@@ -580,11 +582,12 @@ private fun ShareMorphButton(
if (sharing) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(6.dp)
+ verticalArrangement = Arrangement.spacedBy(5.dp)
) {
- // The chevron brightens as you drag toward the release threshold.
- Icon(Icons.Rounded.KeyboardArrowUp, null, Modifier.size(18.dp), Color.White.copy(alpha = 0.5f + 0.5f * progress))
+ // Share icon on top (always visible); the up-arrow sits below and brightens
+ // as you drag toward the release threshold — a "swipe up to share" hint.
Icon(Icons.Rounded.IosShare, stringResource(R.string.viewer_share_document), Modifier.size(20.dp), Color.White)
+ Icon(Icons.Rounded.KeyboardArrowUp, null, Modifier.size(18.dp), Color.White.copy(alpha = 0.5f + 0.5f * progress))
}
} else {
Icon(Icons.Rounded.UploadFile, stringResource(R.string.viewer_open_another), Modifier.size(20.dp), fg)