From eabed0a593507fdf5f25f4111e9c8b102eb1892b Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Tue, 13 Oct 2026 08:54:53 -0400 Subject: [PATCH] Hang the glasses Settings lip over the top of the button --- .../java/com/droiddeck/launcher/ui/DropSheet.kt | 11 ++++++----- .../java/com/droiddeck/launcher/ui/LiftSheet.kt | 15 ++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DropSheet.kt b/app/src/main/java/com/droiddeck/launcher/ui/DropSheet.kt index 01a74c543..a6e4512b6 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DropSheet.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DropSheet.kt @@ -472,14 +472,15 @@ internal fun BoxWithConstraintsScope.DropSheet( val r0 = rest if (r0 != null && (state.lipShow.value > 0.01f || state.pull.value > 0.5f)) { - var handleW by remember { mutableStateOf(0f) } + var handleSize by remember { mutableStateOf(androidx.compose.ui.unit.IntSize.Zero) } val lipH = 32.dp + state.pull.value.dp val drop = { if (!state.open && enabled) state.open = true } val settingsLabel = stringResource(R.string.drawer_page_settings) Box( - Modifier - .offset { IntOffset((r0.center.x - handleW / 2f).roundToInt(), (r0.bottom + lower * state.ride.value + (state.lipShow.value - 1f) * 8.dp.toPx()).roundToInt()) } - .onSizeChanged { handleW = it.width.toFloat() } + contentAlignment = Alignment.BottomCenter, + modifier = Modifier + .offset { IntOffset((r0.center.x - handleSize.width / 2f).roundToInt(), (r0.top + lower * state.ride.value - handleSize.height + (1f - state.lipShow.value) * 8.dp.toPx()).roundToInt()) } + .onSizeChanged { handleSize = it } .graphicsLayer { alpha = state.lipShow.value * (1f - state.lipGone.value) * (1f - covered()) } .zIndex(2f) .heightIn(min = 44.dp).testTag("glasses-sheet-open") @@ -487,7 +488,7 @@ internal fun BoxWithConstraintsScope.DropSheet( .focusProperties { canFocus = false } .clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, role = Role.Button, onClick = drop), ) { - Handle(lipH, down = true) + Handle(lipH, above = true) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt index 302d8b0c7..362ed8e3e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt @@ -83,6 +83,7 @@ import androidx.compose.ui.geometry.RoundRect import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.drawscope.scale import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.lerp import androidx.compose.ui.input.InputMode @@ -725,10 +726,10 @@ internal fun LiftHero( * saying there is a drawer to pull up. Still with animations off. */ @Composable -internal fun Handle(height: Dp, down: Boolean = false) { +internal fun Handle(height: Dp, above: Boolean = false) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - val shape = RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp) + val shape = if (above) RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp) else RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp) val still = Motion.scale == 0f val bob = androidx.compose.animation.core.rememberInfiniteTransition(label = "handle") // A quick lift and settle, then a rest: a nudge, not a pulse. @@ -748,19 +749,19 @@ internal fun Handle(height: Dp, down: Boolean = false) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.height(height).clip(shape).background(colors.surface) - .drawBorderSidesAndFoot(pal.line, 12.dp) + .drawBorderSidesAndFoot(pal.line, 12.dp, flip = above) .padding(start = 14.dp, end = 10.dp), ) { Text(stringResource(R.string.drawer_page_settings), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1) Icon( - if (down) Icons.Filled.KeyboardArrowDown else Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant, - modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (down) 3.dp else -3.dp).toPx() * lift }, + if (above) Icons.Filled.KeyboardArrowDown else Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant, + modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (above) 3.dp else -3.dp).toPx() * lift }, ) } } /** A 1dp outline down the sides and along the foot, none along the top (the lip tucks under Play). */ -private fun Modifier.drawBorderSidesAndFoot(color: Color, corner: Dp): Modifier = +private fun Modifier.drawBorderSidesAndFoot(color: Color, corner: Dp, flip: Boolean = false): Modifier = this.drawWithContent { drawContent() val c = corner.toPx() @@ -773,7 +774,7 @@ private fun Modifier.drawBorderSidesAndFoot(color: Color, corner: Dp): Modifier arcTo(Rect(size.width - 2 * c, size.height - 2 * c + sw / 2, size.width - sw / 2, size.height - sw / 2), 90f, -90f, false) lineTo(size.width - sw / 2, 0f) } - drawPath(p, color, style = Stroke(sw)) + if (flip) scale(1f, -1f) { drawPath(p, color, style = Stroke(sw)) } else drawPath(p, color, style = Stroke(sw)) } /**