mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-10 05:00:36 +01:00
feat: back to top in user detail
This commit is contained in:
parent
745755ff88
commit
d89a2169cd
@ -49,5 +49,6 @@ interface PostDetailMviModel :
|
||||
sealed interface Effect {
|
||||
data object Close : Effect
|
||||
data class ScrollToComment(val index: Int) : Effect
|
||||
data object BackToTop : Effect
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,12 @@ class PostDetailScreen(
|
||||
is PostDetailMviModel.Effect.ScrollToComment -> {
|
||||
lazyListState.scrollToItem(evt.index)
|
||||
}
|
||||
|
||||
PostDetailMviModel.Effect.BackToTop -> {
|
||||
scope.launch {
|
||||
lazyListState.scrollToItem(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.launchIn(this)
|
||||
}
|
||||
@ -483,7 +489,8 @@ class PostDetailScreen(
|
||||
)
|
||||
},
|
||||
content = {
|
||||
CommentCard(modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
||||
CommentCard(
|
||||
modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
||||
.let {
|
||||
if (comment.id == highlightCommentId) {
|
||||
it.background(
|
||||
@ -614,7 +621,8 @@ class PostDetailScreen(
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
Divider(
|
||||
|
@ -295,6 +295,9 @@ class PostDetailViewModel(
|
||||
|
||||
private fun applySortType(value: SortType) {
|
||||
mvi.updateState { it.copy(sortType = value) }
|
||||
mvi.scope?.launch {
|
||||
mvi.emitEffect(PostDetailMviModel.Effect.BackToTop)
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user