mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 23:27:04 +05:30
fix(android): only attempt to scroll when items exist
Fixes COMPOSE-LOBSTERS-3F
This commit is contained in:
parent
9357362ef6
commit
1fff9d9aa2
1 changed files with 9 additions and 3 deletions
|
@ -129,7 +129,9 @@ fun LobstersPostsScreen(
|
||||||
icon = Icons.Outlined.Whatshot,
|
icon = Icons.Outlined.Whatshot,
|
||||||
selectedIcon = Icons.Filled.Whatshot,
|
selectedIcon = Icons.Filled.Whatshot,
|
||||||
) {
|
) {
|
||||||
coroutineScope.launch { hottestListState.animateScrollToItem(index = 0) }
|
coroutineScope.launch {
|
||||||
|
if (hottestPosts.itemCount > 0) hottestListState.animateScrollToItem(index = 0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Newest",
|
label = "Newest",
|
||||||
|
@ -137,7 +139,9 @@ fun LobstersPostsScreen(
|
||||||
icon = Icons.Outlined.NewReleases,
|
icon = Icons.Outlined.NewReleases,
|
||||||
selectedIcon = Icons.Filled.NewReleases,
|
selectedIcon = Icons.Filled.NewReleases,
|
||||||
) {
|
) {
|
||||||
coroutineScope.launch { newestListState.animateScrollToItem(index = 0) }
|
coroutineScope.launch {
|
||||||
|
if (newestPosts.itemCount > 0) newestListState.animateScrollToItem(index = 0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Saved",
|
label = "Saved",
|
||||||
|
@ -145,7 +149,9 @@ fun LobstersPostsScreen(
|
||||||
icon = Icons.Outlined.FavoriteBorder,
|
icon = Icons.Outlined.FavoriteBorder,
|
||||||
selectedIcon = Icons.Filled.Favorite,
|
selectedIcon = Icons.Filled.Favorite,
|
||||||
) {
|
) {
|
||||||
coroutineScope.launch { savedListState.animateScrollToItem(index = 0) }
|
coroutineScope.launch {
|
||||||
|
if (savedPosts.isNotEmpty()) savedListState.animateScrollToItem(index = 0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue