diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt index 0e4579aa3..8b20d8da4 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -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( @@ -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 = {}, diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/PreviewData.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/PreviewData.kt index 8705e6273..fb34b901f 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/PreviewData.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/PreviewData.kt @@ -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!", @@ -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], + ) ) diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt index aadcb4a49..6c8ac7814 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt @@ -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 @@ -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() diff --git a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/podcast/PodcastDetailsScreen.kt b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/podcast/PodcastDetailsScreen.kt index e9e18a2cf..67932514b 100644 --- a/Jetcaster/app/src/main/java/com/example/jetcaster/ui/podcast/PodcastDetailsScreen.kt +++ b/Jetcaster/app/src/main/java/com/example/jetcaster/ui/podcast/PodcastDetailsScreen.kt @@ -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 @@ -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 @@ -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) @@ -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) @@ -317,7 +315,7 @@ fun PodcastDetailsTopAppBar( @Composable fun PodcastDetailsHeaderItemPreview() { PodcastDetailsHeaderItem( - podcast = PreviewPodcasts[0].asExternalModel(), + podcast = PreviewPodcasts[0], toggleSubscribe = { }, ) } @@ -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 = { },