Skip to content

Commit

Permalink
Use nested scroll modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Aug 10, 2024
1 parent 639451c commit c6ae703
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package org.schabi.newpipe.ui.components.items

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
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.res.stringResource
import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceManager
import androidx.window.core.layout.WindowWidthSizeClass
import my.nanihadesuka.compose.LazyColumnScrollbar
import org.schabi.newpipe.R
import org.schabi.newpipe.extractor.InfoItem
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem
Expand Down Expand Up @@ -62,29 +63,26 @@ fun ItemList(
}

val showProgress = DependentPreferenceHelper.getPositionsInListsEnabled(context)
val nestedScrollModifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection())

if (mode == ItemViewMode.GRID) {
// TODO: Implement grid layout using LazyVerticalGrid and LazyVerticalGridScrollbar.
} else {
// Card or list views
val listState = rememberLazyListState()
LazyColumn(modifier = nestedScrollModifier) {
listHeader()

LazyColumnScrollbar(state = listState) {
LazyColumn(state = listState) {
listHeader()
items(items.size) {
val item = items[it]

items(items.size) {
val item = items[it]

// TODO: Implement card layouts.
if (item is StreamInfoItem) {
val isSelected = selectedStream == item
StreamListItem(
item, showProgress, isSelected, onClick, onLongClick, onDismissPopup
)
} else if (item is PlaylistInfoItem) {
PlaylistListItem(item, onClick)
}
// TODO: Implement card layouts.
if (item is StreamInfoItem) {
val isSelected = selectedStream == item
StreamListItem(
item, showProgress, isSelected, onClick, onLongClick, onDismissPopup
)
} else if (item is PlaylistInfoItem) {
PlaylistListItem(item, onClick)
}
}
}
Expand Down

0 comments on commit c6ae703

Please sign in to comment.