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 viewer glass controls and night mode

chethan616eb47c2caedd5
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
index 7b49286..b35550f 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/AppViewModel.kt
@@ -838,7 +838,9 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
get() = if (appPrefs.getString("pageMode", "continuous") == "single") com.chethan616.clearpdf.ui.viewer.PageMode.SinglePage
else com.chethan616.clearpdf.ui.viewer.PageMode.Continuous
- val savedNightMode: Boolean get() = appPrefs.getBoolean("nightMode", false)
+ /** One reactive source for Settings and the reader's View settings. */
+ private var nightModeDefaultState by mutableStateOf(appPrefs.getBoolean("nightMode", false))
+ val savedNightMode: Boolean get() = nightModeDefaultState
fun setPageMode(doc: OpenDocument, mode: com.chethan616.clearpdf.ui.viewer.PageMode) {
// leaving Reading Mode: a canvas laid out already followed the page read; else it shows it on layout
@@ -855,6 +857,7 @@ class AppViewModel(app: Application, private val saved: SavedStateHandle) : Andr
/** PDFs and documents use this choice as soon as they open, and the current reader follows it. */
fun setNightModeDefault(on: Boolean) {
+ nightModeDefaultState = on
appPrefs.edit().putBoolean("nightMode", on).apply()
prefsChanged++
document?.controller?.nightMode = on
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
index 0d73f73..7a1dd15 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/Components.kt
@@ -205,6 +205,9 @@ fun PdfSheet(
val visible = LocalSheetVisible.current ?: own
GlassOverlay(animatesOut = true) {
val c = clear
+ // Viewer sheets are glass over the actual document. Keep their wash neutral, so a PDF or
+ // image supplies the reflected colour instead of the dark theme's old indigo frost.
+ val sheetWash = background?.copy(alpha = 0.9f) ?: if (c.dark) Color(0xFF0D0D10).copy(alpha = 0.64f) else Color.White.copy(alpha = 0.76f)
val presence = com.chethan616.clearpdf.ui.glass.LocalOverlayPresence.current
val leaving = presence?.leaving == true
// shown on its own (not through a SheetHost), it slides away once whoever showed it is gone
@@ -247,7 +250,7 @@ fun PdfSheet(
.onSizeChanged { height = it.height }
.pointerInput(Unit) { detectTapGestures() },
shape = RoundedRectangle(34.dp),
- wash = background?.copy(alpha = 0.9f) ?: c.frost,
+ wash = sheetWash,
blur = 18.dp,
) {
val haptics = com.chethan616.clearpdf.ui.glass.LocalHaptics.current
@@ -342,6 +345,7 @@ fun SheetRow(
checked: Boolean = false,
enabled: Boolean = true,
tint: Color? = null,
+ trailingInteractive: Boolean = false,
trailing: (@Composable RowScope.() -> Unit)? = null,
) {
val c = clear
@@ -353,23 +357,31 @@ fun SheetRow(
else -> Candy.Sky
}
Row(
- modifier.fillMaxWidth().heightIn(min = 50.dp).pressable(onClick, enabled = enabled, pressedScale = 0.985f).padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 6.dp),
+ modifier.fillMaxWidth().heightIn(min = 50.dp)
+ .then(if (trailingInteractive) Modifier else Modifier.pressable(onClick, enabled = enabled, pressedScale = 0.985f))
+ .padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- if (icon != null) {
- Box(
- Modifier.size(30.dp).clip(RoundedRectangle(9.dp))
- .background(androidx.compose.ui.graphics.Brush.verticalGradient(listOf(accent.copy(alpha = 0.86f), accent)))
- .graphicsLayer { alpha = if (enabled) 1f else 0.4f },
- contentAlignment = Alignment.Center,
- ) { Icon(icon, null, tint = Color.White, modifier = Modifier.size(17.dp)) }
- Spacer(Modifier.width(14.dp))
- }
val ink = if (danger) Candy.Tomato else c.ink
- Text(
- label, style = ClearType.Body.copy(fontSize = 16.sp), color = if (enabled) ink else ink.copy(alpha = 0.38f),
- maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f).padding(vertical = 7.dp),
- )
+ Row(
+ Modifier.weight(1f).fillMaxWidth()
+ .then(if (trailingInteractive) Modifier.pressable(onClick, enabled = enabled, pressedScale = 0.985f) else Modifier),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ if (icon != null) {
+ Box(
+ Modifier.size(30.dp).clip(RoundedRectangle(9.dp))
+ .background(androidx.compose.ui.graphics.Brush.verticalGradient(listOf(accent.copy(alpha = 0.86f), accent)))
+ .graphicsLayer { alpha = if (enabled) 1f else 0.4f },
+ contentAlignment = Alignment.Center,
+ ) { Icon(icon, null, tint = Color.White, modifier = Modifier.size(17.dp)) }
+ Spacer(Modifier.width(14.dp))
+ }
+ Text(
+ label, style = ClearType.Body.copy(fontSize = 16.sp), color = if (enabled) ink else ink.copy(alpha = 0.38f),
+ maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f).padding(vertical = 7.dp),
+ )
+ }
if (trailing != null) trailing()
if (checked) Icon(LucideIcons.Check, null, tint = Candy.Sky, modifier = Modifier.size(21.dp))
if (chevron) Icon(LucideIcons.ChevronRight, null, tint = c.inkFaint, modifier = Modifier.size(19.dp))
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
index d97c4ed..7fc0ab6 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/Overlays.kt
@@ -321,6 +321,12 @@ data class GlassMenuItem(val label: String, val icon: ImageVector? = null, val d
/** How long a chosen menu item waits for the menu to fold away (its dismiss tween, about 260 ms). */
private const val MenuGoneMillis = 220L
+// Menus are their own glass material. A neutral wash lets a PDF, picture, or wallpaper supply the
+// reflected colour instead of imposing the app theme's blue frost over every context.
+private val MenuLightWash = Color.White.copy(alpha = 0.72f)
+private val MenuDarkWash = Color(0xFF0D0D10).copy(alpha = 0.58f)
+private val MenuGlassStyle = GlassStyle.MaximumFrost.copy(saturation = 1f)
+
@Composable
fun GlassMenu(anchor: Rect, onDismiss: () -> Unit, items: List<GlassMenuItem>) {
var closing by remember { mutableStateOf(false) }
@@ -399,9 +405,9 @@ private fun GlassMenuLayoutContent(
},
shape = RoundedRectangle(24.dp),
// Keep menus fully frosted even when the global glass setting is Lite or Crystal.
- wash = c.frost,
+ wash = if (c.dark) MenuDarkWash else MenuLightWash,
blur = 16.dp,
- styleOverride = GlassStyle.MaximumFrost,
+ styleOverride = MenuGlassStyle,
) {
CompositionLocalProvider(LocalGlassInk provides c.ink) {
Column(Modifier.heightIn(max = maxHeight).verticalScroll(rememberScrollState()), content = content)
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
index bec7329..894a469 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/notes/PhotoEditor.kt
@@ -4,14 +4,9 @@ import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
-import androidx.compose.animation.slideInVertically
-import androidx.compose.animation.slideOutVertically
-import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
-import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
-import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -25,11 +20,14 @@ import androidx.compose.foundation.layout.height
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.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.windowInsetsTopHeight
-import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.lazy.LazyRow
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material3.Slider
+import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -37,7 +35,6 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateMapOf
-import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@@ -46,10 +43,8 @@ import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
-import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
-import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
@@ -66,17 +61,17 @@ import com.chethan616.clearpdf.engine.toBitmap
import com.chethan616.clearpdf.ui.AppViewModel
import com.chethan616.clearpdf.ui.LucideIcons
import com.chethan616.clearpdf.ui.glass.ChromeCapsule
-import com.chethan616.clearpdf.ui.glass.Feel
import com.chethan616.clearpdf.ui.glass.Fluid
import com.chethan616.clearpdf.ui.glass.GlassCircle
import com.chethan616.clearpdf.ui.glass.GlassIcon
import com.chethan616.clearpdf.ui.glass.GlassPill
import com.chethan616.clearpdf.ui.glass.LocalBackdrop
-import com.chethan616.clearpdf.ui.glass.LocalHaptics
+import com.chethan616.clearpdf.ui.glass.LocalGlassInk
import com.chethan616.clearpdf.ui.glass.RoundedRectangle
-import com.chethan616.clearpdf.ui.glass.glass
import com.chethan616.clearpdf.ui.glass.glassBar
+import com.chethan616.clearpdf.ui.glass.pressable
import com.chethan616.clearpdf.ui.glass.rememberBeat
+import com.chethan616.clearpdf.ui.glass.rememberGlassInk
import com.chethan616.clearpdf.ui.theme.Candy
import com.chethan616.clearpdf.ui.theme.ClearType
import com.kyant.backdrop.backdrops.layerBackdrop
@@ -90,9 +85,8 @@ import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.io.File
import kotlin.math.abs
-import kotlin.math.roundToInt
-/** One adjustment of LightCraft's develop settings: where it lives, its name, glyph and range. */
+/** One adjustment LightCraft can develop. */
private enum class Adjust(
val section: String,
val field: String,
@@ -110,72 +104,64 @@ private enum class Adjust(
Saturation("color", "saturation", R.string.photo_saturation, LucideIcons.Droplet, -100f, 100f, 0),
}
-/** The quarter turns LightCraft's orientation names, clockwise from as shot. */
private val TURNS = listOf("Normal", "Rotate90", "Rotate180", "Rotate270")
-/** "+0.40", "−12", "0": signed, as Photos shows an adjustment. */
-private fun shown(a: Adjust, v: Float): String {
+private fun shown(a: Adjust, value: Float): String {
val zero = if (a.decimals > 0) 0.005f else 0.5f
- if (abs(v) < zero) return "0"
- val n = if (a.decimals > 0) "%.${a.decimals}f".format(abs(v)) else abs(v).toInt().toString()
- return (if (v > 0) "+" else "−") + n
+ if (abs(value) < zero) return "0"
+ val number = if (a.decimals > 0) "%1$.${a.decimals}f".format(abs(value)) else abs(value).toInt().toString()
+ return (if (value > 0f) "+" else "−") + number
}
/**
- * A photo editor built completely on Artefact's liquid-glass design system:
- * - Edge-to-edge photo canvas with touch-and-hold to view original
- * - Floating liquid-glass header with beat-delayed Cancel (X) and Save (Tick)
- * - Pure liquid glass controls with NO canvas circle marks
- * - Zero-snap precision ruler with haptic feedback
- * - Deep integration with GlassSettings & MotionSettings
- * - Proper BackHandler ensuring swipe-back never closes the app
+ * A direct-touch editor: the picture remains the focus, while two compact glass cylinders own the
+ * adjustment value and adjustment selection. The slider is immediate; rendering happens behind it.
*/
@OptIn(kotlinx.coroutines.FlowPreview::class)
@Composable
fun PhotoEditScreen(vm: AppViewModel, noteId: String, name: String, onClose: () -> Unit) {
- val source = remember(name) { vm.notes.file(name) }
- val editor = remember { PhotoEditor() }
+ val source = remember(noteId, name) { vm.notes.file(name) }
+ val editor = remember(name) { PhotoEditor() }
DisposableEffect(editor) { onDispose { editor.release(); editor.close() } }
- val values = remember { mutableStateMapOf<Adjust, Float>() }
- var turn by remember { mutableStateOf(0) }
- var chosen by remember { mutableStateOf(Adjust.Exposure) }
- var shown by remember { mutableStateOf<ImageBitmap?>(null) }
- var original by remember { mutableStateOf<ImageBitmap?>(null) }
+
+ val values = remember(name) { mutableStateMapOf<Adjust, Float>() }
+ var turn by remember(name) { mutableStateOf(0) }
+ var selected by remember(name) { mutableStateOf(Adjust.Exposure) }
+ var preview by remember(name) { mutableStateOf<ImageBitmap?>(null) }
+ var original by remember(name) { mutableStateOf<ImageBitmap?>(null) }
var comparing by remember { mutableStateOf(false) }
var saving by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
- val edited = values.values.any { it != 0f } || turn != 0
-
- fun settings(withValues: Boolean = true): String {
- val o = JSONObject()
- if (withValues) for ((a, v) in values) if (v != 0f) {
- (o.optJSONObject(a.section) ?: JSONObject().also { o.put(a.section, it) }).put(a.field, v.toDouble())
+ val changed = values.values.any { it != 0f } || turn != 0
+
+ fun settings(includeAdjustments: Boolean = true): String {
+ val root = JSONObject()
+ if (includeAdjustments) values.forEach { (adjustment, value) ->
+ if (value != 0f) {
+ val section = root.optJSONObject(adjustment.section) ?: JSONObject().also { root.put(adjustment.section, it) }
+ section.put(adjustment.field, value.toDouble())
+ }
}
- if (turn != 0) o.put("orientation", TURNS[turn])
- return o.toString()
+ if (turn != 0) root.put("orientation", TURNS[turn])
+ return root.toString()
}
- // Beat delay for Cancel (X): plays the liquid glass spring press before dismissing
- val beatClose = rememberBeat(onClose)
-
- // Beat delay for Done (Tick): plays the spring press, exports the image, and closes cleanly
- val beatDone = rememberBeat({
+ val close = rememberBeat(onClose)
+ val done = rememberBeat(action = {
if (saving) return@rememberBeat
- if (!edited) {
+ if (!changed) {
onClose()
return@rememberBeat
}
saving = true
scope.launch {
- val out = File(source.parentFile, "edited-${System.currentTimeMillis()}.jpg")
- val ok = withContext(Dispatchers.Default) {
- runCatching {
- editor.exportJpeg(source.absolutePath, settings(), out.absolutePath, 92u)
- }.isSuccess
+ val output = File(source.parentFile, "edited-${System.currentTimeMillis()}.jpg")
+ val saved = withContext(Dispatchers.Default) {
+ runCatching { editor.exportJpeg(source.absolutePath, settings(), output.absolutePath, 92u) }.isSuccess
}
- if (ok) {
- vm.notes.get(noteId)?.let { n ->
- vm.notes.put(n.copy(images = n.images.map { if (it == name) out.name else it }))
+ if (saved) {
+ vm.notes.get(noteId)?.let { note ->
+ vm.notes.put(note.copy(images = note.images.map { if (it == name) output.name else it }))
}
} else {
vm.tell(com.chethan616.clearpdf.text(R.string.photo_not_saved))
@@ -185,58 +171,32 @@ fun PhotoEditScreen(vm: AppViewModel, noteId: String, name: String, onClose: ()
}
})
- // Intercept back gesture / button: closes photo editor safely instead of closing the app!
- BackHandler(enabled = true) {
- beatClose()
- }
+ BackHandler(enabled = true) { close() }
- // Re-develop as the ruler moves; a newer value cancels the render still running
- LaunchedEffect(Unit) {
- // Rendering a 1600 px photo for every pointer event starved the ruler of frames. Coalesce
- // values for two display frames; the ruler remains immediate while the preview catches up
- // fluidly and always renders the final value.
+ // A smaller working render prevents native image development from competing with slider input.
+ LaunchedEffect(source) {
snapshotFlow { settings() }
.distinctUntilChanged()
- .debounce(48)
+ .debounce(80)
.collectLatest { json ->
- shown = withContext(Dispatchers.Default) {
- runCatching {
- editor.render(source.absolutePath, json, 1600u).toBitmap().asImageBitmap()
- }.getOrNull()
- } ?: shown
- }
+ preview = withContext(Dispatchers.Default) {
+ runCatching { editor.render(source.absolutePath, json, 1280u).toBitmap().asImageBitmap() }.getOrNull()
+ } ?: preview
+ }
}
-
- // The picture as shot (turned as the edit is), for holding to compare
- LaunchedEffect(turn) {
- val json = settings(withValues = false)
+ LaunchedEffect(source, turn) {
original = withContext(Dispatchers.Default) {
- runCatching {
- editor.render(source.absolutePath, json, 1600u).toBitmap().asImageBitmap()
- }.getOrNull()
+ runCatching { editor.render(source.absolutePath, settings(includeAdjustments = false), 1280u).toBitmap().asImageBitmap() }.getOrNull()
}
}
val backdrop = rememberLayerBackdrop()
-
- Box(
- Modifier
- .fillMaxSize()
- .background(Color(0xFF090A0F)),
- ) {
- // ── Photo Canvas Layer ───────────────────────────────────────────────
- Column(
- Modifier
- .fillMaxSize()
- .layerBackdrop(backdrop),
- ) {
- Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars))
- Spacer(Modifier.height(64.dp))
+ Box(Modifier.fillMaxSize().background(Color(0xFF090A0F))) {
+ Box(Modifier.fillMaxSize().layerBackdrop(backdrop)) {
Box(
Modifier
- .weight(1f)
- .fillMaxWidth()
- .padding(horizontal = 16.dp, vertical = 8.dp)
+ .fillMaxSize()
+ .padding(top = 76.dp, bottom = 176.dp, start = 12.dp, end = 12.dp)
.pointerInput(Unit) {
detectTapGestures(onPress = {
comparing = true
@@ -246,330 +206,168 @@ fun PhotoEditScreen(vm: AppViewModel, noteId: String, name: String, onClose: ()
},
contentAlignment = Alignment.Center,
) {
- (if (comparing) original ?: shown else shown)?.let {
+ (if (comparing) original ?: preview else preview)?.let { image ->
Image(
- it,
- null,
- Modifier
- .clip(RoundedRectangle(20.dp))
- .fillMaxSize(),
+ bitmap = image,
+ contentDescription = null,
+ modifier = Modifier.fillMaxSize().clip(RoundedRectangle(24.dp)),
contentScale = ContentScale.Fit,
)
}
-
- // "ORIGINAL" indicator when user holds down on the photo
- androidx.compose.animation.AnimatedVisibility(
+ AnimatedVisibility(
visible = comparing,
enter = fadeIn(Fluid.fade()),
exit = fadeOut(Fluid.fade()),
modifier = Modifier.align(Alignment.TopCenter),
) {
Box(
- Modifier
- .padding(top = 12.dp)
- .background(Color.Black.copy(alpha = 0.55f), ChromeCapsule)
- .padding(horizontal = 14.dp, vertical = 6.dp),
+ Modifier.padding(top = 12.dp).background(Color.Black.copy(alpha = 0.58f), ChromeCapsule).padding(horizontal = 14.dp, vertical = 7.dp),
) {
- Text(
- stringResource(R.string.photo_original).uppercase(),
- style = ClearType.Label.copy(
- fontSize = 11.sp,
- letterSpacing = 1.4.sp,
- fontWeight = FontWeight.SemiBold,
- ),
- color = Color.White,
- )
+ Text(stringResource(R.string.photo_original), style = ClearType.Label, color = Color.White)
}
}
}
- // Room for the bottom liquid glass deck
- Spacer(Modifier.height(240.dp))
- Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
}
- // ── Liquid Glass Chrome Layer ─────────────────────────────────────────
CompositionLocalProvider(LocalBackdrop provides backdrop) {
- // ── Top Navigation Bar ────────────────────────────────────────────
- Column(
- Modifier
- .fillMaxWidth()
- .align(Alignment.TopCenter),
- ) {
- Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars))
- Row(
- Modifier
- .fillMaxWidth()
- .padding(horizontal = 16.dp, vertical = 8.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- // Close / Cancel (X) button with beat delay
- GlassCircle(
- onClick = beatClose,
- label = stringResource(R.string.common_cancel),
- size = 42.dp,
- surface = Color.White.copy(alpha = 0.12f),
- ink = Color.White,
- ) {
- GlassIcon(LucideIcons.X, null, Modifier.size(18.dp))
- }
-
- Spacer(Modifier.weight(1f))
-
- // Reset button — animates in only when edits exist
- AnimatedVisibility(
- visible = edited,
- enter = fadeIn(Fluid.quick()) + slideInVertically(Fluid.quick()) { -it / 2 },
- exit = fadeOut(Fluid.quick()) + slideOutVertically(Fluid.quick()) { -it / 2 },
- ) {
- GlassPill(
- onClick = {
- values.clear()
- turn = 0
- },
- height = 42.dp,
- horizontalPadding = 16.dp,
- surface = Color.White.copy(alpha = 0.12f),
- tap = Feel.Tap,
- ) {
- Text(
- stringResource(R.string.photo_reset),
- style = ClearType.Label.copy(fontSize = 13.sp, fontWeight = FontWeight.SemiBold),
- color = Candy.Lemon,
- )
- }
- }
-
- if (edited) Spacer(Modifier.width(10.dp))
-
- // Rotate CW
- GlassCircle(
- onClick = { turn = (turn + 1) % 4 },
- label = stringResource(R.string.photo_rotate),
- size = 42.dp,
- surface = Color.White.copy(alpha = 0.12f),
- ink = Color.White,
- ) {
- GlassIcon(LucideIcons.RotateCw, null, Modifier.size(18.dp))
- }
-
- Spacer(Modifier.width(10.dp))
-
- // Done / Save (Tick) button with beat delay
- GlassCircle(
- onClick = beatDone,
- label = stringResource(R.string.common_done),
- size = 42.dp,
- tint = if (edited) Candy.Sky else Color.Unspecified,
- surface = if (edited) Candy.Sky.copy(alpha = 0.32f) else Color.White.copy(alpha = 0.12f),
- ink = if (edited) Color.White else Color.White.copy(alpha = 0.7f),
- ) {
- GlassIcon(LucideIcons.Check, null, Modifier.size(20.dp))
- }
+ Box(Modifier.fillMaxSize()) {
+ PhotoHeader(
+ changed = changed,
+ onClose = close,
+ onDone = done,
+ onReset = { values.clear(); turn = 0 },
+ onRotate = { turn = (turn + 1) % 4 },
+ )
+ Box(Modifier.align(Alignment.BottomCenter)) {
+ PhotoControls(
+ selected = selected,
+ value = values[selected] ?: 0f,
+ onSelect = { selected = it },
+ onValueChange = { next ->
+ val caught = if (abs(next) < (selected.max - selected.min) * 0.012f) 0f else next
+ values[selected] = caught
+ },
+ )
}
}
+ }
+ }
+}
- // ── Bottom Liquid Glass Control Center ────────────────────────────
- Column(
- Modifier
- .fillMaxWidth()
- .align(Alignment.BottomCenter)
- .padding(horizontal = 14.dp, vertical = 8.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- ) {
- val v = values[chosen] ?: 0f
-
- // Floating glass control deck enclosing readout, ruler, and dials
- Box(
- Modifier
- .fillMaxWidth()
- .glass(
- shape = RoundedRectangle(28.dp),
- wash = Color(0x33101524),
- blur = 18.dp,
- lensHeight = 14.dp,
- lensAmount = 22.dp,
- )
- .padding(top = 16.dp, bottom = 14.dp),
- ) {
- Column(
- Modifier.fillMaxWidth(),
- horizontalAlignment = Alignment.CenterHorizontally,
- ) {
- // Title + Value display
- Text(
- stringResource(chosen.label).uppercase(),
- style = ClearType.Label.copy(fontSize = 11.sp, letterSpacing = 1.8.sp),
- color = Color.White.copy(alpha = 0.5f),
- )
- Spacer(Modifier.height(2.dp))
- Text(
- shown(chosen, v),
- style = ClearType.Title.copy(fontSize = 24.sp, fontWeight = FontWeight.Bold),
- color = if (v != 0f) Candy.Lemon else Color.White,
- )
-
- Spacer(Modifier.height(10.dp))
-
- // Precision Ruler
- Ruler(chosen, v) { values[chosen] = it }
-
- Spacer(Modifier.height(16.dp))
-
- // Liquid Glass Dials Row (no circle marks!)
- Row(
- Modifier
- .fillMaxWidth()
- .horizontalScroll(rememberScrollState())
- .padding(horizontal = 12.dp),
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- ) {
- for (a in Adjust.entries) {
- Dial(
- a = a,
- value = values[a] ?: 0f,
- chosen = a == chosen,
- onClick = { chosen = a },
- )
- }
- }
- }
+@Composable
+private fun PhotoHeader(
+ changed: Boolean,
+ onClose: () -> Unit,
+ onDone: () -> Unit,
+ onReset: () -> Unit,
+ onRotate: () -> Unit,
+) {
+ val ink = rememberGlassInk(Color.White)
+ Column(Modifier.fillMaxWidth()) {
+ Spacer(Modifier.windowInsetsTopHeight(WindowInsets.statusBars))
+ Row(
+ Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ ) {
+ GlassCircle(onClick = onClose, size = 42.dp, ink = Color.White, label = stringResource(R.string.common_cancel)) {
+ GlassIcon(LucideIcons.X, null, Modifier.size(19.dp))
+ }
+ Row(Modifier.weight(1f).height(42.dp).then(ink.modifier).glassBar().padding(horizontal = 15.dp), verticalAlignment = Alignment.CenterVertically) {
+ Text(stringResource(R.string.photo_edit), style = ClearType.Title.copy(fontSize = 15.sp), color = ink.color)
+ }
+ AnimatedVisibility(visible = changed, enter = fadeIn(Fluid.quick()), exit = fadeOut(Fluid.quick())) {
+ GlassPill(onClick = onReset, height = 42.dp, horizontalPadding = 13.dp, label = stringResource(R.string.photo_reset)) {
+ Text(stringResource(R.string.photo_reset), style = ClearType.Label, color = Candy.Lemon)
}
-
- Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
+ }
+ GlassCircle(onClick = onRotate, size = 42.dp, ink = Color.White, label = stringResource(R.string.photo_rotate)) {
+ GlassIcon(LucideIcons.RotateCw, null, Modifier.size(19.dp))
+ }
+ GlassCircle(
+ onClick = onDone,
+ size = 42.dp,
+ tint = if (changed) Candy.Sky else Color.Unspecified,
+ ink = Color.White,
+ label = stringResource(R.string.common_done),
+ ) {
+ GlassIcon(LucideIcons.Check, null, Modifier.size(20.dp))
}
}
}
}
-/**
- * An adjustment dial: pure liquid glass component with responsive fluid press,
- * squish and bloom. NO canvas circle marks or outer rings.
- */
@Composable
-private fun Dial(
- a: Adjust,
+private fun PhotoControls(
+ selected: Adjust,
value: Float,
- chosen: Boolean,
- onClick: () -> Unit,
+ onSelect: (Adjust) -> Unit,
+ onValueChange: (Float) -> Unit,
) {
- val nonZero = value != 0f
+ val ink = rememberGlassInk(Color.White)
Column(
+ Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
- modifier = Modifier.width(62.dp),
) {
- GlassCircle(
- onClick = onClick,
- size = 50.dp,
- label = stringResource(a.label),
- ink = if (chosen) Color(0xFF141202) else Color.White,
- tint = if (chosen) Candy.Lemon else Color.Unspecified,
- surface = if (chosen) Candy.Lemon else Color.White.copy(alpha = 0.10f),
+ Row(
+ Modifier.fillMaxWidth().height(72.dp).then(ink.modifier).glassBar().padding(horizontal = 16.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
- GlassIcon(
- a.icon,
- null,
- Modifier.size(22.dp),
- tint = if (chosen) Color(0xFF141202) else Color.White,
+ Column(Modifier.width(72.dp)) {
+ Text(stringResource(selected.label), style = ClearType.Label, color = ink.color.copy(alpha = 0.66f), maxLines = 1, overflow = TextOverflow.Ellipsis)
+ Text(shown(selected, value), style = ClearType.Title.copy(fontSize = 22.sp), color = if (value == 0f) ink.color else Candy.Lemon)
+ }
+ Slider(
+ value = value,
+ onValueChange = onValueChange,
+ valueRange = selected.min..selected.max,
+ modifier = Modifier.weight(1f),
+ colors = SliderDefaults.colors(
+ thumbColor = Candy.Sky,
+ activeTrackColor = Candy.Sky,
+ inactiveTrackColor = ink.color.copy(alpha = 0.22f),
+ ),
)
}
- Spacer(Modifier.height(6.dp))
- Text(
- if (nonZero) shown(a, value) else stringResource(a.label),
- style = ClearType.Label.copy(
- fontSize = 11.sp,
- fontWeight = if (chosen || nonZero) FontWeight.SemiBold else FontWeight.Normal,
- ),
- color = if (chosen || nonZero) Candy.Lemon else Color.White.copy(alpha = 0.6f),
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- textAlign = TextAlign.Center,
- )
+ Spacer(Modifier.height(8.dp))
+ LazyRow(
+ modifier = Modifier.fillMaxWidth().height(70.dp).then(ink.modifier).glassBar(),
+ contentPadding = PaddingValues(horizontal = 8.dp),
+ horizontalArrangement = Arrangement.spacedBy(2.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ items(Adjust.entries, key = { it.name }) { adjustment ->
+ CompositionLocalProvider(LocalGlassInk provides ink.color) {
+ AdjustmentTab(adjustment, adjustment == selected, onClick = { onSelect(adjustment) })
+ }
+ }
+ }
+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
}
}
-/**
- * The value's ruler: ticks across the range with edge-fade, zero catch with haptics,
- * and a center indicator in Lemon.
- */
@Composable
-private fun Ruler(a: Adjust, value: Float, onChange: (Float) -> Unit) {
- val haptics = LocalHaptics.current
- val range = a.max - a.min
- var drag by remember(a) { mutableStateOf(value) }
- var dragging by remember(a) { mutableStateOf(false) }
- // A meaningful tick per adjustment type: fractions for exposure, five-point steps for tone,
- // quarter turns for geometry. It feels deliberate without vibrating continuously.
- val tickSize = remember(a) {
- when {
- range <= 8f -> 0.1f
- range <= 12f -> 0.25f
- range <= 40f -> 1f
- else -> 5f
- }
- }
- fun tickAt(v: Float) = (v / tickSize).roundToInt()
- var lastTick by remember(a) { mutableIntStateOf(tickAt(value)) }
- LaunchedEffect(value) {
- if (!dragging) {
- drag = value
- lastTick = tickAt(value)
- }
- }
-
- Canvas(
- Modifier
- .fillMaxWidth()
- .height(44.dp)
- .pointerInput(a) {
- val perPx = range / (size.width * 3f)
- detectHorizontalDragGestures(
- onDragStart = {
- dragging = true
- lastTick = tickAt(drag)
- haptics?.play(Feel.Rise)
- },
- onDragEnd = { dragging = false },
- onDragCancel = { dragging = false },
- ) { change, dx ->
- change.consume()
- var next = (drag - dx * perPx).coerceIn(a.min, a.max)
- // Catch zero precisely; it is the natural resting point for every adjustment.
- if (abs(next) < range * 0.012f) next = 0f
- val nextTick = tickAt(next)
- if (nextTick != lastTick) {
- haptics?.play(Feel.Tick)
- lastTick = nextTick
- }
- drag = next
- onChange(next)
- }
- },
+private fun AdjustmentTab(adjustment: Adjust, selected: Boolean, onClick: () -> Unit) {
+ val ink = LocalGlassInk.current
+ Column(
+ Modifier.width(68.dp).height(62.dp).pressable(onClick, pressedScale = 0.9f).padding(vertical = 4.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(2.dp),
) {
- val w = size.width * 3f
- val mid = size.width / 2
- val t = (drag - a.min) / range
- val ticks = 60
-
- for (i in 0..ticks) {
- val x = mid + (i.toFloat() / ticks - t) * w
- if (x < -4 || x > size.width + 4) continue
- val major = i % 10 == 0
- val h = if (major) size.height * 0.55f else size.height * 0.32f
- val fade = (1f - abs(x - mid) / mid).coerceIn(0.12f, 1f)
- drawLine(
- Color.White.copy(alpha = (if (major) 0.8f else 0.4f) * fade),
- Offset(x, (size.height - h) / 2),
- Offset(x, (size.height + h) / 2),
- 1.5.dp.toPx(),
- StrokeCap.Round,
- )
- }
-
- // zero indicator mark & center needle
- val zx = mid + ((0f - a.min) / range - t) * w
- if (zx in 0f..size.width) {
- drawCircle(Candy.Lemon, 2.5.dp.toPx(), Offset(zx, size.height - 2.dp.toPx()))
+ Box(
+ Modifier.size(34.dp).clip(ChromeCapsule).background(if (selected) Candy.Sky else Color.Transparent),
+ contentAlignment = Alignment.Center,
+ ) {
+ GlassIcon(adjustment.icon, null, Modifier.size(19.dp), tint = if (selected) Color.White else ink)
}
- drawLine(Candy.Lemon, Offset(mid, 0f), Offset(mid, size.height), 2.dp.toPx(), StrokeCap.Round)
+ Text(
+ stringResource(adjustment.label),
+ style = ClearType.Label.copy(fontSize = 10.sp, fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Normal),
+ color = if (selected) ink else ink.copy(alpha = 0.62f),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ textAlign = TextAlign.Center,
+ )
}
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
index 7a21364..c613887 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Edit.kt
@@ -8,10 +8,12 @@ import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
@@ -29,6 +31,7 @@ import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
@@ -77,6 +80,10 @@ import com.chethan616.clearpdf.ui.AppViewModel
import com.chethan616.clearpdf.ui.LucideIcons
import com.chethan616.clearpdf.ui.OpenDocument
import com.chethan616.clearpdf.ui.pdfColors
+import com.chethan616.clearpdf.ui.glass.LocalGlassInk
+import com.chethan616.clearpdf.ui.glass.glassBar
+import com.chethan616.clearpdf.ui.glass.rememberGlassInk
+import com.chethan616.clearpdf.ui.theme.clear
import kotlin.math.roundToInt
/** A paragraph Edit PDF can change: its number on the page, text, box (points) and style. */
@@ -124,28 +131,22 @@ fun EditToolbar(vm: AppViewModel, doc: OpenDocument) {
@Composable
private fun EditToolsBar(vm: AppViewModel, doc: OpenDocument) {
- Row(
- // taller when a large font setting enlarges the labels, rather than cutting them off
- Modifier.fillMaxWidth().heightIn(min = BottomBarHeight).barTopLine().background(pdfColors.surface),
- horizontalArrangement = Arrangement.Center,
- verticalAlignment = Alignment.CenterVertically,
- ) {
+ SubToolbar {
val textHint = stringResource(R.string.edit_tap_for_text)
val imageHint = stringResource(R.string.edit_tap_for_image)
- EditBarItem(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_organize), false, 96.dp) {
+ SubTool(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_organize), vm.organizing, {
vm.organizing = true
doc.controller.pagesOpen = true
- }
- BarDividerLine()
- EditBarItem(LucideIcons.Type, stringResource(R.string.edit_add_text), vm.editMode == EditMode.AddText, 70.dp) {
+ })
+ SubTool(LucideIcons.Type, stringResource(R.string.edit_add_text), vm.editMode == EditMode.AddText, {
vm.editMode = if (vm.editMode == EditMode.AddText) EditMode.Select else EditMode.AddText
if (vm.editMode == EditMode.AddText) vm.tell(textHint)
- }
- // as Add text: a mode, then a tap places the picture there
- EditBarItem(LucideIcons.ImagePlus, stringResource(R.string.edit_add_image), vm.editMode == EditMode.AddImage, 78.dp) {
+ })
+ // As with Add text, Add image selects a placement mode; tapping the page places it.
+ SubTool(LucideIcons.ImagePlus, stringResource(R.string.edit_add_image), vm.editMode == EditMode.AddImage, {
vm.editMode = if (vm.editMode == EditMode.AddImage) EditMode.Select else EditMode.AddImage
if (vm.editMode == EditMode.AddImage) vm.tell(imageHint)
- }
+ })
}
}
@@ -157,14 +158,15 @@ private fun BarDividerLine() {
@Composable
private fun EditBarItem(icon: ImageVector, label: String, selected: Boolean, width: Dp, onClick: () -> Unit) {
val c = pdfColors
+ val ink = LocalGlassInk.current
Column(
Modifier.width(width).heightIn(min = BottomBarHeight).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = label },
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
- Icon(icon, null, tint = if (selected) c.toolAccent else c.icon, modifier = Modifier.size(24.dp))
+ Icon(icon, null, tint = if (selected) c.toolAccent else ink, modifier = Modifier.size(24.dp))
Spacer(Modifier.height(6.dp))
- Text(label, color = if (selected) c.toolAccent else c.label, fontSize = 13.sp, maxLines = 1, softWrap = false)
+ Text(label, color = if (selected) c.toolAccent else ink, fontSize = 13.sp, maxLines = 1, softWrap = false)
}
}
@@ -175,7 +177,7 @@ private fun EditFormatBar(vm: AppViewModel, doc: OpenDocument, para: Paragraph)
fun toggle(p: FormatPanel) {
panel = if (panel == p) FormatPanel.None else p
}
- Column(Modifier.fillMaxWidth().background(c.surface)) {
+ Column(Modifier.fillMaxWidth()) {
when (panel) {
FormatPanel.Size -> SizePanel(para) { vm.styleParagraph(doc, para, mapOf("size" to it.toDouble())) }
FormatPanel.Font -> FontPanel(vm.editFont[para.page to para.number]) { f ->
@@ -191,7 +193,7 @@ private fun EditFormatBar(vm: AppViewModel, doc: OpenDocument, para: Paragraph)
FormatPanel.None -> Unit
}
Row(
- Modifier.fillMaxWidth().height(BottomBarHeight).barTopLine(),
+ Modifier.fillMaxWidth().height(BottomBarHeight).padding(horizontal = 12.dp, vertical = 8.dp).glassBar().padding(horizontal = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
) {
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
index 66e0acd..26379cb 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/Forms.kt
@@ -58,6 +58,7 @@ import com.chethan616.clearpdf.ui.PdfSheet
import com.chethan616.clearpdf.ui.SheetRow
import com.chethan616.clearpdf.ui.SheetTitle
import com.chethan616.clearpdf.ui.pdfColors
+import com.chethan616.clearpdf.ui.glass.glassBar
import kotlin.math.roundToInt
/** A field being filled in: the widget tapped. */
@@ -142,7 +143,11 @@ fun BoxScope.FieldEditor(vm: AppViewModel, edit: FieldEdit) {
// words used in forms before, above the keyboard
val suggestions = if (w.password) emptyList() else vm.suggestionsFor(text)
if (suggestions.isNotEmpty()) {
- Row(Modifier.align(Alignment.BottomCenter).fillMaxWidth().imePadding().background(c.surface).height(44.dp), verticalAlignment = Alignment.CenterVertically) {
+ Row(
+ Modifier.align(Alignment.BottomCenter).fillMaxWidth().imePadding().padding(horizontal = 12.dp, vertical = 8.dp)
+ .height(44.dp).glassBar().padding(horizontal = 8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
for (sug in suggestions) {
Text(sug, color = c.text, maxLines = 1, modifier = Modifier.weight(1f).clickable { text = sug }.padding(horizontal = 12.dp, vertical = 10.dp))
}
@@ -170,9 +175,7 @@ class FieldActions(val reset: () -> Unit, val step: (Boolean) -> Unit, val canBa
fun FieldTopBar(actions: FieldActions) {
val c = pdfColors
Row(
- Modifier.fillMaxWidth().height(TopBarHeight).background(c.surface).drawBehind {
- drawRect(c.divider, androidx.compose.ui.geometry.Offset(0f, size.height - 1.dp.toPx()), androidx.compose.ui.geometry.Size(size.width, 1.dp.toPx()))
- },
+ Modifier.fillMaxWidth().height(TopBarHeight).padding(horizontal = 12.dp, vertical = 8.dp).glassBar().padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Text(stringResource(R.string.forms_reset), color = c.label, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold,
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
index 824f27c..d457fa1 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/PageCanvas.kt
@@ -16,6 +16,7 @@ import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.key
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@@ -272,12 +273,16 @@ fun PageCanvas(
}
},
) {
- Canvas(Modifier.fillMaxSize()) {
- // read the image version so arrivals redraw
- images.version
- drawRect(look.background)
- drawPages(state, images, generation, look, maxScale * 4f)
- overlay()
+ // A colour filter change must replace the canvas draw block as well as recompose the host.
+ // Otherwise a visible View settings switch can leave the already-recorded page unfiltered.
+ key(look) {
+ Canvas(Modifier.fillMaxSize()) {
+ // read the image version so arrivals redraw
+ images.version
+ drawRect(look.background)
+ drawPages(state, images, generation, look, maxScale * 4f)
+ overlay()
+ }
}
}
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
index 5d81103..865b4cd 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerBars.kt
@@ -80,7 +80,6 @@ import com.chethan616.clearpdf.ui.iconAccent
import com.chethan616.clearpdf.ui.theme.Candy
import com.chethan616.clearpdf.ui.theme.ClearType
import com.chethan616.clearpdf.ui.theme.clear
-import com.chethan616.clearpdf.ui.pdfColors
import com.chethan616.clearpdf.ui.glass.Capsule
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
@@ -121,10 +120,10 @@ fun ViewerTopBar(
onSearch: (() -> Unit)?,
onShare: () -> Unit,
onMore: (Rect) -> Unit,
+ contentAlpha: Float = 1f,
undoLabel: String? = null,
redoLabel: String? = null,
) {
- val c = pdfColors
Row(
Modifier.fillMaxWidth().height(TopBarHeight).padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -137,42 +136,50 @@ fun ViewerTopBar(
}
var titleAnchor by remember { mutableStateOf(Rect.Zero) }
GlassPill(
- onClick = { onTitle(titleAnchor) },
- modifier = Modifier.weight(1f).onGloballyPositioned { titleAnchor = it.boundsInWindow() },
+ onClick = { if (contentAlpha > 0.5f) onTitle(titleAnchor) },
+ modifier = Modifier.weight(1f).onGloballyPositioned { titleAnchor = it.boundsInWindow() }
+ .graphicsLayer { alpha = contentAlpha.coerceIn(0f, 1f) },
height = 48.dp,
horizontalPadding = 16.dp,
- surface = c.surfaceRaised.copy(alpha = if (c.dark) 0.90f else 0.84f),
) {
- CompositionLocalProvider(LocalGlassInk provides c.icon) {
+ val ink = LocalGlassInk.current
if (toolTitle != null) Box(Modifier.size(9.dp).clip(CircleShape).background(Candy.Sky))
Column(Modifier.weight(1f)) {
- Text(toolTitle ?: title, style = ClearType.Title.copy(fontSize = 15.5.sp, lineHeight = 19.sp), color = c.icon, maxLines = 1, overflow = TextOverflow.Ellipsis)
- if (subtitle != null && toolTitle == null) Text(subtitle, style = ClearType.Caption, color = c.icon.copy(alpha = 0.72f), maxLines = 1)
+ Text(toolTitle ?: title, style = ClearType.Title.copy(fontSize = 15.5.sp, lineHeight = 19.sp), color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ if (subtitle != null && toolTitle == null) Text(subtitle, style = ClearType.Caption, color = ink.copy(alpha = 0.72f), maxLines = 1)
}
if (onSearch != null && !toolActive) {
- BarGlyphButton(onSearch, stringResource(R.string.viewer_find_in_document), size = 36.dp) {
- Icon(LucideIcons.Search, null, tint = c.icon, modifier = Modifier.size(19.dp))
+ BarGlyphButton(onSearch, stringResource(R.string.viewer_find_in_document), size = 36.dp, enabled = contentAlpha > 0.5f) {
+ Icon(LucideIcons.Search, null, tint = ink, modifier = Modifier.size(19.dp))
}
}
- }
}
if (toolActive) {
if (canUndo || canRedo) {
- BarGroup {
- BarGlyphButton({ if (canUndo) onUndo() }, stringResource(R.string.common_undo), enabled = canUndo) {
- Icon(LucideIcons.Undo2, null, tint = if (canUndo) com.chethan616.clearpdf.ui.glass.LocalGlassInk.current else com.chethan616.clearpdf.ui.glass.LocalGlassInk.current.copy(alpha = 0.38f), modifier = Modifier.size(20.dp))
- }
- BarGlyphButton({ if (canRedo) onRedo() }, stringResource(R.string.common_redo), enabled = canRedo) {
- Icon(LucideIcons.Redo2, null, tint = if (canRedo) com.chethan616.clearpdf.ui.glass.LocalGlassInk.current else com.chethan616.clearpdf.ui.glass.LocalGlassInk.current.copy(alpha = 0.38f), modifier = Modifier.size(20.dp))
- }
+ if (canUndo) GlassCircle(onClick = onUndo, label = stringResource(R.string.common_undo)) {
+ GlassIcon(LucideIcons.Undo2, null, Modifier.size(20.dp))
+ }
+ if (canRedo) GlassCircle(onClick = onRedo, label = stringResource(R.string.common_redo)) {
+ GlassIcon(LucideIcons.Redo2, null, Modifier.size(20.dp))
}
}
} else {
- BarGroup {
- if (canUndo) UndoMenuButton(canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel)
- BarGlyphButton(onShare, stringResource(R.string.common_share)) { Icon(LucideIcons.Share2, null, tint = c.icon, modifier = Modifier.size(19.dp)) }
- var moreAnchor by remember { mutableStateOf(Rect.Zero) }
- BarGlyphButton({ onMore(moreAnchor) }, stringResource(R.string.common_more_options), modifier = Modifier.onGloballyPositioned { moreAnchor = it.boundsInWindow() }) { Icon(LucideIcons.Ellipsis, null, tint = c.icon, modifier = Modifier.size(21.dp)) }
+ if (canUndo) UndoMenuButton(
+ canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel,
+ modifier = Modifier.graphicsLayer { alpha = contentAlpha.coerceIn(0f, 1f) },
+ enabled = contentAlpha > 0.5f,
+ )
+ GlassCircle(onClick = { if (contentAlpha > 0.5f) onShare() }, modifier = Modifier.graphicsLayer { alpha = contentAlpha.coerceIn(0f, 1f) }, label = stringResource(R.string.common_share)) {
+ GlassIcon(LucideIcons.Share2, null, Modifier.size(19.dp))
+ }
+ var moreAnchor by remember { mutableStateOf(Rect.Zero) }
+ GlassCircle(
+ onClick = { if (contentAlpha > 0.5f) onMore(moreAnchor) },
+ label = stringResource(R.string.common_more_options),
+ modifier = Modifier.onGloballyPositioned { moreAnchor = it.boundsInWindow() }
+ .graphicsLayer { alpha = contentAlpha.coerceIn(0f, 1f) },
+ ) {
+ GlassIcon(LucideIcons.Ellipsis, null, Modifier.size(21.dp))
}
}
}
@@ -207,27 +214,26 @@ fun GlassBars(visible: Boolean, fromTop: Boolean, content: @Composable () -> Uni
) { content() }
}
-/** Bar buttons grouped on one glass capsule, as iOS groups them. */
-@Composable
-private fun BarGroup(content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit) {
- val c = pdfColors
- Row(
- Modifier.height(48.dp).glassBar(surface = c.surfaceRaised.copy(alpha = if (c.dark) 0.90f else 0.84f)).padding(horizontal = 4.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) { CompositionLocalProvider(com.chethan616.clearpdf.ui.glass.LocalGlassInk provides c.icon) { content() } }
-}
-
-/** Undo in a bar group: a tap opens a menu naming what Undo and Redo would do. */
+/** Undo: a standalone viewer glass button, matching Back and More tools. */
@Composable
-fun UndoMenuButton(canUndo: Boolean, canRedo: Boolean, onUndo: () -> Unit, onRedo: () -> Unit, undoLabel: String? = null, redoLabel: String? = null) {
+fun UndoMenuButton(
+ canUndo: Boolean,
+ canRedo: Boolean,
+ onUndo: () -> Unit,
+ onRedo: () -> Unit,
+ undoLabel: String? = null,
+ redoLabel: String? = null,
+ modifier: Modifier = Modifier,
+ enabled: Boolean = true,
+) {
var open by remember { mutableStateOf(false) }
var anchor by remember { mutableStateOf(Rect.Zero) }
- BarGlyphButton(
- { if (canUndo || canRedo) open = true },
- stringResource(R.string.viewer_undo_or_redo),
- modifier = Modifier.onGloballyPositioned { anchor = it.boundsInWindow() },
- ) { Icon(LucideIcons.Undo2, null, tint = com.chethan616.clearpdf.ui.glass.LocalGlassInk.current, modifier = Modifier.size(20.dp)) }
- if (open) {
+ GlassCircle(
+ onClick = { if (enabled && (canUndo || canRedo)) open = true },
+ modifier = modifier.onGloballyPositioned { anchor = it.boundsInWindow() },
+ label = stringResource(R.string.viewer_undo_or_redo),
+ ) { GlassIcon(LucideIcons.Undo2, null, Modifier.size(20.dp)) }
+ if (open && enabled) {
val items = buildList {
if (canUndo) add(GlassMenuItem(undoLabel?.let { stringResource(R.string.viewer_undo_named, it) } ?: stringResource(R.string.common_undo), LucideIcons.Undo2, onClick = onUndo))
if (canRedo) add(GlassMenuItem(redoLabel?.let { stringResource(R.string.viewer_redo_named, it) } ?: stringResource(R.string.common_redo), LucideIcons.Redo2, onClick = onRedo))
@@ -237,7 +243,7 @@ fun UndoMenuButton(canUndo: Boolean, canRedo: Boolean, onUndo: () -> Unit, onRed
}
/**
- * Find, floating where the top row was: a round close button, then a glass capsule holding the
+ * Find, floating where the top row was: the persistent viewer back button, then a glass capsule holding the
* field, the "3 of 12" count (Extra Features), clear, Previous and Next.
*/
@Composable
@@ -248,13 +254,11 @@ fun SearchBar(
canStep: Boolean,
onSubmit: () -> Unit,
onClear: () -> Unit,
- onClose: () -> Unit,
onPrev: () -> Unit,
onNext: () -> Unit,
count: String? = null,
) {
- val c = pdfColors
- val ink = com.chethan616.clearpdf.ui.glass.InkProbe(Modifier, c.icon)
+ val ink = rememberGlassInk(clear.ink)
val focus = remember { FocusRequester() }
val keyboard = LocalSoftwareKeyboardController.current
val findLabel = stringResource(R.string.viewer_find_in_document)
@@ -263,28 +267,28 @@ fun SearchBar(
delay(180)
focus.requestFocus()
}
- // the field is the title pill stretched over Share and More (their group and its gap, 96 dp), on
+ // the field is the title pill stretched over Share and More (their two glass circles and gap), on
// a damped glass spring; its words come in once it has room and leave first
Row(
Modifier.fillMaxWidth().height(TopBarHeight).padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
- Box(Modifier.graphicsLayer { alpha = progress().coerceIn(0f, 1f) }) {
- com.chethan616.clearpdf.ui.glass.GlassBackButton(onClose, label = stringResource(R.string.viewer_collapse), immediate = true)
- }
+ // The viewer's Back button remains in the same position for the whole morph. Keeping just
+ // one glass control here avoids two overlapping lenses making the glyph flicker.
+ Spacer(Modifier.size(40.dp))
Row(
Modifier.weight(1f).height(48.dp)
.layout { m, cs ->
val full = cs.maxWidth
- val start = (full - 96.dp.roundToPx()).coerceAtLeast(full / 2)
+ val start = (full - 88.dp.roundToPx()).coerceAtLeast(full / 2)
val p = progress().coerceIn(0f, 1f)
val w = (start + (full - start) * p).toInt().coerceIn(1, full)
val placeable = m.measure(cs.copy(minWidth = w, maxWidth = w))
layout(full, placeable.height) { placeable.place(0, 0) }
}
.then(ink.modifier)
- .glassBar(surface = c.surfaceRaised.copy(alpha = if (c.dark) 0.92f else 0.86f)).padding(start = 16.dp, end = 4.dp)
+ .glassBar().padding(start = 16.dp, end = 4.dp)
.graphicsLayer { alpha = ((progress().coerceIn(0f, 1f) - 0.35f) / 0.45f).coerceIn(0f, 1f) },
verticalAlignment = Alignment.CenterVertically,
) {
@@ -358,13 +362,14 @@ fun QuickToolbar(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
) {
- // iOS 26's toolbar: one glass capsule of plain glyphs in the glass's ink (no rainbow, no captions:
- // each glyph names itself to TalkBack), More tools in a glass bubble of its own beside it
- val c = pdfColors
- Row(Modifier.weight(1f).fillMaxHeight().glassBar(surface = c.surfaceRaised.copy(alpha = if (c.dark) 0.90f else 0.84f)).padding(horizontal = 6.dp), verticalAlignment = Alignment.CenterVertically) {
- CompositionLocalProvider(com.chethan616.clearpdf.ui.glass.LocalGlassInk provides c.icon) {
- for (t in shown) DockItem(t.icon, stringResource(t.label)) { onTool(t) }
- }
+ // Match Back and More tools: every action has its own clear glass circle rather than living
+ // inside a themed toolbar surface.
+ Row(
+ Modifier.weight(1f).fillMaxHeight(),
+ horizontalArrangement = Arrangement.SpaceEvenly,
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ for (t in shown) DockItem(t.icon, stringResource(t.label)) { onTool(t) }
}
// Office documents have their own concise toolbar. PDFs use the menu for the remaining
// tools rather than opening the old grid sheet.
@@ -388,11 +393,10 @@ fun QuickToolbar(
private fun Modifier.androidxRotate(degrees: Float) = this.graphicsLayer { rotationZ = degrees }
@Composable
-private fun androidx.compose.foundation.layout.RowScope.DockItem(icon: ImageVector, label: String, onClick: () -> Unit) {
- Box(
- Modifier.weight(1f).fillMaxHeight().pressable(onClick, pressedScale = 0.86f).semantics { contentDescription = label },
- contentAlignment = Alignment.Center,
- ) { GlassIcon(icon, null, Modifier.size(24.dp)) }
+private fun DockItem(icon: ImageVector, label: String, onClick: () -> Unit) {
+ GlassCircle(onClick = onClick, size = 48.dp, label = label) {
+ GlassIcon(icon, null, Modifier.size(24.dp))
+ }
}
/** No line along bars any more: glass floats. Kept so the tools' own bars can call it. */
@@ -406,12 +410,12 @@ fun Modifier.barTopLine(): Modifier = this
fun SubToolbar(content: @Composable () -> Unit) {
val scroll = rememberScrollState()
BoxWithConstraints(Modifier.fillMaxWidth().height(BottomBarHeight).padding(horizontal = 12.dp, vertical = 8.dp), contentAlignment = Alignment.Center) {
- val c = pdfColors
+ val ink = rememberGlassInk(clear.ink)
Row(
- Modifier.widthIn(max = maxWidth).fillMaxHeight().glassBar(surface = c.surfaceRaised.copy(alpha = if (c.dark) 0.90f else 0.84f)).horizontalScroll(scroll).padding(horizontal = 8.dp),
+ Modifier.widthIn(max = maxWidth).fillMaxHeight().then(ink.modifier).glassBar().horizontalScroll(scroll).padding(horizontal = 8.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
- ) { CompositionLocalProvider(LocalSubToolbarScroll provides scroll, com.chethan616.clearpdf.ui.glass.LocalGlassInk provides c.icon) { content() } }
+ ) { CompositionLocalProvider(LocalSubToolbarScroll provides scroll, LocalGlassInk provides ink.color) { content() } }
}
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
index d79c231..1778a54 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerOverlays.kt
@@ -65,6 +65,7 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.chethan616.clearpdf.ui.glass.pressable
+import com.chethan616.clearpdf.ui.glass.glass
import com.kyant.backdrop.floatingLayer
import com.chethan616.clearpdf.ui.theme.clear
import com.chethan616.clearpdf.R
@@ -111,8 +112,11 @@ fun BoxScope.Scrubber(doc: OpenDocument, visible: Boolean, top: Dp, bottom: Dp,
.offset { IntOffset(0, y.roundToInt()) }
.height(32.dp)
.widthIn(min = if (label.length >= 3) 52.dp else 40.dp)
- .shadow(2.dp, RoundedCornerShape(topStart = 16.dp, bottomStart = 16.dp))
- .background(c.surface, RoundedCornerShape(topStart = 16.dp, bottomStart = 16.dp))
+ .glass(
+ shape = RoundedCornerShape(topStart = 16.dp, bottomStart = 16.dp),
+ wash = if (c.dark) Color(0xFF0D0D10).copy(alpha = 0.64f) else Color.White.copy(alpha = 0.76f),
+ blur = 2.dp,
+ )
.pointerInput(doc) {
detectTapGestures(onTap = { onTap() })
}
@@ -308,7 +312,11 @@ private fun InlineNoteBar(hint: String, onDismiss: () -> Unit, onPost: (String)
Box(Modifier.fillMaxSize().pointerInput(Unit) { detectTapGestures { onDismiss() } })
Column(
Modifier.align(Alignment.BottomCenter).fillMaxWidth().imePadding()
- .clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)).background(c.surface),
+ .glass(
+ shape = RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp),
+ wash = if (c.dark) Color(0xFF0D0D10).copy(alpha = 0.64f) else Color.White.copy(alpha = 0.76f),
+ blur = 18.dp,
+ ),
) {
BasicTextField(
value = text, onValueChange = { text = it }, maxLines = 3,
@@ -462,8 +470,11 @@ fun BoxScope.HorizontalScrubber(doc: OpenDocument, visible: Boolean, bottom: Dp,
Modifier
.offset { IntOffset(x.roundToInt(), 0) }
.size(48.dp, 30.dp)
- .shadow(2.dp, RoundedCornerShape(15.dp))
- .background(c.surface, RoundedCornerShape(15.dp))
+ .glass(
+ shape = RoundedCornerShape(15.dp),
+ wash = if (c.dark) Color(0xFF0D0D10).copy(alpha = 0.64f) else Color.White.copy(alpha = 0.76f),
+ blur = 2.dp,
+ )
.pointerInput(doc) { detectTapGestures(onTap = { onTap() }) }
.pointerInput(doc) {
detectDragGestures(
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
index 76af688..833d4b1 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerScreen.kt
@@ -374,12 +374,7 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
}
val searchShown by remember { androidx.compose.runtime.derivedStateOf { ctl.searching || sp.value > 0.002f } }
Box(barSides) {
- Box(
- Modifier.graphicsLayer { alpha = (1f - sp.value).coerceIn(0f, 1f) }
- .then(if (searchShown) Modifier.pointerInput(searchShown) {
- awaitPointerEventScope { while (true) awaitPointerEvent(androidx.compose.ui.input.pointer.PointerEventPass.Initial).changes.forEach { it.consume() } }
- } else Modifier),
- ) {
+ Box {
val fa = vm.fieldActions
if (fa != null) FieldTopBar(fa) else ViewerTopBar(
title = doc.title,
@@ -389,7 +384,11 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
doneIsCheck = ctl.tool != ViewerTool.Comment,
canUndo = doc.localUndo?.canUndo?.invoke() ?: (doc.info.undo != null),
canRedo = doc.localUndo?.canRedo?.invoke() ?: (doc.info.redo != null),
- onBack = { if (ctl.tool != ViewerTool.None) vm.leaveTool(doc) else vm.closeDocument() },
+ onBack = {
+ if (searchShown) closeSearch(doc)
+ else if (ctl.tool != ViewerTool.None) vm.leaveTool(doc)
+ else vm.closeDocument()
+ },
onUndo = { vm.undo(doc) },
onRedo = { vm.redo(doc) },
onTitle = { anchor ->
@@ -406,6 +405,7 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
moreMenuAnchor = anchor
ctl.sheet = if (ctl.sheet == ViewerSheet.More) ViewerSheet.None else ViewerSheet.More
},
+ contentAlpha = 1f - sp.value,
undoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.undo,
redoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.redo,
)
@@ -425,7 +425,6 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
query = ""
search.clear()
},
- onClose = { closeSearch(doc) },
onPrev = { search.step(false)?.let { showHit(doc, it) } },
onNext = { search.step(true)?.let { showHit(doc, it) } },
// Extra Features: which result is on screen, of how many (still growing while
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
index 398c884..ee40362 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ViewerSheets.kt
@@ -195,7 +195,13 @@ fun ViewSettingsSheet(vm: AppViewModel, doc: OpenDocument) {
SheetSection {
// Keep this sheet mounted while the page inversion changes so the switch's touch
// sequence cannot race a disappearing parent surface.
- SheetRow(LucideIcons.Moon, stringResource(R.string.sheet_night_mode), { vm.setNightMode(doc, !ctl.nightMode) }, tint = Candy.Grape) {
+ SheetRow(
+ LucideIcons.Moon,
+ stringResource(R.string.sheet_night_mode),
+ { vm.setNightMode(doc, !ctl.nightMode) },
+ tint = Candy.Grape,
+ trailingInteractive = true,
+ ) {
PdfSwitch(ctl.nightMode, { vm.setNightMode(doc, it) })
}
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
index 17528f2..841ad4a 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/viewer/ZoomButtons.kt
@@ -6,14 +6,11 @@ import android.content.res.Configuration
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
-import androidx.compose.foundation.background
-import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.PlainTooltip
@@ -29,8 +26,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
-import androidx.compose.ui.draw.clip
-import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.pointerInput
@@ -39,7 +34,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.chethan616.clearpdf.R
import com.chethan616.clearpdf.ui.LucideIcons
-import com.chethan616.clearpdf.ui.pdfColors
+import com.chethan616.clearpdf.ui.glass.GlassCircle
+import com.chethan616.clearpdf.ui.glass.GlassIcon
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
@@ -124,22 +120,17 @@ fun ZoomButtons(state: ViewerState, visible: Boolean, bottom: Dp, onHover: () ->
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ZoomButton(icon: ImageVector, label: String, enabled: Boolean, onClick: () -> Unit) {
- val c = pdfColors
TooltipBox(
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
tooltip = { PlainTooltip { Text(label) } },
state = rememberTooltipState(),
) {
- Box(
- Modifier
- .size(40.dp)
- .shadow(4.dp, CircleShape)
- .clip(CircleShape)
- .background(c.surfaceRaised)
- .clickable(enabled = enabled, onClick = onClick),
- contentAlignment = Alignment.Center,
+ GlassCircle(
+ onClick = { if (enabled) onClick() },
+ size = 40.dp,
+ label = label,
) {
- Icon(icon, label, tint = c.icon, modifier = Modifier.size(22.dp).alpha(if (enabled) 1f else 0.38f))
+ GlassIcon(icon, null, modifier = Modifier.size(22.dp).alpha(if (enabled) 1f else 0.38f))
}
}
}