Skip to content

Commit

Permalink
add preview
Browse files Browse the repository at this point in the history
  • Loading branch information
AliAsadi committed Jul 2, 2024
1 parent 7a30f14 commit 8765423
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ fun FavoritesScreen(
val isLoading = favoriteUiState.isLoading
val noDataAvailable = favoriteUiState.noDataAvailable

MovieList(movies = movies, onMovieClick = onMovieClick)

if (isLoading) {
LoaderFullScreen()
} else {
Expand All @@ -71,6 +69,8 @@ fun FavoritesScreen(
title = stringResource(id = R.string.no_favorite_movies_title),
subtitle = stringResource(id = R.string.no_favorite_movies_subtitle)
)
} else {
MovieList(movies = movies, onMovieClick = onMovieClick)
}
}
}
Expand All @@ -79,7 +79,7 @@ fun FavoritesScreen(
@Preview(showSystemUi = true, name = "Light")
@Preview(showSystemUi = true, name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun FavoritesScreenPreview() {
private fun FavoritesScreenPreview() {
val movieItems: List<MovieListItem> = listOf(
MovieListItem.Separator("Action"),
MovieListItem.Movie(1, "image1.jpg", "Action"),
Expand All @@ -88,6 +88,18 @@ fun FavoritesScreenPreview() {
MovieListItem.Movie(3, "image3.jpg", "Drama")
)

PreviewContainer {
val movies = flowOf(PagingData.from(movieItems)).collectAsLazyPagingItems()
FavoritesScreen(FavoriteUiState(isLoading = false, noDataAvailable = false), movies) {}
}
}

@Preview(showSystemUi = true, name = "Light")
@Preview(showSystemUi = true, name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun FavoritesScreenNoDataPreview() {
val movieItems: List<MovieListItem> = listOf(MovieListItem.Movie(1, "image1.jpg", "Action"))

PreviewContainer {
val movies = flowOf(PagingData.from(movieItems)).collectAsLazyPagingItems()
FavoritesScreen(FavoriteUiState(isLoading = false, noDataAvailable = true), movies) {}
Expand Down

0 comments on commit 8765423

Please sign in to comment.