Skip to content

Commit

Permalink
PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
arriolac committed Mar 30, 2024
1 parent 6452db8 commit 1c94c88
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 54 deletions.
22 changes: 8 additions & 14 deletions Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,18 @@ import com.example.jetcaster.core.data.model.LibraryInfo
import com.example.jetcaster.core.data.model.PlayerEpisode
import com.example.jetcaster.core.data.model.PodcastCategoryFilterResult
import com.example.jetcaster.core.data.model.PodcastInfo
import com.example.jetcaster.core.data.model.asExternalModel
import com.example.jetcaster.core.data.model.asPodcastCategoryEpisode
import com.example.jetcaster.ui.home.discover.discoverItems
import com.example.jetcaster.ui.home.library.libraryItems
import com.example.jetcaster.ui.theme.JetcasterTheme
import com.example.jetcaster.util.ToggleFollowPodcastIconButton
import com.example.jetcaster.util.quantityStringResource
import com.example.jetcaster.util.verticalGradientScrim
import java.time.Duration
import java.time.LocalDateTime
import java.time.OffsetDateTime
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.launch
import java.time.Duration
import java.time.LocalDateTime
import java.time.OffsetDateTime

@Composable
fun Home(
Expand Down Expand Up @@ -515,21 +513,17 @@ private fun lastUpdated(updated: OffsetDateTime): String {
fun PreviewHomeContent() {
JetcasterTheme {
Home(
featuredPodcasts = PreviewPodcastsWithExtraInfo.map {
it.asExternalModel()
}.toPersistentList(),
featuredPodcasts = PreviewPodcasts.toPersistentList(),
isRefreshing = false,
homeCategories = HomeCategory.entries,
selectedHomeCategory = HomeCategory.Discover,
filterableCategoriesModel = FilterableCategoriesModel(
categories = PreviewCategories.map { it.asExternalModel() },
selectedCategory = PreviewCategories.firstOrNull()?.asExternalModel()
categories = PreviewCategories,
selectedCategory = PreviewCategories.firstOrNull()
),
podcastCategoryFilterResult = PodcastCategoryFilterResult(
topPodcasts = PreviewPodcastsWithExtraInfo.map { it.asExternalModel() },
episodes = PreviewEpisodeToPodcasts.map {
it.asPodcastCategoryEpisode()
}
topPodcasts = PreviewPodcasts,
episodes = PreviewPodcastCategoryEpisodes
),
library = LibraryInfo(),
onCategorySelected = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,38 @@

package com.example.jetcaster.ui.home

import com.example.jetcaster.core.data.database.model.Category
import com.example.jetcaster.core.data.database.model.Episode
import com.example.jetcaster.core.data.database.model.EpisodeToPodcast
import com.example.jetcaster.core.data.database.model.Podcast
import com.example.jetcaster.core.data.database.model.PodcastWithExtraInfo
import com.example.jetcaster.core.data.model.CategoryInfo
import com.example.jetcaster.core.data.model.EpisodeInfo
import com.example.jetcaster.core.data.model.PodcastCategoryEpisode
import com.example.jetcaster.core.data.model.PodcastInfo
import java.time.OffsetDateTime
import java.time.ZoneOffset

val PreviewCategories = listOf(
Category(name = "Crime"),
Category(name = "News"),
Category(name = "Comedy")
CategoryInfo(id = 1, name = "Crime"),
CategoryInfo(id = 2, name = "News"),
CategoryInfo(id = 3, name = "Comedy")
)

val PreviewPodcasts = listOf(
Podcast(
PodcastInfo(
uri = "fakeUri://podcast/1",
title = "Android Developers Backstage",
author = "Android Developers"
author = "Android Developers",
isSubscribed = true,
lastEpisodeDate = OffsetDateTime.now()
),
Podcast(
PodcastInfo(
uri = "fakeUri://podcast/2",
title = "Google Developers podcast",
author = "Google Developers"
author = "Google Developers",
lastEpisodeDate = OffsetDateTime.now()
)
)

val PreviewPodcastsWithExtraInfo = PreviewPodcasts.mapIndexed { index, podcast ->
PodcastWithExtraInfo().apply {
this.podcast = podcast
this.lastEpisodeDate = OffsetDateTime.now()
this.isFollowed = index % 2 == 0
}
}

val PreviewEpisodes = listOf(
Episode(
EpisodeInfo(
uri = "fakeUri://episode/1",
podcastUri = PreviewPodcasts[0].uri,
title = "Episode 140: Bubbles!",
summary = "In this episode, Romain, Chet and Tor talked with Mady Melor and Artur " +
"Tsurkan from the System UI team about... Bubbles!",
Expand All @@ -65,9 +58,9 @@ val PreviewEpisodes = listOf(
)
)

val PreviewEpisodeToPodcasts = listOf(
EpisodeToPodcast().apply {
episode = PreviewEpisodes.first()
_podcasts = PreviewPodcasts
}
val PreviewPodcastCategoryEpisodes = listOf(
PodcastCategoryEpisode(
podcast = PreviewPodcasts[0],
episode = PreviewEpisodes[0],
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import coil.request.ImageRequest
import com.example.jetcaster.core.data.model.PlayerEpisode
import com.example.jetcaster.core.data.model.PodcastCategoryFilterResult
import com.example.jetcaster.core.data.model.PodcastInfo
import com.example.jetcaster.core.data.model.asExternalModel
import com.example.jetcaster.designsystem.theme.Keyline1
import com.example.jetcaster.ui.home.PreviewEpisodes
import com.example.jetcaster.ui.home.PreviewPodcasts
Expand Down Expand Up @@ -181,8 +180,8 @@ private fun TopPodcastRowItem(
fun PreviewEpisodeListItem() {
JetcasterTheme {
EpisodeListItem(
episode = PreviewEpisodes[0].asExternalModel(),
podcast = PreviewPodcasts[0].asExternalModel(),
episode = PreviewEpisodes[0],
podcast = PreviewPodcasts[0],
onClick = { },
onQueueEpisode = { },
modifier = Modifier.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -64,7 +65,6 @@ import com.example.jetcaster.R
import com.example.jetcaster.core.data.model.EpisodeInfo
import com.example.jetcaster.core.data.model.PlayerEpisode
import com.example.jetcaster.core.data.model.PodcastInfo
import com.example.jetcaster.core.data.model.asExternalModel
import com.example.jetcaster.designsystem.theme.Keyline1
import com.example.jetcaster.ui.home.PreviewEpisodes
import com.example.jetcaster.ui.home.PreviewPodcasts
Expand Down Expand Up @@ -181,7 +181,7 @@ fun PodcastDetailsHeaderItem(
.data(podcast.imageUrl)
.crossfade(true)
.build(),
contentDescription = stringResource(id = R.string.cd_podcast_image),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.size(148.dp)
Expand Down Expand Up @@ -260,17 +260,15 @@ fun PodcastDetailsHeaderItemButtons(
) {
Row(modifier.padding(top = 16.dp)) {
Button(
onClick = onClick
onClick = onClick,
modifier = Modifier.semantics(mergeDescendants = true) { }
) {
Icon(
imageVector = if (isSubscribed)
Icons.Default.Check
else
Icons.Default.Add,
contentDescription = if (isSubscribed)
stringResource(id = R.string.unsubscribe)
else
stringResource(id = R.string.subscribe)
contentDescription = null
)
Text(
text = if (isSubscribed)
Expand Down Expand Up @@ -317,7 +315,7 @@ fun PodcastDetailsTopAppBar(
@Composable
fun PodcastDetailsHeaderItemPreview() {
PodcastDetailsHeaderItem(
podcast = PreviewPodcasts[0].asExternalModel(),
podcast = PreviewPodcasts[0],
toggleSubscribe = { },
)
}
Expand All @@ -326,8 +324,8 @@ fun PodcastDetailsHeaderItemPreview() {
@Composable
fun PodcastDetailsScreenPreview() {
PodcastDetailsScreen(
podcast = PreviewPodcasts[0].asExternalModel(),
episodes = PreviewEpisodes.map { it.asExternalModel() },
podcast = PreviewPodcasts[0],
episodes = PreviewEpisodes,
toggleSubscribe = { },
onQueueEpisode = { },
navigateToPlayer = { },
Expand Down

0 comments on commit 1c94c88

Please sign in to comment.