mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
Track glasses mode, refresh-aware glasses window, align Play SteamVR with Play Steam
This commit is contained in:
1 parent
b8fe2fbd88
commit
697565f84b
8 files changed
+105
-29
No files matched your search
@@ -440,10 +440,15 @@ internal fun BoxWithConstraintsScope.DropSheet(
|
||||
val sideInset = if (narrow) 20.dp else 44.dp
|
||||
val besideShown = enabled && !state.open && !state.shown
|
||||
val r1 = rest
|
||||
if (r1 != null && (besideShown || state.sink.value < 0.99f)) Box(
|
||||
val play = LocalPlayRect.current
|
||||
if (r1 != null && play != null && (besideShown || state.sink.value < 0.99f)) Box(
|
||||
Modifier
|
||||
.align(Alignment.TopEnd)
|
||||
.padding(top = sideInset, end = sideInset + with(density) { r1.width.toDp() } + 12.dp)
|
||||
.offset {
|
||||
val gap = 12.dp.roundToPx()
|
||||
val below = play.right + gap > r1.left
|
||||
IntOffset(play.left.roundToInt(), if (below) r1.bottom.roundToInt() + gap else sideInset.roundToPx())
|
||||
}
|
||||
.width(with(density) { play.width.toDp() })
|
||||
.graphicsLayer { alpha = (1f - state.sink.value) * (1f - covered()) }
|
||||
.zIndex(2f)
|
||||
.focusProperties { canFocus = besideShown },
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -38,6 +39,7 @@ import androidx.compose.material.icons.filled.ChevronLeft
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -57,6 +59,8 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.rememberTextMeasurer
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -153,6 +157,7 @@ internal fun PrimaryButton(
|
||||
/** The Steam tab's own Play: bigger than any other button on a page. */
|
||||
large: Boolean = false,
|
||||
icon: ImageVector? = null,
|
||||
fill: Boolean = false,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
@@ -172,7 +177,8 @@ internal fun PrimaryButton(
|
||||
// Where it sits, so a session it starts can grow out of it (LaunchFlood).
|
||||
val placed = remember { arrayOfNulls<androidx.compose.ui.layout.LayoutCoordinates>(1) }
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = if (fill) Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally) else Arrangement.spacedBy(8.dp),
|
||||
modifier = modifier.then(track)
|
||||
.onGloballyPositioned { placed[0] = it }
|
||||
// 48dp to touch on a handheld; compact rows keep 44.
|
||||
@@ -192,18 +198,34 @@ internal fun PrimaryButton(
|
||||
onClick()
|
||||
}
|
||||
.padding(
|
||||
start = if (large) 20.dp else if (compact) 10.dp else if (icon != null) 14.dp else 18.dp,
|
||||
end = if (large) 26.dp else if (compact) 10.dp else 18.dp,
|
||||
start = if (fill) 12.dp else if (large) 20.dp else if (compact) 10.dp else if (icon != null) 14.dp else 18.dp,
|
||||
end = if (fill) 12.dp else if (large) 26.dp else if (compact) 10.dp else 18.dp,
|
||||
top = if (large) 16.dp else if (compact) 7.dp else 11.dp,
|
||||
bottom = if (large) 16.dp else if (compact) 7.dp else 11.dp,
|
||||
),
|
||||
) {
|
||||
val fg = if (enabled) colors.onPrimary else colors.onSurfaceVariant
|
||||
if (icon != null) Icon(icon, contentDescription = null, tint = fg, modifier = Modifier.size(if (large) 20.dp else 17.dp))
|
||||
Text(
|
||||
text, fontSize = if (large) 17.sp else if (compact) 12.sp else 15.sp,
|
||||
fontWeight = if (large) FontWeight.Bold else FontWeight.SemiBold, letterSpacing = 0.5.sp, color = fg, maxLines = 1,
|
||||
)
|
||||
val style = LocalTextStyle.current.merge(TextStyle(
|
||||
fontSize = if (large) 17.sp else if (compact) 12.sp else 15.sp,
|
||||
fontWeight = if (large) FontWeight.Bold else FontWeight.SemiBold, letterSpacing = 0.5.sp, color = fg,
|
||||
))
|
||||
if (fill) FittedLabel(text, style, Modifier.weight(1f, fill = false))
|
||||
else Text(text, style = style, maxLines = 1)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FittedLabel(text: String, style: TextStyle, modifier: Modifier = Modifier) {
|
||||
BoxWithConstraints(modifier) {
|
||||
val measurer = rememberTextMeasurer()
|
||||
val max = constraints.maxWidth
|
||||
val size = remember(text, style, max) {
|
||||
var size = style.fontSize
|
||||
while (size.value > 10f && measurer.measure(text, style.copy(fontSize = size), maxLines = 1, softWrap = false).size.width > max) size = (size.value - 0.5f).sp
|
||||
size
|
||||
}
|
||||
Text(text, style = style.copy(fontSize = size), maxLines = 1, softWrap = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,8 @@ internal val LocalSheetBeat = staticCompositionLocalOf<SheetBeat?> { null }
|
||||
|
||||
internal val LocalSheetChipWidth = compositionLocalOf { Dp.Unspecified }
|
||||
|
||||
internal val LocalPlayRect = compositionLocalOf<Rect?> { null }
|
||||
|
||||
private val ChipGap = 6.dp
|
||||
|
||||
internal fun sheetChipWidth(row: Dp, count: Int): Dp =
|
||||
@@ -727,7 +729,7 @@ internal fun LiftHero(
|
||||
}
|
||||
}
|
||||
}
|
||||
CompositionLocalProvider(LocalSheetChipWidth provides chipWidth) { overlay { sink.value } }
|
||||
CompositionLocalProvider(LocalSheetChipWidth provides chipWidth, LocalPlayRect provides restRect) { overlay { sink.value } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
@@ -113,8 +114,8 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
if (glasses.present) DropSheet(
|
||||
drop, glasses.model, GlassesIcon, glassesTabs(glasses), covered = lifted,
|
||||
beside = { enabled ->
|
||||
PrimaryButton(stringResource(R.string.games_play_steamvr), enabled = !s.busy, large = true, icon = Icons.Filled.PlayArrow,
|
||||
modifier = Modifier.testTag("play-steamvr")) { if (enabled) a.onPlaySteamVr() }
|
||||
PrimaryButton(stringResource(R.string.games_play_steamvr), enabled = !s.busy, large = true, icon = Icons.Filled.PlayArrow, fill = true,
|
||||
modifier = Modifier.fillMaxWidth().testTag("play-steamvr")) { if (enabled) a.onPlaySteamVr() }
|
||||
},
|
||||
) { tab ->
|
||||
GlassesGroups(rememberMenuHost(), glasses, glassesSettings, inSession = false, tab = tab)
|
||||
|
||||
Reference in new issue
Block a user