@@ -19,6 +19,7 @@ package com.example.jetcaster.ui.home.category
1919import androidx.compose.foundation.Image
2020import androidx.compose.foundation.clickable
2121import androidx.compose.foundation.interaction.MutableInteractionSource
22+ import androidx.compose.foundation.layout.Arrangement
2223import androidx.compose.foundation.layout.Box
2324import androidx.compose.foundation.layout.Column
2425import androidx.compose.foundation.layout.PaddingValues
@@ -67,6 +68,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
6768import coil.compose.rememberImagePainter
6869import com.example.jetcaster.R
6970import com.example.jetcaster.data.Episode
71+ import com.example.jetcaster.data.EpisodeToPodcast
7072import com.example.jetcaster.data.Podcast
7173import com.example.jetcaster.data.PodcastWithExtraInfo
7274import com.example.jetcaster.ui.home.PreviewEpisodes
@@ -98,20 +100,39 @@ fun PodcastCategory(
98100 /* *
99101 * TODO: reset scroll position when category changes
100102 */
101- LazyColumn (
102- modifier = modifier,
103+ Column (modifier = modifier) {
104+ CategoryPodcasts (viewState.topPodcasts, viewModel)
105+ EpisodeList (viewState.episodes)
106+ }
107+ }
108+
109+ @Composable
110+ private fun CategoryPodcasts (
111+ topPodcasts : List <PodcastWithExtraInfo >,
112+ viewModel : PodcastCategoryViewModel
113+ ) {
114+ LazyRow (
103115 contentPadding = PaddingValues (0 .dp),
104- horizontalAlignment = Alignment .Start
116+ horizontalArrangement = Arrangement .Start
105117 ) {
106118 item {
107119 CategoryPodcastRow (
108- podcasts = viewState. topPodcasts,
120+ podcasts = topPodcasts,
109121 onTogglePodcastFollowed = viewModel::onTogglePodcastFollowed,
110122 modifier = Modifier .fillParentMaxWidth()
111123 )
112124 }
125+ }
126+ }
127+
128+ @Composable
129+ private fun EpisodeList (episodes : List <EpisodeToPodcast >) {
130+ LazyColumn (
131+ contentPadding = PaddingValues (0 .dp),
132+ verticalArrangement = Arrangement .Center
133+ ) {
113134
114- items(viewState. episodes, key = { it.episode.uri }) { item ->
135+ items(episodes, key = { it.episode.uri }) { item ->
115136 EpisodeListItem (
116137 episode = item.episode,
117138 podcast = item.podcast,
0 commit comments