feat(session): add portrait sessions and controls below the game (#1612)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-26 12:01:44 -04:00
1 parent d65912f0c5
commit eaaecf0661
16 files changed
+359 -91

No files matched your search

@@ -37,10 +37,12 @@ class DeckControlsPanel(
private val onSteamMenu: () -> Unit,
private val onQam: () -> Unit,
private val pad: PadBridge? = null,
private val portraitDock: Boolean = false,
) : LinearLayout(context) {
private enum class Tab(val label: Int) { GAMEPAD(R.string.deck_tab_gamepad), GRIPS(R.string.deck_tab_grips), LEFT(R.string.deck_tab_left), RIGHT(R.string.deck_tab_right), BOTH(R.string.deck_tab_both) }
private val content = FrameLayout(context)
val deckControls = pad == null || SessionState.deckPad
private val tabViews = HashMap<Tab, TextView>()
private val topBar: View by lazy { topBar() }
@@ -49,7 +51,7 @@ class DeckControlsPanel(
setBackgroundColor(Color.BLACK)
addView(topBar, LayoutParams(LayoutParams.MATCH_PARENT, dp(64)))
addView(content, LayoutParams(LayoutParams.MATCH_PARENT, 0, 1f))
select(if (pad != null) selectedWithPad else selected)
select(if (pad != null && !deckControls) Tab.GAMEPAD else if (pad != null) selectedWithPad else selected)
}
override fun onDetachedFromWindow() {
@@ -67,6 +69,7 @@ class DeckControlsPanel(
background = outline(CORNER_PILL, SURFACE)
setPadding(dp(4), dp(4), dp(4), dp(4))
for (tab in Tab.values()) {
if (!deckControls && tab != Tab.GAMEPAD) continue
if (tab == Tab.GAMEPAD && pad == null) continue
val view = TextView(context).apply {
text = context.getString(tab.label)
@@ -170,7 +173,7 @@ class DeckControlsPanel(
addView(grips, LayoutParams(LayoutParams.MATCH_PARENT, dp(84)))
}
private fun gamepad(pad: PadBridge): View = GamepadLayout(context).apply {
private fun gamepad(pad: PadBridge): View = GamepadLayout(context, portraitDock).apply {
fun pill(label: String, write: (PadState, Boolean) -> Unit) = PadButton(context, pad, label, write)
place(surfaceSlot(pad, right = false), GamepadGeometry.Slot.LEFT_MAIN)
place(DirectionPad(context, pad), GamepadGeometry.Slot.LEFT_SECOND)
@@ -186,14 +189,22 @@ class DeckControlsPanel(
place(centreTap("\u2022\u2022\u2022", context.getString(R.string.drawer_open_qam), onQam), GamepadGeometry.Slot.QAM)
}
place(pill("MENU") { st, d -> st.press(PadState.START, d) }, GamepadGeometry.Slot.MENU)
place(centreTap("\u25a6 " + context.getString(R.string.deck_panels), context.getString(R.string.deck_more_controls)) { select(Tab.BOTH) },
if (deckControls) place(centreTap("\u25a6 " + context.getString(R.string.deck_panels), context.getString(R.string.deck_more_controls)) { select(Tab.BOTH) },
GamepadGeometry.Slot.PANELS)
if (portraitDock && deckControls) {
place(GripButton(context, "L4", null, DeckControls.L4), GamepadGeometry.Slot.L4)
place(GripButton(context, "L5", null, DeckControls.L5), GamepadGeometry.Slot.L5)
place(GripButton(context, "R5", null, DeckControls.R5), GamepadGeometry.Slot.R5)
place(GripButton(context, "R4", null, DeckControls.R4), GamepadGeometry.Slot.R4)
}
}
private fun centreTap(label: String, description: String, onClick: () -> Unit) = TextView(context).apply {
text = label
contentDescription = description
textSize = 13f
maxLines = 1
setAutoSizeTextTypeUniformWithConfiguration(9, 13, 1, android.util.TypedValue.COMPLEX_UNIT_SP)
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
letterSpacing = 0.08f
gravity = Gravity.CENTER
@@ -206,6 +217,11 @@ class DeckControlsPanel(
}
private fun surfaceSlot(pad: PadBridge, right: Boolean): View = FrameLayout(context).apply {
if (!deckControls) {
addView(StickView(context, pad, right),
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT))
return@apply
}
val slot = this
fun show() {
slot.removeAllViews()
@@ -617,7 +633,7 @@ class DeckControlsPanel(
}
}
private class GamepadLayout(context: Context) : ViewGroup(context) {
private class GamepadLayout(context: Context, private val portraitDock: Boolean) : ViewGroup(context) {
private val slots = LinkedHashMap<View, GamepadGeometry.Slot>()
fun place(view: View, slot: GamepadGeometry.Slot) {
@@ -625,7 +641,7 @@ class DeckControlsPanel(
addView(view)
}
private fun boxes(w: Int, h: Int) = GamepadGeometry.layout(w.toFloat(), h.toFloat(), resources.displayMetrics.density)
private fun boxes(w: Int, h: Int) = GamepadGeometry.layout(w.toFloat(), h.toFloat(), resources.displayMetrics.density, portraitDock)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val w = MeasureSpec.getSize(widthMeasureSpec)
@@ -8,6 +8,7 @@ object GamepadGeometry {
LEFT_OUTER_SHOULDER, LEFT_INNER_SHOULDER, RIGHT_INNER_SHOULDER, RIGHT_OUTER_SHOULDER,
VIEW, STEAM, QAM, MENU,
PANELS,
L4, L5, R5, R4,
}
data class Box(val cx: Float, val cy: Float, val width: Float, val height: Float) {
@@ -25,8 +26,11 @@ object GamepadGeometry {
fun tall(w: Float, h: Float): Boolean = h >= w * 0.45f
fun layout(w: Float, h: Float, density: Float): Map<Slot, Box> {
fun layout(w: Float, h: Float, density: Float, portraitDock: Boolean = false): Map<Slot, Box> {
if (w <= 0f || h <= 0f) return emptyMap()
if (portraitDock && h >= w * 0.9f && w >= 300 * density && h >= 360 * density) {
return portraitLayout(w, h, density)
}
val pad = 8 * density
val buttonH = 40 * density
val rowButton = 64 * density
@@ -67,7 +71,7 @@ object GamepadGeometry {
}
middleGrid(columns, gap - 2 * gutter, shoulderY - buttonH / 2f)
} else {
val side = min(w * 0.5f, h * 0.70f)
val side = min(min(w * 0.5f, h * 0.70f), (w - 2 * gridButton - 2 * gutter) / 1.42f)
val main = side * 0.62f
val second = side * 0.46f
val secondCy = h - side * 0.97f
@@ -87,4 +91,39 @@ object GamepadGeometry {
}
return boxes
}
private fun portraitLayout(w: Float, h: Float, density: Float): Map<Slot, Box> {
val pad = 8 * density
val gap = 8 * density
val buttonH = 44 * density
val scale = min(1f, (h - 2 * pad - 4 * gap - 3 * buttonH) / (w * 0.7f))
val main = w * 0.4f * scale
val second = w * 0.3f * scale
val mainY = h - pad - main / 2f
val secondY = mainY - main / 2f - gap - second / 2f
val shoulderY = secondY - second / 2f - gap - buttonH / 2f
val boxes = linkedMapOf(
Slot.LEFT_MAIN to Box(w * 0.25f, mainY, main, main),
Slot.RIGHT_MAIN to Box(w * 0.75f, mainY, main, main),
Slot.LEFT_SECOND to Box(w * 0.25f, secondY, second, second),
Slot.RIGHT_SECOND to Box(w * 0.75f, secondY, second, second),
)
val utilityW = (w - 2 * pad - 3 * gap) / 4f
for ((i, slot) in middle.withIndex()) {
boxes[slot] = Box(pad + utilityW / 2f + i * (utilityW + gap), pad + buttonH / 2f, utilityW, buttonH)
}
val gripTop = pad + buttonH + gap
val gripH = min(64 * density, shoulderY - buttonH / 2f - gap - gripTop)
for ((i, slot) in listOf(Slot.L4, Slot.L5, Slot.R5, Slot.R4).withIndex()) {
boxes[slot] = Box(pad + utilityW / 2f + i * (utilityW + gap), gripTop + gripH / 2f, utilityW, gripH)
}
val panelsW = min(112 * density, w * 0.22f)
val shoulderW = (w - 2 * pad - 4 * gap - panelsW) / 4f
boxes[Slot.PANELS] = Box(w / 2f, shoulderY, panelsW, buttonH)
boxes[Slot.LEFT_OUTER_SHOULDER] = Box(pad + shoulderW / 2f, shoulderY, shoulderW, buttonH)
boxes[Slot.LEFT_INNER_SHOULDER] = Box(pad + shoulderW * 1.5f + gap, shoulderY, shoulderW, buttonH)
boxes[Slot.RIGHT_INNER_SHOULDER] = Box(w - pad - shoulderW * 1.5f - gap, shoulderY, shoulderW, buttonH)
boxes[Slot.RIGHT_OUTER_SHOULDER] = Box(w - pad - shoulderW / 2f, shoulderY, shoulderW, buttonH)
return boxes
}
}
@@ -210,9 +210,16 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
val host = rememberMenuHost()
var explainWifiDiscovery by remember { mutableStateOf(false) }
if (tab == SheetTab.DISPLAY) {
val displaySize = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(s.panelSize, s.resolution)
val context = LocalContext.current
val portraitWindow = SessionPrefs.portrait(context)
val longSide = maxOf(s.panelSize.first, s.panelSize.second)
val shortSide = minOf(s.panelSize.first, s.panelSize.second)
val controlsBelow = SessionPrefs.controlsBelowWanted(context, s.mode,
if (portraitWindow) shortSide else longSide, if (portraitWindow) longSide else shortSide)
val portrait = portraitWindow && !controlsBelow
val displaySize = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(s.panelSize, s.resolution, portrait)
SettingsGroup(stringResource(R.string.display_session)) {
ResolutionRow(host, s.resolution, s.panelSize, a.onResolution)
ResolutionRow(host, s.resolution, s.panelSize, a.onResolution, portrait = portrait)
s.picturePosition?.let { position ->
ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null,
listOf("top" to stringResource(R.string.display_position_top),
@@ -14,16 +14,17 @@ import com.droiddeck.launcher.session.SessionDisplay
fun ResolutionRow(
host: MenuHost, choice: String, panel: Pair<Int, Int>, onPick: (String) -> Unit,
chipModifier: Modifier = Modifier,
portrait: Boolean = false,
) {
val custom = "custom"
val size = SessionDisplay.resolveChoice(panel, choice)
val screen = SessionDisplay.screenSize(panel)
val size = SessionDisplay.resolveChoice(panel, choice, portrait)
val screen = SessionDisplay.resolveChoice(panel, SessionDisplay.MATCH_SCREEN, portrait)
val choices = SessionDisplay.resolutionOptions(panel)
val selected = if (choice == SessionDisplay.FOLLOW_SCREEN) choice
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
var editCustom by remember { mutableStateOf(false) }
val options = choices.map { value ->
val dimensions = SessionDisplay.resolveChoice(panel, value)
val dimensions = SessionDisplay.resolveChoice(panel, value, portrait)
value to if (value == SessionDisplay.MATCH_SCREEN) stringResource(R.string.display_match_screen, screen.first, screen.second)
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
else if (value == SessionDisplay.DEFAULT_RESOLUTION) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}")
@@ -72,6 +72,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
@@ -405,6 +407,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
androidx.compose.foundation.layout.BoxWithConstraints(modifier = Modifier.fillMaxSize().exposeTestTags(), contentAlignment = Alignment.CenterEnd) {
val short = maxHeight < 440.dp
val sheetWidth = minOf(360.dp, maxWidth * 0.92f)
val narrow = sheetWidth < 320.dp
AnimatedVisibility(
open,
enter = slideInHorizontally(Motion.sp(0.8f, Spring.StiffnessLow)) { it } + fadeIn(Motion.tw(220)),
@@ -420,14 +423,18 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
.controllerBack {
if (host.open != null) host.open = null else a.onClose()
}
.padding(if (short) 12.dp else 16.dp),
.padding(12.dp),
) {
val title = a.title ?: if (a.steam) stringResource(R.string.drawer_steam) else stringResource(R.string.drawer_desktop)
if (narrow) Text(title, fontSize = 18.sp, fontWeight = FontWeight.Bold,
color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis,
modifier = Modifier.fillMaxWidth().padding(bottom = 6.dp))
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth().heightIn(min = 44.dp),
) {
Text(a.title ?: if (a.steam) stringResource(R.string.drawer_steam) else stringResource(R.string.drawer_desktop), fontSize = if (short) 18.sp else 20.sp, fontWeight = FontWeight.Bold,
if (narrow) Spacer(Modifier.weight(1f)) else Text(title, fontSize = 18.sp, fontWeight = FontWeight.Bold,
color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
if (a.pipSupported) SteamActionPill(
stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, focus.track(page, "pip"),
@@ -468,12 +475,12 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().padding(top = if (short) 6.dp else 12.dp),
modifier = Modifier.fillMaxWidth().padding(top = 6.dp),
) {
DrawerBumper("LB", stringResource(R.string.drawer_prev_page), modifier = focus.track(page, "prev")) {
host.open = null; onPageChange(pages.step(page, -1))
}
DrawerPageTabs(page = page, pages = pages, compact = short, modifier = Modifier.weight(1f)) { index -> host.open = null; onPageChange(index) }
DrawerPageTabs(page = page, pages = pages, compact = true, modifier = Modifier.weight(1f)) { index -> host.open = null; onPageChange(index) }
DrawerBumper("RB", stringResource(R.string.drawer_next_page), modifier = focus.track(page, "next")) {
host.open = null; onPageChange(pages.step(page, 1))
}
@@ -484,7 +491,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
) { selectedGlassesTab = it }
Column(
modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(pageScroll.getValue(page)),
) { CompositionLocalProvider(LocalChipMinWidth provides 120.dp) {
) { CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) {
when (page) {
SessionDrawerPage.DISPLAY -> {
SettingsGroup(stringResource(R.string.drawer_page_display)) {
@@ -559,7 +566,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
stringResource(R.string.ctrl_edit), a.onGestureSettings,
modifier = focus.track(page, "gesture-settings"))
if (a.onScreenKeys != null) {
SettingsRow(stringResource(R.string.screen_keys), null) {
SettingsRow(stringResource(R.string.screen_keys), null, stacked = narrow) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
@@ -896,16 +903,22 @@ private fun DrawerPageTabs(page: SessionDrawerPage, pages: List<SessionDrawerPag
modifier = modifier.height(if (compact) 44.dp else 64.dp).clipToBounds().selectableGroup(),
) {
val tab = if (compact) 36f else 44f
val scrolling = maxWidth < (tab + (count - 1) * 24f).dp
val scroll = rememberScrollState()
val density = LocalDensity.current.density
LaunchedEffect(scrolling, selectedIndex, maxWidth) {
if (scrolling) scroll.animateScrollTo(((selectedIndex * (tab + 4f) + tab / 2f - maxWidth.value / 2f) * density).roundToInt().coerceAtLeast(0))
}
val spacing = ((maxWidth.value - tab) / ((count - 1) * (1f + DRAWER_TAB_LEAN_DP / DRAWER_TAB_SPACING_DP))).coerceIn(24f, DRAWER_TAB_SPACING_DP)
val leanStep = DRAWER_TAB_LEAN_DP * spacing / DRAWER_TAB_SPACING_DP
val lean by animateFloatAsState(-(selectedIndex - middle) * leanStep, motion, label = "tabLean")
pages.forEachIndexed { index, item ->
@Composable fun tabs() { pages.forEachIndexed { index, item ->
androidx.compose.runtime.key(item) {
val selected = item == page
val source = remember { MutableInteractionSource() }
val focused = source.collectIsFocusedAsState().value
val scale by animateFloatAsState(if (selected) 1f else DRAWER_TAB_SIDE_SCALE, motion, label = "tabScale")
val alpha by animateFloatAsState(if (selected) 1f else DRAWER_TAB_SIDE_ALPHA, motion, label = "tabAlpha")
val scale by animateFloatAsState(if (selected || scrolling) 1f else DRAWER_TAB_SIDE_SCALE, motion, label = "tabScale")
val alpha by animateFloatAsState(if (selected || scrolling) 1f else DRAWER_TAB_SIDE_ALPHA, motion, label = "tabAlpha")
val glow by animateFloatAsState(if (selected) 1f else 0f, motion, label = "tabGlow")
val pageDescription = stringResource(R.string.drawer_page_desc, stringResource(item.title))
val tint by animateColorAsState(if (selected) colors.onBackground else colors.onSurfaceVariant, Motion.tw(340, easing = FastOutSlowInEasing), label = "tabTint")
@@ -913,7 +926,7 @@ private fun DrawerPageTabs(page: SessionDrawerPage, pages: List<SessionDrawerPag
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.offset(x = ((index - middle) * spacing + lean).dp)
.then(if (scrolling) Modifier else Modifier.offset(x = ((index - middle) * spacing + lean).dp))
.size(tab.dp)
.graphicsLayer { scaleX = scale; scaleY = scale; this.alpha = alpha }
.clip(RoundedCornerShape(16.dp))
@@ -933,6 +946,9 @@ private fun DrawerPageTabs(page: SessionDrawerPage, pages: List<SessionDrawerPag
}
}
}
}
if (scrolling) Row(Modifier.fillMaxWidth().horizontalScroll(scroll), horizontalArrangement = Arrangement.spacedBy(4.dp)) { tabs() }
else tabs()
}
}
@@ -230,6 +230,7 @@ private fun BumperKey(label: String, description: String, onClick: () -> Unit) {
}
val LocalChipMinWidth = androidx.compose.runtime.compositionLocalOf { 150.dp }
internal val LocalCompactSettings = androidx.compose.runtime.compositionLocalOf { false }
class MenuHost {
var open by mutableStateOf<String?>(null)
@@ -389,6 +390,7 @@ fun MenuItem(
@Composable
fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Modifier = Modifier, onClick: () -> Unit) {
val compact = LocalCompactSettings.current
val colors = MaterialTheme.colorScheme
val src = remember { MutableInteractionSource() }
val hot = src.collectIsFocusedAsState().value || src.collectIsHoveredAsState().value
@@ -405,13 +407,15 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo
.alpha(if (enabled) 1f else 0.5f)
.hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current, enabled = enabled, onClick = onClick)
.controllerConfirm(enabled = enabled, onClick = onClick)
.padding(horizontal = 12.dp, vertical = 8.dp),
.padding(horizontal = if (compact) 10.dp else 12.dp, vertical = if (compact) 6.dp else 8.dp),
) {
AnimatedContent(
targetState = text,
transitionSpec = { (fadeIn(Motion.tw(260)) + slideInVertically(Motion.tw(260)) { it / 2 }) togetherWith (fadeOut(Motion.tw(160)) + slideOutVertically(Motion.tw(160)) { -it / 2 }) },
label = "chipText",
) { t -> Text(t, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) }
) { t -> Text(t, fontSize = if (compact) 12.sp else 13.sp,
lineHeight = if (compact) 16.sp else androidx.compose.ui.unit.TextUnit.Unspecified,
fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) }
Spacer(Modifier.width(8.dp))
Text("▾", fontSize = 10.sp, color = colors.onSurfaceVariant, modifier = Modifier.rotate(rot))
}
@@ -419,15 +423,16 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo
@Composable
fun SettingsGroup(title: String, compact: Boolean = false, content: @Composable ColumnScope.() -> Unit) {
val tight = compact || LocalCompactSettings.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
Column(Modifier.fillMaxWidth().sheetPiece()) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(if (compact) 6.dp else 10.dp),
modifier = Modifier.fillMaxWidth().padding(top = if (compact) 4.dp else 16.dp, bottom = if (compact) 3.dp else 6.dp),
horizontalArrangement = Arrangement.spacedBy(if (tight) 6.dp else 10.dp),
modifier = Modifier.fillMaxWidth().padding(top = if (tight) 4.dp else 16.dp, bottom = if (tight) 3.dp else 6.dp),
) {
Text(title.uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant)
Text(title.uppercase(), fontSize = if (tight) 11.sp else 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant)
Box(modifier = Modifier.weight(1f).height(1.dp).background(pal.line))
}
Column(modifier = Modifier.fillMaxWidth().clip(GroupShape).background(colors.surface).border(1.dp, pal.line, GroupShape)) { content() }
@@ -436,19 +441,34 @@ fun SettingsGroup(title: String, compact: Boolean = false, content: @Composable
@Composable
fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, control: @Composable () -> Unit) {
val compact = LocalCompactSettings.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val bg by animateColorAsState(if (highlighted) pal.signal.copy(alpha = 0.10f) else Color.Transparent, Motion.tw(200), label = "rowBg")
val hintText: @Composable (androidx.compose.ui.unit.TextUnit) -> Unit = { size ->
Text(hint ?: "", fontSize = size, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 2.dp),
lineHeight = if (compact) 14.sp else androidx.compose.ui.unit.TextUnit.Unspecified,
minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis)
}
if (stacked || LocalNarrowPane.current) Column(
modifier = Modifier.fillMaxWidth().background(bg).padding(start = 14.dp, end = 14.dp, top = 11.dp, bottom = 12.dp),
if (compact && !stacked) Column(
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp),
) {
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
if (hint != null || hintLines != null) hintText(13.sp)
Box(Modifier.padding(top = 8.dp)) { control() }
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Text(label, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground,
modifier = Modifier.weight(1f))
control()
}
if (hint != null || hintLines != null) hintText(11.sp)
} else if (stacked || LocalNarrowPane.current) Column(
modifier = Modifier.fillMaxWidth().background(bg).padding(
horizontal = if (compact) 10.dp else 14.dp,
vertical = if (compact) 6.dp else 12.dp),
) {
Text(label, fontSize = if (compact) 13.sp else 15.sp,
lineHeight = if (compact) 16.sp else androidx.compose.ui.unit.TextUnit.Unspecified,
fontWeight = FontWeight.SemiBold, color = colors.onBackground)
if (hint != null || hintLines != null) hintText(if (compact) 11.sp else 13.sp)
Box(Modifier.padding(top = if (compact) 6.dp else 8.dp)) { control() }
} else Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
@@ -561,6 +581,7 @@ fun ValueSlider(
value: Int, range: IntRange, step: Int, enabled: Boolean, label: String?, format: (Int) -> String,
modifier: Modifier = Modifier, onChange: (Int) -> Unit,
) {
val compact = LocalCompactSettings.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val source = remember { MutableInteractionSource() }
@@ -581,7 +602,7 @@ fun ValueSlider(
}
}
Column(
modifier = modifier.fillMaxWidth().heightIn(min = 72.dp)
modifier = modifier.fillMaxWidth().heightIn(min = if (compact) 64.dp else 72.dp)
.clip(shape).background(if (hot) pal.signal.copy(alpha = 0.12f) else Color.Transparent)
.glideBorder(hot, shape, pal.signal)
.alpha(if (enabled) 1f else 0.5f)
@@ -610,10 +631,10 @@ fun ValueSlider(
.padding(horizontal = 8.dp, vertical = 6.dp),
) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
if (label != null) Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
if (label != null) Text(label, fontSize = if (compact) 13.sp else 15.sp, fontWeight = FontWeight.SemiBold,
color = colors.onBackground, modifier = Modifier.weight(1f))
else Spacer(Modifier.weight(1f))
Text(text, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1)
Text(text, fontSize = if (compact) 12.sp else 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1)
}
Canvas(
Modifier.fillMaxWidth().height(40.dp).onSizeChanged { trackPx = it.width }