Skip to content

Commit

Permalink
[Jetcaster] Touch up the TV UI (#1432)
Browse files Browse the repository at this point in the history
Fix podcast art padding
Fix clipping on podcast screen
Fix navigation transition jumping around
  • Loading branch information
bentrengrove authored Jul 16, 2024
2 parents 696c1b0 + 8f05627 commit 594649b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
JetcasterTheme {
// TV is hardcoded to dark mode to match TV ui
JetcasterTheme(isInDarkTheme = true) {
Surface(
modifier = Modifier.fillMaxSize(),
shape = RectangleShape
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ private fun Route(jetcasterAppState: JetcasterAppState) {
composable(Screen.Profile.route) {
ProfileScreen(
modifier = Modifier
.fillMaxSize()
.padding(JetcasterAppDefaults.overScanMargin.default.intoPaddingValues())
)
}

composable(Screen.Settings.route) {
SettingsScreen(
modifier = Modifier
.fillMaxSize()
.padding(JetcasterAppDefaults.overScanMargin.default.intoPaddingValues())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Card
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.CardScale
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
Expand Down Expand Up @@ -73,6 +75,7 @@ private fun EpisodeThumbnail(
onClick = onClick,
interactionSource = interactionSource,
scale = CardScale.None,
shape = CardDefaults.shape(RoundedCornerShape(12.dp)),
modifier = modifier,
) {
Thumbnail(episode = playerEpisode, size = JetcasterAppDefaults.thumbnailSize.episode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package com.example.jetcaster.tv.ui.component

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Card
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.CardScale
import androidx.tv.material3.StandardCardContainer
import androidx.tv.material3.Text
Expand All @@ -39,6 +41,7 @@ internal fun PodcastCard(
onClick = onClick,
interactionSource = it,
scale = CardScale.None,
shape = CardDefaults.shape(RoundedCornerShape(12.dp))
) {
Thumbnail(
podcastInfo = podcastInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -52,16 +53,18 @@ fun EpisodeScreen(

val uiState by episodeScreenViewModel.uiStateFlow.collectAsState()

val screenModifier = modifier.fillMaxSize()
when (val s = uiState) {
EpisodeScreenUiState.Loading -> Loading(modifier = modifier)
EpisodeScreenUiState.Error -> ErrorState(backToHome = backToHome, modifier = modifier)
EpisodeScreenUiState.Loading -> Loading(modifier = screenModifier)
EpisodeScreenUiState.Error -> ErrorState(backToHome = backToHome, modifier = screenModifier)
is EpisodeScreenUiState.Ready -> EpisodeDetailsWithBackground(
playerEpisode = s.playerEpisode,
playEpisode = {
episodeScreenViewModel.play(it)
playEpisode()
},
addPlayList = episodeScreenViewModel::addPlayList
addPlayList = episodeScreenViewModel::addPlayList,
modifier = screenModifier
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ private fun PodcastDetailsWithBackground(
enqueue = enqueue,
modifier = Modifier
.fillMaxSize()
.padding(JetcasterAppDefaults.overScanMargin.podcast.intoPaddingValues())
)
}
}
Expand Down Expand Up @@ -157,7 +156,12 @@ private fun PodcastDetails(
isSubscribed = isSubscribed,
subscribe = subscribe,
unsubscribe = unsubscribe,
modifier = Modifier.weight(0.3f),
modifier = Modifier
.weight(0.3f)
.padding(
JetcasterAppDefaults.overScanMargin.podcast.copy(end = 0.dp)
.intoPaddingValues()
),
)
},
second = {
Expand Down Expand Up @@ -258,7 +262,8 @@ private fun PodcastEpisodeList(
) {
TvLazyColumn(
verticalArrangement = Arrangement.spacedBy(JetcasterAppDefaults.gap.podcastRow),
modifier = modifier
modifier = modifier,
contentPadding = JetcasterAppDefaults.overScanMargin.podcast.intoPaddingValues()
) {
items(episodeList) {
EpisodeListItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal data class OverScanMarginSettings(
val default: OverScanMargin = OverScanMargin(),
val catalog: OverScanMargin = OverScanMargin(end = 0.dp),
val episode: OverScanMargin = OverScanMargin(start = 80.dp, end = 80.dp),
val drawer: OverScanMargin = OverScanMargin(start = 0.dp, end = 0.dp),
val drawer: OverScanMargin = OverScanMargin(start = 16.dp, end = 16.dp),
val podcast: OverScanMargin = OverScanMargin(
top = 40.dp,
bottom = 40.dp,
Expand Down

0 comments on commit 594649b

Please sign in to comment.