Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

refactor(live): extract channel content states

David Nashash60df822019a1
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
index 257192e4..65c732b2 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt
@@ -1,7 +1,6 @@
package com.streamvault.app.ui.screens.home
import androidx.compose.material3.ExperimentalMaterial3Api
-import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyColumn
@@ -25,17 +24,12 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.foundation.focusGroup
import androidx.compose.ui.input.key.*
import androidx.compose.ui.input.key.onPreviewKeyEvent
-import androidx.compose.material.icons.filled.Lock
-import androidx.compose.material.icons.Icons
-import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.tv.material3.*
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.TextButton
-import androidx.compose.material3.CircularProgressIndicator
-import androidx.compose.material3.LinearProgressIndicator
import com.streamvault.core.ui.device.rememberIsTelevisionDevice
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
@@ -48,8 +42,8 @@ import com.streamvault.feature.live.home.HomeLoadingPane
import com.streamvault.feature.live.home.HomePreviewHost
import com.streamvault.feature.live.home.LiveChannelResultsHeader
import com.streamvault.feature.live.home.LiveCategorySidebarHeader
+import com.streamvault.feature.live.home.LiveChannelContentHost
import com.streamvault.feature.live.presentation.components.LiveChannelRowSurface
-import com.streamvault.core.ui.components.shell.StatusPill
import com.streamvault.core.ui.components.TvEmptyState
import com.streamvault.app.ui.components.dialogs.CategoryOptionsDialog
import com.streamvault.app.ui.components.dialogs.HiddenCategoriesDialog
@@ -82,11 +76,6 @@ import com.streamvault.app.navigation.Routes
import com.streamvault.domain.model.VirtualCategoryIds
import com.streamvault.domain.playback.archivePlaybackCapability
import com.streamvault.domain.repository.ChannelRepository
-import androidx.compose.ui.viewinterop.AndroidView
-import com.streamvault.player.PlayerSurfaceResizeMode
-import java.text.SimpleDateFormat
-import java.util.Date
-import java.util.Locale
import com.streamvault.app.ui.remote.LiveBrowseRemoteShortcutHandler
import com.streamvault.app.ui.remote.dispatchLiveBrowseRemoteShortcut
import com.streamvault.app.ui.remote.remoteColorButtonForKeyCode
@@ -848,92 +837,24 @@ fun HomeScreen(
animationSpec = tween(durationMillis = 200),
label = "category_content_transition"
) { _ ->
- if (uiState.isLoading) {
- Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(16.dp)
- ) {
- CircularProgressIndicator(color = Color.White)
- Text(
- text = stringResource(R.string.home_loading_channels),
- color = Color.White.copy(alpha = 0.7f),
- style = MaterialTheme.typography.bodyMedium
- )
- }
- }
- } else if (uiState.errorMessage != null) {
- val errorMsg = uiState.errorMessage
- Box(
- modifier = Modifier.fillMaxSize(),
- contentAlignment = Alignment.Center
- ) {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- Text(
- text = errorMsg ?: "",
- style = MaterialTheme.typography.titleMedium,
- color = OnBackground
- )
- }
- }
- } else if (!uiState.hasChannels) {
- Box(
- modifier = Modifier.fillMaxSize(),
- contentAlignment = Alignment.Center
- ) {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(6.dp)
- ) {
- if (hasBlockedCategorySearch) {
- Icon(
- imageVector = Icons.Filled.Lock,
- contentDescription = null,
- tint = OnBackground,
- modifier = Modifier.size(34.dp)
- )
- Text(
- text = stringResource(R.string.home_locked_short),
- style = MaterialTheme.typography.titleLarge,
- color = OnBackground
- )
- Text(
- text = stringResource(R.string.home_no_channels_found_subtitle),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- } else {
- Text(
- text = stringResource(R.string.home_no_channels_found),
- style = MaterialTheme.typography.titleLarge,
- color = OnBackground
- )
- Text(
- text = stringResource(R.string.home_no_channels_found_subtitle),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- val selectedCategory = uiState.selectedCategory
- if (selectedCategory?.isVirtual == true && selectedCategory.id == VirtualCategoryIds.FAVORITES) {
- Text(
- text = stringResource(R.string.home_add_favorites_hint),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- } else if (selectedCategory?.isVirtual == true && selectedCategory.id == VirtualCategoryIds.RECENT) {
- Text(
- text = stringResource(R.string.home_recent_channels_hint),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- }
+ val selectedCategory = uiState.selectedCategory
+ LiveChannelContentHost(
+ isLoading = uiState.isLoading,
+ errorMessage = uiState.errorMessage,
+ hasChannels = uiState.hasChannels,
+ isBlockedCategorySearch = hasBlockedCategorySearch,
+ loadingLabel = stringResource(R.string.home_loading_channels),
+ lockedLabel = stringResource(R.string.home_locked_short),
+ noChannelsLabel = stringResource(R.string.home_no_channels_found),
+ noChannelsSubtitle = stringResource(R.string.home_no_channels_found_subtitle),
+ additionalEmptyHint = when {
+ selectedCategory?.isVirtual == true && selectedCategory.id == VirtualCategoryIds.FAVORITES ->
+ stringResource(R.string.home_add_favorites_hint)
+ selectedCategory?.isVirtual == true && selectedCategory.id == VirtualCategoryIds.RECENT ->
+ stringResource(R.string.home_recent_channels_hint)
+ else -> null
}
- } else {
+ ) {
var ignoreNextClick by remember { mutableStateOf(false) }
val channelListState = rememberLazyListState()
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index ed9a6c0d..66620dba 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -131,8 +131,8 @@ the live boundary incrementally: `HomeViewModel`, the sidebar/preview surface,
the loading/preview host supporting composables, the live source switcher, Home
quick-filter panel/chip row, the reusable EPG guide shortcut chip, the shared
EPG guide-now ticker/provider, EPG search field/row, Home reorder top bar, and
-Home channel row surface, Home channel-results header, and the Home category
-sidebar header are now feature-owned while the Home and EPG
+Home channel row surface, Home channel-results header, Home category sidebar
+header, and channel-content state host are now feature-owned while the Home and EPG
screen/dialog composition remains in `:app`.
The source switcher receives localized labels from the app at the current
composition boundary. Live-owned
diff --git a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
index aefa65eb..5b92cb38 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -21,8 +21,8 @@ Status update (2026-08-29): `HomeViewModel`, the sidebar/preview surface, the
loading/preview host supporting composables, the live source switcher, Home
quick-filter panel/chip row, the reusable EPG guide shortcut chip, the shared
EPG guide-now ticker/provider, EPG search field/row, Home reorder top bar,
-Home channel row surface, Home channel-results header, and the Home category
-sidebar header are now feature-owned
+Home channel row surface, Home channel-results header, Home category sidebar
+header, and channel-content state host are now feature-owned
and their feature checks are green. Home screen/dialog composition, the
remaining live cards/rows, complete locale resource migration, and acceptance
gates remain open.
@@ -665,6 +665,9 @@ feature-owned `LiveSourceSwitcher`, `LiveQuickFiltersPanel` (including its
formatting/accessibility text through explicit presentation parameters. Home
also calls `LiveCategorySidebarHeader`, which owns source-switcher/search/
quick-filter layout while receiving app callbacks and localized labels. The
+channel content state now calls `LiveChannelContentHost` for loading, error,
+locked-empty, and no-channel presentation while keeping the channel-list slot
+in the app. The
quick-filter key/selection rules are covered by `LiveQuickFiltersTest`. The
remaining app-owned live cards and shell/dialog composition still require
compatibility seams before the full Home move.
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/home/LiveChannelContentHost.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveChannelContentHost.kt
new file mode 100644
index 00000000..850d0427
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveChannelContentHost.kt
@@ -0,0 +1,107 @@
+package com.streamvault.feature.live.home
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.size
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Lock
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import androidx.tv.material3.Icon
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Text
+import com.streamvault.core.ui.theme.OnBackground
+import com.streamvault.core.ui.theme.OnSurfaceDim
+
+@Composable
+fun LiveChannelContentHost(
+ isLoading: Boolean,
+ errorMessage: String?,
+ hasChannels: Boolean,
+ isBlockedCategorySearch: Boolean,
+ loadingLabel: String,
+ lockedLabel: String,
+ noChannelsLabel: String,
+ noChannelsSubtitle: String,
+ additionalEmptyHint: String? = null,
+ modifier: Modifier = Modifier,
+ channelContent: @Composable () -> Unit
+) {
+ Box(modifier = modifier.fillMaxSize()) {
+ when {
+ isLoading -> {
+ Column(
+ modifier = Modifier.align(Alignment.Center),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ CircularProgressIndicator(color = Color.White)
+ Text(
+ text = loadingLabel,
+ color = Color.White.copy(alpha = 0.7f),
+ style = MaterialTheme.typography.bodyMedium
+ )
+ }
+ }
+
+ errorMessage != null -> {
+ Text(
+ text = errorMessage,
+ modifier = Modifier.align(Alignment.Center),
+ style = MaterialTheme.typography.titleMedium,
+ color = OnBackground
+ )
+ }
+
+ !hasChannels -> {
+ Column(
+ modifier = Modifier.align(Alignment.Center),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(6.dp)
+ ) {
+ if (isBlockedCategorySearch) {
+ Icon(
+ imageVector = Icons.Filled.Lock,
+ contentDescription = null,
+ tint = OnBackground,
+ modifier = Modifier.size(34.dp)
+ )
+ Text(
+ text = lockedLabel,
+ style = MaterialTheme.typography.titleLarge,
+ color = OnBackground
+ )
+ } else {
+ Text(
+ text = noChannelsLabel,
+ style = MaterialTheme.typography.titleLarge,
+ color = OnBackground
+ )
+ }
+ Text(
+ text = noChannelsSubtitle,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ if (!isBlockedCategorySearch) {
+ additionalEmptyHint?.let { hint ->
+ Text(
+ text = hint,
+ style = MaterialTheme.typography.bodySmall,
+ color = OnSurfaceDim
+ )
+ }
+ }
+ }
+ }
+
+ else -> channelContent()
+ }
+ }
+}