fix(hls): lay rendition checkboxes out horizontally via FlowRow
Five full-width rows eating half a screen was too much real estate for
a five-item toggle. Replace the fillMaxWidth stack with a FlowRow where
each item is a compact checkbox + short label ("360p", "540p", …),
wrapping to the next line on narrow screens.
The bitrate subline per rendition was cut — the values are public
library defaults anyway (360/540/720/1080/4K ladder) and the secondary
text was the biggest contributor to the vertical bloat. Above-source
rungs remain disabled; the grey-out on the checkbox + label is still
visible in the new layout.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+23
-32
@@ -30,6 +30,7 @@ import androidx.compose.foundation.clickable
|
|||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -439,17 +440,19 @@ private fun RenditionsCheckboxes(vm: NewHlsVideoViewModel) {
|
|||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
}
|
}
|
||||||
|
|
||||||
HlsLadder.default().renditions.forEach { rendition ->
|
FlowRow(
|
||||||
val label = rendition.resolution.label
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
val aboveSource = sourceShortSide != null && rendition.resolution.shortSide > sourceShortSide
|
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||||
val enabled = !aboveSource
|
) {
|
||||||
val checked = label in vm.selectedRenditionLabels && !aboveSource
|
HlsLadder.default().renditions.forEach { rendition ->
|
||||||
|
val label = rendition.resolution.label
|
||||||
|
val aboveSource = sourceShortSide != null && rendition.resolution.shortSide > sourceShortSide
|
||||||
|
val enabled = !aboveSource
|
||||||
|
val checked = label in vm.selectedRenditionLabels && !aboveSource
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier.clickable(enabled = enabled) {
|
||||||
.fillMaxWidth()
|
|
||||||
.clickable(enabled = enabled) {
|
|
||||||
vm.selectedRenditionLabels =
|
vm.selectedRenditionLabels =
|
||||||
if (checked) {
|
if (checked) {
|
||||||
vm.selectedRenditionLabels - label
|
vm.selectedRenditionLabels - label
|
||||||
@@ -457,34 +460,22 @@ private fun RenditionsCheckboxes(vm: NewHlsVideoViewModel) {
|
|||||||
vm.selectedRenditionLabels + label
|
vm.selectedRenditionLabels + label
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Checkbox(
|
Checkbox(
|
||||||
checked = checked,
|
checked = checked,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
vm.selectedRenditionLabels =
|
vm.selectedRenditionLabels =
|
||||||
if (it) vm.selectedRenditionLabels + label else vm.selectedRenditionLabels - label
|
if (it) vm.selectedRenditionLabels + label else vm.selectedRenditionLabels - label
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
color =
|
color =
|
||||||
if (enabled) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.onSurfaceVariant,
|
if (enabled) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
val subline =
|
|
||||||
if (aboveSource) {
|
|
||||||
stringResource(R.string.hls_rendition_above_source)
|
|
||||||
} else {
|
|
||||||
stringResource(R.string.hls_rendition_bitrate_kbps_format, rendition.bitrateKbps)
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
text = subline,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user