mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-10 01:10:33 +00:00
Allow scrolling of about channel section
This commit is contained in:
parent
387a4d5f56
commit
bc87575410
@ -2,59 +2,70 @@ package org.schabi.newpipe.ui.components.channel
|
|||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import my.nanihadesuka.compose.LazyColumnScrollbar
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.extractor.Image
|
import org.schabi.newpipe.extractor.Image
|
||||||
import org.schabi.newpipe.extractor.Image.ResolutionLevel
|
import org.schabi.newpipe.extractor.Image.ResolutionLevel
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor
|
import org.schabi.newpipe.extractor.stream.StreamExtractor
|
||||||
import org.schabi.newpipe.ui.components.metadata.ImageMetadataItem
|
|
||||||
import org.schabi.newpipe.ui.components.metadata.MetadataItem
|
import org.schabi.newpipe.ui.components.metadata.MetadataItem
|
||||||
import org.schabi.newpipe.ui.components.metadata.TagsSection
|
import org.schabi.newpipe.ui.components.metadata.TagsSection
|
||||||
|
import org.schabi.newpipe.ui.components.metadata.imageMetadataItem
|
||||||
import org.schabi.newpipe.ui.theme.AppTheme
|
import org.schabi.newpipe.ui.theme.AppTheme
|
||||||
import org.schabi.newpipe.util.Localization
|
import org.schabi.newpipe.util.Localization
|
||||||
import org.schabi.newpipe.util.NO_SERVICE_ID
|
import org.schabi.newpipe.util.NO_SERVICE_ID
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AboutChannelSection(channelInfo: ParcelableChannelInfo) {
|
fun AboutChannelSection(channelInfo: ParcelableChannelInfo) {
|
||||||
// This tab currently holds little information, so a lazy column isn't needed here.
|
val (serviceId, description, count, avatars, banners, tags) = channelInfo
|
||||||
Column(
|
val lazyListState = rememberLazyListState()
|
||||||
modifier = Modifier.padding(12.dp),
|
|
||||||
|
LazyColumnScrollbar(state = lazyListState) {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(12.dp)
|
||||||
|
.nestedScroll(rememberNestedScrollInteropConnection()),
|
||||||
|
state = lazyListState,
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
val (serviceId, description, count, avatars, banners, tags) = channelInfo
|
|
||||||
|
|
||||||
if (description.isNotEmpty()) {
|
if (description.isNotEmpty()) {
|
||||||
|
item {
|
||||||
Text(text = description)
|
Text(text = description)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count != StreamExtractor.UNKNOWN_SUBSCRIBER_COUNT) {
|
if (count != StreamExtractor.UNKNOWN_SUBSCRIBER_COUNT) {
|
||||||
|
item {
|
||||||
MetadataItem(
|
MetadataItem(
|
||||||
title = R.string.metadata_subscribers,
|
title = R.string.metadata_subscribers,
|
||||||
value = Localization.shortCount(LocalContext.current, count)
|
value = Localization.shortCount(LocalContext.current, count)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatars.isNotEmpty()) {
|
|
||||||
ImageMetadataItem(R.string.metadata_avatars, avatars)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (banners.isNotEmpty()) {
|
imageMetadataItem(R.string.metadata_avatars, avatars)
|
||||||
ImageMetadataItem(R.string.metadata_banners, banners)
|
|
||||||
}
|
imageMetadataItem(R.string.metadata_banners, banners)
|
||||||
|
|
||||||
if (tags.isNotEmpty()) {
|
if (tags.isNotEmpty()) {
|
||||||
|
item {
|
||||||
TagsSection(serviceId, tags)
|
TagsSection(serviceId, tags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||||
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.ui.components.metadata
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -32,6 +33,14 @@ fun ImageMetadataItem(@StringRes title: Int, images: List<Image>) {
|
|||||||
MetadataItem(title = title, value = imageLinks)
|
MetadataItem(title = title, value = imageLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun LazyListScope.imageMetadataItem(@StringRes title: Int, images: List<Image>) {
|
||||||
|
if (images.isNotEmpty()) {
|
||||||
|
item {
|
||||||
|
ImageMetadataItem(title, images)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun convertImagesToLinks(context: Context, images: List<Image>): AnnotatedString {
|
private fun convertImagesToLinks(context: Context, images: List<Image>): AnnotatedString {
|
||||||
val preferredUrl = ImageStrategy.choosePreferredImage(images)
|
val preferredUrl = ImageStrategy.choosePreferredImage(images)
|
||||||
|
|
||||||
|
@ -45,16 +45,15 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import my.nanihadesuka.compose.LazyColumnScrollbar
|
import my.nanihadesuka.compose.LazyColumnScrollbar
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.extractor.Image
|
|
||||||
import org.schabi.newpipe.extractor.localization.DateWrapper
|
import org.schabi.newpipe.extractor.localization.DateWrapper
|
||||||
import org.schabi.newpipe.extractor.stream.Description
|
import org.schabi.newpipe.extractor.stream.Description
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor
|
import org.schabi.newpipe.extractor.stream.StreamExtractor
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo
|
import org.schabi.newpipe.extractor.stream.StreamInfo
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType
|
import org.schabi.newpipe.extractor.stream.StreamType
|
||||||
import org.schabi.newpipe.ui.components.common.DescriptionText
|
import org.schabi.newpipe.ui.components.common.DescriptionText
|
||||||
import org.schabi.newpipe.ui.components.metadata.ImageMetadataItem
|
|
||||||
import org.schabi.newpipe.ui.components.metadata.MetadataItem
|
import org.schabi.newpipe.ui.components.metadata.MetadataItem
|
||||||
import org.schabi.newpipe.ui.components.metadata.TagsSection
|
import org.schabi.newpipe.ui.components.metadata.TagsSection
|
||||||
|
import org.schabi.newpipe.ui.components.metadata.imageMetadataItem
|
||||||
import org.schabi.newpipe.ui.theme.AppTheme
|
import org.schabi.newpipe.ui.theme.AppTheme
|
||||||
import org.schabi.newpipe.util.Localization
|
import org.schabi.newpipe.util.Localization
|
||||||
import org.schabi.newpipe.util.NO_SERVICE_ID
|
import org.schabi.newpipe.util.NO_SERVICE_ID
|
||||||
@ -210,14 +209,6 @@ private fun LazyListScope.metadataItem(@StringRes title: Int, value: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LazyListScope.imageMetadataItem(@StringRes title: Int, images: List<Image>) {
|
|
||||||
if (images.isNotEmpty()) {
|
|
||||||
item {
|
|
||||||
ImageMetadataItem(title, images)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||||
@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES)
|
@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||||
@Composable
|
@Composable
|
||||||
|
Loading…
Reference in New Issue
Block a user