@@ -19,6 +19,7 @@ package com.example.jetcaster.ui.home.category
19
19
import androidx.compose.foundation.Image
20
20
import androidx.compose.foundation.clickable
21
21
import androidx.compose.foundation.interaction.MutableInteractionSource
22
+ import androidx.compose.foundation.layout.Arrangement
22
23
import androidx.compose.foundation.layout.Box
23
24
import androidx.compose.foundation.layout.Column
24
25
import androidx.compose.foundation.layout.PaddingValues
@@ -67,6 +68,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
67
68
import coil.compose.rememberImagePainter
68
69
import com.example.jetcaster.R
69
70
import com.example.jetcaster.data.Episode
71
+ import com.example.jetcaster.data.EpisodeToPodcast
70
72
import com.example.jetcaster.data.Podcast
71
73
import com.example.jetcaster.data.PodcastWithExtraInfo
72
74
import com.example.jetcaster.ui.home.PreviewEpisodes
@@ -98,20 +100,39 @@ fun PodcastCategory(
98
100
/* *
99
101
* TODO: reset scroll position when category changes
100
102
*/
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 (
103
115
contentPadding = PaddingValues (0 .dp),
104
- horizontalAlignment = Alignment .Start
116
+ horizontalArrangement = Arrangement .Start
105
117
) {
106
118
item {
107
119
CategoryPodcastRow (
108
- podcasts = viewState. topPodcasts,
120
+ podcasts = topPodcasts,
109
121
onTogglePodcastFollowed = viewModel::onTogglePodcastFollowed,
110
122
modifier = Modifier .fillParentMaxWidth()
111
123
)
112
124
}
125
+ }
126
+ }
127
+
128
+ @Composable
129
+ private fun EpisodeList (episodes : List <EpisodeToPodcast >) {
130
+ LazyColumn (
131
+ contentPadding = PaddingValues (0 .dp),
132
+ verticalArrangement = Arrangement .Center
133
+ ) {
113
134
114
- items(viewState. episodes, key = { it.episode.uri }) { item ->
135
+ items(episodes, key = { it.episode.uri }) { item ->
115
136
EpisodeListItem (
116
137
episode = item.episode,
117
138
podcast = item.podcast,
0 commit comments