Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@
<string name="tv_banner_discover_more_title">You haven\'t seen the half of it</string>
<string name="tv_banner_discover_more_subtitle">Your next obsession is in here somewhere</string>
<string name="tv_banner_discover_more_action_title">Discover more shows</string>
<string name="tv_search_prompt">Podcasts, shows, authors</string>
<string name="tv_search_recent">Recent searches</string>
<string name="tv_search_featured">Featured</string>
<string name="tv_search_searching">Searching…</string>
<string name="tv_search_no_results_title">No results</string>
<string name="tv_search_no_results_for_title">No results for \“%1$s\”</string>
<string name="tv_search_no_results_subtitle">Try more general or different keywords.</string>
<string name="tv_search_error_subtitle">Check your connection and try again.</string>
<string name="tv_profile_starred_episodes">Starred Episodes</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ sealed interface ImprovedSearchResultItem {
val podcastTitle: String,
val publishedDate: Date,
val duration: Duration,
val hasVideo: Boolean = false,
) : ImprovedSearchResultItem
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ImprovedSearchManagerImpl @Inject constructor(
podcastTitle = it.podcastTitle,
publishedDate = it.publishedDate,
duration = it.duration.seconds,
hasVideo = it.hasVideo,
)

CombinedResult.Unknown -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ sealed interface CombinedResult {
val podcastTitle: String,
@Json(name = "podcast_slug")
val podcastSlug: String = "",
@Json(name = "has_video")
val hasVideo: Boolean = false,
) : CombinedResult

data object Unknown : CombinedResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ import au.com.shiftyjelly.pocketcasts.theme.tvTypography
import java.util.Date
import kotlin.time.Duration.Companion.seconds

@Composable
internal fun TvSearchEpisodeRow(
episode: ImprovedSearchResultItem.EpisodeItem,
onClick: () -> Unit,
onOpenActions: () -> Unit,
modifier: Modifier = Modifier,
episodeFocusRequester: FocusRequester? = null,
) {
TvEpisodeListItemContainer(
onOpenActions = onOpenActions,
modifier = modifier,
) { rowModifier ->
TvSearchEpisodeCard(
episode = episode,
onClick = onClick,
modifier = rowModifier
.then(if (episodeFocusRequester != null) Modifier.focusRequester(episodeFocusRequester) else Modifier),
)
}
}

@Composable
internal fun TvSearchEpisodeCard(
episode: ImprovedSearchResultItem.EpisodeItem,
Expand Down Expand Up @@ -139,10 +118,10 @@ internal fun TvSearchEpisodeCard(

@Preview(device = Devices.TV_1080p)
@Composable
private fun TvSearchEpisodeRowPreview() {
private fun TvSearchEpisodeCardPreview() {
TvTheme {
Box(modifier = Modifier.background(MaterialTheme.tvColors.backgroundSunken).padding(48.dp)) {
TvSearchEpisodeRow(
TvSearchEpisodeCard(
episode = ImprovedSearchResultItem.EpisodeItem(
uuid = "episode-1",
title = "The real cost of sugar and how it shapes the food we eat",
Expand All @@ -152,7 +131,6 @@ private fun TvSearchEpisodeRowPreview() {
duration = 1440.seconds,
),
onClick = {},
onOpenActions = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -57,15 +58,18 @@ internal fun TvSearchField(
query: String,
onQueryChange: (String) -> Unit,
modifier: Modifier = Modifier,
onEditingChange: (Boolean) -> Unit = {},
) {
var editing by remember { mutableStateOf(false) }
var restoreRestFocus by remember { mutableStateOf(false) }
val fieldFocusRequester = remember { FocusRequester() }
val restFocusRequester = remember { FocusRequester() }
val focusManager = LocalFocusManager.current
val keyboardController = LocalSoftwareKeyboardController.current
val currentOnEditingChange by rememberUpdatedState(onEditingChange)

LaunchedEffect(editing) {
currentOnEditingChange(editing)
if (editing) {
runCatching { fieldFocusRequester.requestFocus() }
keyboardController?.show()
Expand Down Expand Up @@ -175,7 +179,7 @@ private fun TvSearchFieldContent(
Box(contentAlignment = Alignment.CenterStart) {
if (query.isEmpty()) {
Text(
text = stringResource(LR.string.search),
text = stringResource(LR.string.tv_search_prompt),
style = MaterialTheme.tvTypography.title3,
color = MaterialTheme.tvColors.textSecondary,
)
Expand Down
Loading