Skip to content

Commit

Permalink
Display a loading indicator when fetching the next page (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored Dec 18, 2023
1 parent 57e6fe1 commit 580b7fa
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemKey
import androidx.tv.foundation.lazy.grid.TvGridCells
import androidx.tv.foundation.lazy.grid.TvGridItemSpan
import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.foundation.lazy.grid.itemsIndexed
import androidx.tv.foundation.lazy.grid.rememberTvLazyGridState
Expand Down Expand Up @@ -505,6 +506,19 @@ private fun <T : Content> ListsSectionContent(
}
}
}

if (items.loadState.append is LoadState.Loading) {
item(
contentType = "LoadingView",
span = { TvGridItemSpan(columnCount) }
) {
ListsSectionLoading(
modifier = modifier
.fillMaxSize()
.padding(MaterialTheme.paddings.baseline)
)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package ch.srgssr.pillarbox.demo.ui.integrationLayer
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
Expand Down Expand Up @@ -116,6 +117,16 @@ fun ContentListView(
}
}
}

if (items.loadState.append is LoadState.Loading) {
item(contentType = "LoadingView") {
LoadingView(
modifier = modifier
.fillMaxSize()
.padding(top = MaterialTheme.paddings.baseline)
)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ private fun SearchResultList(
}
}
}

if (items.loadState.append is LoadState.Loading) {
item(contentType = "LoadingView") {
LoadingView(
modifier = modifier
.fillMaxSize()
.padding(MaterialTheme.paddings.baseline)
)
}
}
}
}
}
Expand Down

0 comments on commit 580b7fa

Please sign in to comment.