mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 09:38:44 +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,26 +489,27 @@ class PostDetailScreen(
|
||||
)
|
||||
},
|
||||
content = {
|
||||
CommentCard(modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
||||
.let {
|
||||
if (comment.id == highlightCommentId) {
|
||||
it.background(
|
||||
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||
5.dp
|
||||
).copy(
|
||||
alpha = 0.75f
|
||||
CommentCard(
|
||||
modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
||||
.let {
|
||||
if (comment.id == highlightCommentId) {
|
||||
it.background(
|
||||
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||
5.dp
|
||||
).copy(
|
||||
alpha = 0.75f
|
||||
)
|
||||
)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.onClick {
|
||||
model.reduce(
|
||||
PostDetailMviModel.Intent.ToggleExpandComment(
|
||||
commentId,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.onClick {
|
||||
model.reduce(
|
||||
PostDetailMviModel.Intent.ToggleExpandComment(
|
||||
commentId,
|
||||
)
|
||||
)
|
||||
},
|
||||
},
|
||||
comment = comment,
|
||||
separateUpAndDownVotes = uiState.separateUpAndDownVotes,
|
||||
autoLoadImages = uiState.autoLoadImages,
|
||||
@ -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