@@ -93,7 +93,7 @@ import com.example.jetnews.ui.theme.JetnewsTheme
9393import kotlinx.coroutines.runBlocking
9494
9595/* *
96- * The home screen displaying just the article feed.
96+ * The home screen displaying just the post feed.
9797 */
9898@Composable
9999fun HomeFeedScreen (
@@ -123,7 +123,7 @@ fun HomeFeedScreen(
123123 postsFeed = hasPostsUiState.postsFeed,
124124 favorites = hasPostsUiState.favorites,
125125 showExpandedSearch = ! showTopAppBar,
126- onArticleTapped = onSelectPost,
126+ onPostTapped = onSelectPost,
127127 onToggleFavorite = onToggleFavorite,
128128 contentPadding = contentPadding,
129129 modifier = contentModifier,
@@ -289,18 +289,25 @@ private fun LoadingContent(
289289/* *
290290 * Display a feed of posts.
291291 *
292- * When a post is clicked on, [onArticleTapped ] will be called.
292+ * When a post is clicked on, [onPostTapped ] will be called.
293293 *
294294 * @param postsFeed (state) the feed to display
295- * @param onArticleTapped (event) request navigation to Article screen
295+ * @param favorites (state) a set of favorite posts
296+ * @param showExpandedSearch (state) whether the expanded search is shown
297+ * @param onPostTapped (event) request navigation to Post screen
298+ * @param onToggleFavorite (event) request that this post toggle its favorite state
296299 * @param modifier modifier for the root element
300+ * @param contentPadding the padding to apply to the content
301+ * @param state the state object to be used to control or observe the list's state
302+ * @param searchInput (state) the search input
303+ * @param onSearchInputChanged (event) request that the search input changed
297304 */
298305@Composable
299306private fun PostList (
300307 postsFeed : PostsFeed ,
301308 favorites : Set <String >,
302309 showExpandedSearch : Boolean ,
303- onArticleTapped : (postId: String ) -> Unit ,
310+ onPostTapped : (postId: String ) -> Unit ,
304311 onToggleFavorite : (String ) -> Unit ,
305312 modifier : Modifier = Modifier ,
306313 contentPadding : PaddingValues = PaddingValues (0.dp),
@@ -322,12 +329,12 @@ private fun PostList(
322329 )
323330 }
324331 }
325- item { PostListTopSection (postsFeed.highlightedPost, onArticleTapped ) }
332+ item { PostListTopSection (postsFeed.highlightedPost, onPostTapped ) }
326333 if (postsFeed.recommendedPosts.isNotEmpty()) {
327334 item {
328335 PostListSimpleSection (
329336 postsFeed.recommendedPosts,
330- onArticleTapped ,
337+ onPostTapped ,
331338 favorites,
332339 onToggleFavorite,
333340 )
@@ -336,12 +343,12 @@ private fun PostList(
336343 if (postsFeed.popularPosts.isNotEmpty() && ! showExpandedSearch) {
337344 item {
338345 PostListPopularSection (
339- postsFeed.popularPosts, onArticleTapped ,
346+ postsFeed.popularPosts, onPostTapped ,
340347 )
341348 }
342349 }
343350 if (postsFeed.recentPosts.isNotEmpty()) {
344- item { PostListHistorySection (postsFeed.recentPosts, onArticleTapped ) }
351+ item { PostListHistorySection (postsFeed.recentPosts, onPostTapped ) }
345352 }
346353 }
347354}
@@ -364,18 +371,18 @@ private fun FullScreenLoading() {
364371 * Top section of [PostList]
365372 *
366373 * @param post (state) highlighted post to display
367- * @param navigateToArticle (event) request navigation to Article screen
374+ * @param navigateToPost (event) request navigation to Post screen
368375 */
369376@Composable
370- private fun PostListTopSection (post : Post , navigateToArticle : (String ) -> Unit ) {
377+ private fun PostListTopSection (post : Post , navigateToPost : (String ) -> Unit ) {
371378 Text (
372379 modifier = Modifier .padding(start = 16 .dp, top = 16 .dp, end = 16 .dp),
373380 text = stringResource(id = R .string.home_top_section_title),
374381 style = MaterialTheme .typography.titleMedium,
375382 )
376383 PostCardTop (
377384 post = post,
378- modifier = Modifier .clickable(onClick = { navigateToArticle (post.id) }),
385+ modifier = Modifier .clickable(onClick = { navigateToPost (post.id) }),
379386 )
380387 PostListDivider ()
381388}
@@ -384,20 +391,22 @@ private fun PostListTopSection(post: Post, navigateToArticle: (String) -> Unit)
384391 * Full-width list items for [PostList]
385392 *
386393 * @param posts (state) to display
387- * @param navigateToArticle (event) request navigation to Article screen
394+ * @param navigateToPost (event) request navigation to Post screen
395+ * @param favorites (state) a set of favorite posts
396+ * @param onToggleFavorite (event) request that this post toggle its favorite state
388397 */
389398@Composable
390399private fun PostListSimpleSection (
391400 posts : List <Post >,
392- navigateToArticle : (String ) -> Unit ,
401+ navigateToPost : (String ) -> Unit ,
393402 favorites : Set <String >,
394403 onToggleFavorite : (String ) -> Unit ,
395404) {
396405 Column {
397406 posts.forEach { post ->
398407 PostCardSimple (
399408 post = post,
400- navigateToArticle = navigateToArticle ,
409+ navigateToPost = navigateToPost ,
401410 isFavorite = favorites.contains(post.id),
402411 onToggleFavorite = { onToggleFavorite(post.id) },
403412 )
@@ -410,10 +419,10 @@ private fun PostListSimpleSection(
410419 * Horizontal scrolling cards for [PostList]
411420 *
412421 * @param posts (state) to display
413- * @param navigateToArticle (event) request navigation to Article screen
422+ * @param navigateToPost (event) request navigation to Post screen
414423 */
415424@Composable
416- private fun PostListPopularSection (posts : List <Post >, navigateToArticle : (String ) -> Unit ) {
425+ private fun PostListPopularSection (posts : List <Post >, navigateToPost : (String ) -> Unit ) {
417426 Column {
418427 Text (
419428 modifier = Modifier .padding(16 .dp),
@@ -430,7 +439,7 @@ private fun PostListPopularSection(posts: List<Post>, navigateToArticle: (String
430439 for (post in posts) {
431440 PostCardPopular (
432441 post,
433- navigateToArticle ,
442+ navigateToPost ,
434443 )
435444 }
436445 }
@@ -443,13 +452,13 @@ private fun PostListPopularSection(posts: List<Post>, navigateToArticle: (String
443452 * Full-width list items that display "based on your history" for [PostList]
444453 *
445454 * @param posts (state) to display
446- * @param navigateToArticle (event) request navigation to Article screen
455+ * @param navigateToPost (event) request navigation to Post screen
447456 */
448457@Composable
449- private fun PostListHistorySection (posts : List <Post >, navigateToArticle : (String ) -> Unit ) {
458+ private fun PostListHistorySection (posts : List <Post >, navigateToPost : (String ) -> Unit ) {
450459 Column {
451460 posts.forEach { post ->
452- PostCardHistory (post, navigateToArticle )
461+ PostCardHistory (post, navigateToPost )
453462 PostListDivider ()
454463 }
455464 }
0 commit comments