From 6c64470c28e9ea7d549c8c67734cbdbbb8b7f20d Mon Sep 17 00:00:00 2001 From: Damontecres Date: Sat, 30 May 2026 17:41:44 -0400 Subject: [PATCH] Only show view more card if row has more items (#1493) ## Description Only show the view more card at the end of row if there are actually more items (or at the limit). Also reduces the size of the arrow a bit ### Related issues Related to #1392 ### Testing Emulator with different max items setting ## Screenshots N/A ## AI or LLM usage None --- .../wholphin/services/HomeSettingsService.kt | 23 ++++++++++++++----- .../wholphin/ui/cards/ViewMoreCard.kt | 7 ++++-- .../ui/components/RecommendedContent.kt | 10 +++++++- .../detail/collection/CollectionViewModel.kt | 6 ++++- .../damontecres/wholphin/ui/main/HomePage.kt | 2 +- .../damontecres/wholphin/util/LoadingState.kt | 1 + 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt b/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt index 50c8ae83..da0a7ab6 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt @@ -592,6 +592,7 @@ class HomeSettingsService items = resume, viewOptions = row.viewOptions, rowType = row, + showViewMore = resume.size >= limit, ) } @@ -611,6 +612,7 @@ class HomeSettingsService items = nextUp, viewOptions = row.viewOptions, rowType = row, + showViewMore = nextUp.size >= limit, ) } @@ -631,17 +633,14 @@ class HomeSettingsService prefs.maxDaysNextUp, row.viewOptions.useSeries, ) + val combined = latestNextUpService.buildCombined(resume, nextUp) Success( title = ResStringProvider(R.string.continue_watching), - items = - latestNextUpService - .buildCombined( - resume, - nextUp, - ).take(limit), + items = combined.take(limit), viewOptions = row.viewOptions, rowType = row, + showViewMore = combined.size >= limit, ) } @@ -705,6 +704,7 @@ class HomeSettingsService genres, viewOptions = row.viewOptions, rowType = row, + showViewMore = genres.size >= limit, ) } @@ -756,6 +756,7 @@ class HomeSettingsService title, studios, viewOptions = row.viewOptions, + showViewMore = studios.size >= limit, ) } @@ -784,6 +785,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } latest @@ -838,6 +840,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -891,6 +894,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -928,6 +932,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -957,6 +962,7 @@ class HomeSettingsService title, it, row.viewOptions, + showViewMore = it.size >= limit, ) } } else { @@ -988,6 +994,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -1023,6 +1030,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -1049,6 +1057,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -1079,6 +1088,7 @@ class HomeSettingsService it, row.viewOptions, rowType = row, + showViewMore = it.size >= limit, ) } } @@ -1111,6 +1121,7 @@ class HomeSettingsService suggestions.items, row.viewOptions, rowType = row, + showViewMore = suggestions.items.size >= limit, ) } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/cards/ViewMoreCard.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/cards/ViewMoreCard.kt index 56748473..32265e70 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/cards/ViewMoreCard.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/cards/ViewMoreCard.kt @@ -95,12 +95,15 @@ fun ViewMoreCard( containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp), ), ) { - Box { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.fillMaxSize(), + ) { Icon( imageVector = Icons.Default.ArrowForward, tint = MaterialTheme.colorScheme.onSurface, contentDescription = "View more", - modifier = Modifier.fillMaxSize(), + modifier = Modifier.fillMaxSize(.66f), ) } } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt index 88e86197..dd264d0f 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/components/RecommendedContent.kt @@ -120,10 +120,12 @@ class RecommendedViewModel viewModelScope.launchIO { val result = try { + val items = execute(row, limit) HomeRowLoadingState.Success( title, - execute(row, limit), + items, viewOptions, + showViewMore = items.size >= limit, ) } catch (ex: Exception) { Timber.e(ex, "Exception fetching %s", title) @@ -172,6 +174,10 @@ class RecommendedViewModel private fun fetchSuggestions() { viewModelScope.launch(Dispatchers.IO) { + val limit = + userPreferencesService + .getCurrent() + .appPreferences.homePagePreferences.maxItemsPerRow val title = ResStringProvider(R.string.suggestions) try { suggestionService @@ -188,6 +194,7 @@ class RecommendedViewModel title, resource.items, viewOptions, + showViewMore = resource.items.size >= limit, ) } @@ -196,6 +203,7 @@ class RecommendedViewModel title, emptyList(), viewOptions, + showViewMore = false, ) } } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionViewModel.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionViewModel.kt index f5cbd741..0cc58bea 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionViewModel.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/collection/CollectionViewModel.kt @@ -214,7 +214,11 @@ class CollectionViewModel val result = try { val pager = fetchItems(sort, filter, listOf(type)) - HomeRowLoadingState.Success(title, pager) + HomeRowLoadingState.Success( + title, + pager, + showViewMore = false, + ) } catch (ex: Exception) { Timber.e( ex, diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt index 098da3e2..1ccfb429 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt @@ -472,7 +472,7 @@ fun HomePageContent( .onKeyEvent { onKey(it) }, ) }, - showViewMore = showViewMore, + showViewMore = showViewMore && row.showViewMore, viewMoreCardContent = { mod -> HomePageViewMoreCard( isEpisode = row.items.last()?.type == BaseItemKind.EPISODE, diff --git a/app/src/main/java/com/github/damontecres/wholphin/util/LoadingState.kt b/app/src/main/java/com/github/damontecres/wholphin/util/LoadingState.kt index f42eb6ac..7c618290 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/util/LoadingState.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/util/LoadingState.kt @@ -67,6 +67,7 @@ sealed interface HomeRowLoadingState { val items: List, val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), val rowType: HomeRowConfig? = null, + val showViewMore: Boolean = true, ) : HomeRowLoadingState data class Error(