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