Skip to content

Commit fbbc60b

Browse files
Add loading indicator in ItemList
1 parent 033d288 commit fbbc60b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • app/src/main/java/org/schabi/newpipe/ui/components/items

app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.ui.components.items
22

3+
import androidx.compose.foundation.layout.size
34
import androidx.compose.foundation.lazy.LazyColumn
45
import androidx.compose.foundation.lazy.grid.GridCells
56
import androidx.compose.foundation.lazy.grid.GridItemSpan
@@ -28,6 +29,7 @@ import org.schabi.newpipe.R
2829
import org.schabi.newpipe.info_list.ItemViewMode
2930
import org.schabi.newpipe.ktx.findFragmentActivity
3031
import org.schabi.newpipe.ui.components.common.LazyColumnThemedScrollbar
32+
import org.schabi.newpipe.ui.components.common.LoadingIndicator
3133
import org.schabi.newpipe.ui.components.common.defaultThemedScrollbarSettings
3234
import org.schabi.newpipe.ui.components.items.playlist.PlaylistListItem
3335
import org.schabi.newpipe.ui.components.items.stream.StreamCardItem
@@ -85,12 +87,12 @@ fun ItemList(
8587
LazyVerticalGridScrollbar(state = state, settings = defaultThemedScrollbarSettings()) {
8688
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
8789
val isCompact = windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.COMPACT
88-
val minSize = if (isCompact) 150.dp else 250.dp
90+
val minWidth = if (isCompact) 150.dp else 250.dp
8991

9092
LazyVerticalGrid(
9193
modifier = nestedScrollModifier,
9294
state = state,
93-
columns = GridCells.Adaptive(minSize)
95+
columns = GridCells.Adaptive(minWidth)
9496
) {
9597
item(span = { GridItemSpan(maxLineSpan) }) {
9698
header()
@@ -106,6 +108,8 @@ fun ItemList(
106108
item, showProgress, isSelected, isCompact, onClick, onLongClick,
107109
onDismissPopup
108110
)
111+
} else if (item == null) { // Placeholder
112+
LoadingIndicator(Modifier.size(minWidth, if (isCompact) 100.dp else 150.dp))
109113
}
110114
}
111115
}
@@ -137,6 +141,8 @@ fun ItemList(
137141
}
138142
} else if (item is Playlist) {
139143
PlaylistListItem(item, onClick)
144+
} else if (item == null) { // Placeholder
145+
LoadingIndicator()
140146
}
141147
}
142148
}

0 commit comments

Comments
 (0)