diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt index 71180969a8b..381fa681cce 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/channel/AboutChannelSection.kt @@ -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) + } + } } } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/metadata/ImageMetadataItem.kt b/app/src/main/java/org/schabi/newpipe/ui/components/metadata/ImageMetadataItem.kt index 8d282c2345e..86ea5e6c7a0 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/metadata/ImageMetadataItem.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/metadata/ImageMetadataItem.kt @@ -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) { MetadataItem(title = title, value = imageLinks) } +fun LazyListScope.imageMetadataItem(@StringRes title: Int, images: List) { + if (images.isNotEmpty()) { + item { + ImageMetadataItem(title, images) + } + } +} + private fun convertImagesToLinks(context: Context, images: List): AnnotatedString { val preferredUrl = ImageStrategy.choosePreferredImage(images) diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/VideoDescriptionSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/VideoDescriptionSection.kt index 62d4c1dc563..a4bbee9c654 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/VideoDescriptionSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/VideoDescriptionSection.kt @@ -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) { - 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