-
Notifications
You must be signed in to change notification settings - Fork 1
[REF/#638] Feed ViewModel 내의 UI 스크롤 로직 분리 #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,7 +162,6 @@ internal fun FeedRoute( | |
| onUnpublishClick = viewModel::diaryUnpublish, | ||
| onReportClick = { context.launchCustomTabs(UrlConstant.FEEDBACK_REPORT) }, | ||
| readAllFeed = viewModel::readAllFeed, | ||
| isScrollingDown = viewModel::isScrollingDown | ||
| ) | ||
| } | ||
| } | ||
|
|
@@ -185,7 +184,6 @@ private fun FeedScreen( | |
| onReportClick: () -> Unit, | ||
| readAllFeed: () -> Unit, | ||
| onFeedRefresh: (FeedTab) -> Unit, | ||
| isScrollingDown: (FeedScrollState?, FeedScrollState) -> Boolean, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| val coroutineScope = rememberCoroutineScope() | ||
|
|
@@ -238,15 +236,17 @@ private fun FeedScreen( | |
|
|
||
| LaunchedEffect(pagerState.currentPage) { | ||
| snapshotFlow { | ||
| FeedScrollState( | ||
| firstVisibleItemIndex = currentListState.firstVisibleItemIndex, | ||
| firstVisibleItemScrollOffset = currentListState.firstVisibleItemScrollOffset | ||
| ) | ||
| Pair(currentListState.firstVisibleItemIndex, currentListState.firstVisibleItemScrollOffset) | ||
| } | ||
| .pairwise() | ||
| .collect { (previous, current) -> | ||
| val isScrollingDown = previous != null && ( | ||
| current.first > previous.first || | ||
| (current.first == previous.first && current.second > previous.second) | ||
|
||
| ) | ||
|
|
||
| if (currentListState.isScrollInProgress && | ||
| isScrollingDown(previous, current) && | ||
| isScrollingDown && | ||
|
||
| isAtBottom | ||
| ) { | ||
| latestReadAllFeed() | ||
|
|
@@ -349,8 +349,7 @@ private fun FeedScreenPreview() { | |
| hasFollowing = false, | ||
| recommendRefreshing = false, | ||
| followingRefreshing = false, | ||
| onFeedRefresh = {}, | ||
| isScrollingDown = { _, _ -> false } | ||
| onFeedRefresh = {} | ||
| ) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null 처리는
?.let { }로도 처리할 수 있을 것 같은데 어떤가요??