Skip to content

Commit 2bafa2c

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

File tree

1 file changed

+9
-2
lines changed
  • app/src/main/java/org/schabi/newpipe/ui/components/items

1 file changed

+9
-2
lines changed

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

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

3+
import androidx.compose.foundation.layout.height
4+
import androidx.compose.foundation.layout.size
35
import androidx.compose.foundation.lazy.LazyColumn
46
import androidx.compose.foundation.lazy.grid.GridCells
57
import androidx.compose.foundation.lazy.grid.GridItemSpan
@@ -28,6 +30,7 @@ import org.schabi.newpipe.R
2830
import org.schabi.newpipe.info_list.ItemViewMode
2931
import org.schabi.newpipe.ktx.findFragmentActivity
3032
import org.schabi.newpipe.ui.components.common.LazyColumnThemedScrollbar
33+
import org.schabi.newpipe.ui.components.common.LoadingIndicator
3134
import org.schabi.newpipe.ui.components.common.defaultThemedScrollbarSettings
3235
import org.schabi.newpipe.ui.components.items.playlist.PlaylistListItem
3336
import org.schabi.newpipe.ui.components.items.stream.StreamCardItem
@@ -85,12 +88,12 @@ fun ItemList(
8588
LazyVerticalGridScrollbar(state = state, settings = defaultThemedScrollbarSettings()) {
8689
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
8790
val isCompact = windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.COMPACT
88-
val minSize = if (isCompact) 150.dp else 250.dp
91+
val minWidth = if (isCompact) 150.dp else 250.dp
8992

9093
LazyVerticalGrid(
9194
modifier = nestedScrollModifier,
9295
state = state,
93-
columns = GridCells.Adaptive(minSize)
96+
columns = GridCells.Adaptive(minWidth)
9497
) {
9598
item(span = { GridItemSpan(maxLineSpan) }) {
9699
header()
@@ -106,6 +109,8 @@ fun ItemList(
106109
item, showProgress, isSelected, isCompact, onClick, onLongClick,
107110
onDismissPopup
108111
)
112+
} else if (item == null) { // Placeholder
113+
LoadingIndicator(Modifier.size(minWidth, if (isCompact) 150.dp else 200.dp))
109114
}
110115
}
111116
}
@@ -137,6 +142,8 @@ fun ItemList(
137142
}
138143
} else if (item is Playlist) {
139144
PlaylistListItem(item, onClick)
145+
} else if (item == null) { // Placeholder
146+
LoadingIndicator(Modifier.height(80.dp))
140147
}
141148
}
142149
}

0 commit comments

Comments
 (0)