fix(player): Make chapters sheet scrollable + adjust stream sheet scrolling (#1212)

This commit is contained in:
Abdallah 2023-11-24 18:22:52 +01:00 committed by GitHub
parent 00fb0a740b
commit adb571fcbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 21 deletions

View file

@ -68,24 +68,26 @@ fun StreamsCatalogSheet(
Column( Column(
modifier = Modifier modifier = Modifier
.padding(contentPadding) .padding(contentPadding)
.padding(vertical = TabbedDialogPaddings.Vertical) .padding(vertical = TabbedDialogPaddings.Vertical),
.verticalScroll(rememberScrollState()),
) { ) {
@Composable fun QualityTracksPage() = StreamsPageBuilder( @Composable
fun QualityTracksPage() = StreamsPageBuilder(
externalTrackCode = null, externalTrackCode = null,
stream = videoStreams.quality, stream = videoStreams.quality,
openContentFd = openContentFd, openContentFd = openContentFd,
onTrackSelected = onQualitySelected, onTrackSelected = onQualitySelected,
) )
@Composable fun SubtitleTracksPage() = StreamsPageBuilder( @Composable
fun SubtitleTracksPage() = StreamsPageBuilder(
externalTrackCode = "sub", externalTrackCode = "sub",
stream = videoStreams.subtitle, stream = videoStreams.subtitle,
openContentFd = openContentFd, openContentFd = openContentFd,
onTrackSelected = onSubtitleSelected, onTrackSelected = onSubtitleSelected,
) )
@Composable fun AudioTracksPage() = StreamsPageBuilder( @Composable
fun AudioTracksPage() = StreamsPageBuilder(
externalTrackCode = "audio", externalTrackCode = "audio",
stream = videoStreams.audio, stream = videoStreams.audio,
openContentFd = openContentFd, openContentFd = openContentFd,
@ -167,22 +169,28 @@ private fun StreamsPageBuilder(
} }
} }
tracks.forEachIndexed { i, track -> Column(
val selected = index == i modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState()),
) {
tracks.forEachIndexed { i, track ->
val selected = index == i
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clickable(onClick = { onSelected(i) }) .clickable(onClick = { onSelected(i) })
.padding(sheetDialogPadding), .padding(sheetDialogPadding),
) { ) {
Text( Text(
text = track.lang, text = track.lang,
fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal, fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal,
fontStyle = if (selected) FontStyle.Italic else FontStyle.Normal, fontStyle = if (selected) FontStyle.Italic else FontStyle.Normal,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = if (selected) MaterialTheme.colorScheme.primary else Color.Unspecified, color = if (selected) MaterialTheme.colorScheme.primary else Color.Unspecified,
) )
}
} }
} }
} }

View file

@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -40,7 +42,9 @@ fun VideoChaptersSheet(
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
) { ) {
Column( Column(
modifier = Modifier.padding(MaterialTheme.padding.medium), modifier = Modifier
.padding(MaterialTheme.padding.medium)
.verticalScroll(rememberScrollState()),
) { ) {
Text( Text(
text = stringResource(id = R.string.chapter_dialog_header), text = stringResource(id = R.string.chapter_dialog_header),