Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions app/src/main/kotlin/com/arflix/tv/ui/components/MediaCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ fun MediaCard(
PlaceholderCard(
width = width,
isLandscape = isLandscape,
showTitle = showTitle,
modifier = modifier
)
return
Expand Down Expand Up @@ -522,6 +523,7 @@ fun MediaCard(
private fun PlaceholderCard(
width: Dp,
isLandscape: Boolean,
showTitle: Boolean = true,
modifier: Modifier = Modifier
) {
val aspectRatio = if (isLandscape) 16f / 9f else 2f / 3f
Expand All @@ -542,25 +544,27 @@ private fun PlaceholderCard(
)
}

Spacer(modifier = Modifier.height(ArvioSkin.spacing.x2))
if (showTitle) {
Spacer(modifier = Modifier.height(ArvioSkin.spacing.x2))

// Title skeleton
SkeletonBox(
modifier = Modifier
.fillMaxWidth(0.7f)
.height(14.dp)
.clip(rememberArvioCardShape(ArvioSkin.radius.sm))
)
// Title skeleton
SkeletonBox(
modifier = Modifier
.fillMaxWidth(0.7f)
.height(14.dp)
.clip(rememberArvioCardShape(ArvioSkin.radius.sm))
)

Spacer(modifier = Modifier.height(4.dp))
Spacer(modifier = Modifier.height(4.dp))

// Subtitle skeleton
SkeletonBox(
modifier = Modifier
.fillMaxWidth(0.5f)
.height(12.dp)
.clip(rememberArvioCardShape(ArvioSkin.radius.sm))
)
// Subtitle skeleton
SkeletonBox(
modifier = Modifier
.fillMaxWidth(0.5f)
.height(12.dp)
.clip(rememberArvioCardShape(ArvioSkin.radius.sm))
)
}
}
}

Expand All @@ -585,6 +589,7 @@ fun PosterCard(
PlaceholderCard(
width = width,
isLandscape = false,
showTitle = false,
modifier = modifier
)
return
Expand Down
51 changes: 47 additions & 4 deletions app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,29 @@ private fun MobileHomeRowsLayer(
} else {
rowUsePosterCards
}
val itemsToRender = category.items
val itemsToRender = remember(category.items, rowHasMore, isPortrait) {
if (category.items.isEmpty()) {
(1..8).map { index ->
MediaItem(
id = -index,
title = "",
mediaType = MediaType.MOVIE,
isPlaceholder = true
)
}
} else if (rowHasMore) {
val skeletonCount = if (isPortrait) 12 else 7
category.items + List(skeletonCount) { idx ->
MediaItem(
id = -1000 - idx,
title = "",
isPlaceholder = true
)
}
} else {
category.items
}
}

// Horizontal card row with touch scrolling
LazyRow(
Expand Down Expand Up @@ -3325,7 +3347,30 @@ private fun ContentRow(
val cardAspectRatio = if (effectivePosterMode) 2f / 3f else 16f / 9f
val itemWidth = if (effectivePosterMode) 105.dp else 210.dp
val itemSpacing = 14.dp
val totalItems = category.items.size
val itemsToRender = remember(category.items, effectiveCategoryHasMore, effectivePosterMode) {
if (category.items.isEmpty()) {
(1..8).map { index ->
MediaItem(
id = -index,
title = "",
mediaType = MediaType.MOVIE,
isPlaceholder = true
)
}
} else if (effectiveCategoryHasMore) {
val skeletonCount = if (effectivePosterMode) 12 else 7
category.items + List(skeletonCount) { idx ->
MediaItem(
id = -1000 - idx,
title = "",
isPlaceholder = true
)
}
} else {
category.items
}
}
val totalItems = itemsToRender.size
val maxFirstIndex = remember(totalItems) {
(totalItems - 1).coerceAtLeast(0)
}
Expand Down Expand Up @@ -3483,8 +3528,6 @@ private fun ContentRow(
)
}

val itemsToRender = category.items

// Cards row - clipped to hide previous items when scrolling
val clipModifier = if (isContinueWatching) Modifier else Modifier.clipToBounds()
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2912,11 +2912,8 @@ class HomeViewModel @Inject constructor(
_uiState.value = _uiState.value.copy(categoryHasMoreMap = hasMoreMap)
}

private fun buildProfileSkeletonCategories(
savedCatalogs: List<com.arflix.tv.data.model.CatalogConfig>,
cachedContinueWatching: List<ContinueWatchingItem>
): List<Category> {
val placeholderItems = (1..HOME_PLACEHOLDER_ITEM_COUNT).map { index ->
private fun createPlaceholderItems(count: Int = HOME_PLACEHOLDER_ITEM_COUNT): List<MediaItem> =
(1..count).map { index ->
MediaItem(
id = -index,
title = "",
Expand All @@ -2925,6 +2922,12 @@ class HomeViewModel @Inject constructor(
)
}

private fun buildProfileSkeletonCategories(
savedCatalogs: List<com.arflix.tv.data.model.CatalogConfig>,
cachedContinueWatching: List<ContinueWatchingItem>
): List<Category> {
val placeholderItems = createPlaceholderItems()

val rows = mutableListOf<Category>()
if (cachedContinueWatching.isNotEmpty()) {
rows.add(
Expand Down
Loading