mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-10 05:10:37 +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 {
|
sealed interface Effect {
|
||||||
data object Close : Effect
|
data object Close : Effect
|
||||||
data class ScrollToComment(val index: Int) : Effect
|
data class ScrollToComment(val index: Int) : Effect
|
||||||
|
data object BackToTop : Effect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,12 @@ class PostDetailScreen(
|
|||||||
is PostDetailMviModel.Effect.ScrollToComment -> {
|
is PostDetailMviModel.Effect.ScrollToComment -> {
|
||||||
lazyListState.scrollToItem(evt.index)
|
lazyListState.scrollToItem(evt.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PostDetailMviModel.Effect.BackToTop -> {
|
||||||
|
scope.launch {
|
||||||
|
lazyListState.scrollToItem(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.launchIn(this)
|
}.launchIn(this)
|
||||||
}
|
}
|
||||||
@ -483,26 +489,27 @@ class PostDetailScreen(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
CommentCard(modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
CommentCard(
|
||||||
.let {
|
modifier = Modifier.background(MaterialTheme.colorScheme.background)
|
||||||
if (comment.id == highlightCommentId) {
|
.let {
|
||||||
it.background(
|
if (comment.id == highlightCommentId) {
|
||||||
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
it.background(
|
||||||
5.dp
|
MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||||
).copy(
|
5.dp
|
||||||
alpha = 0.75f
|
).copy(
|
||||||
|
alpha = 0.75f
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}.onClick {
|
||||||
|
model.reduce(
|
||||||
|
PostDetailMviModel.Intent.ToggleExpandComment(
|
||||||
|
commentId,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
},
|
||||||
it
|
|
||||||
}
|
|
||||||
}.onClick {
|
|
||||||
model.reduce(
|
|
||||||
PostDetailMviModel.Intent.ToggleExpandComment(
|
|
||||||
commentId,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
comment = comment,
|
comment = comment,
|
||||||
separateUpAndDownVotes = uiState.separateUpAndDownVotes,
|
separateUpAndDownVotes = uiState.separateUpAndDownVotes,
|
||||||
autoLoadImages = uiState.autoLoadImages,
|
autoLoadImages = uiState.autoLoadImages,
|
||||||
@ -614,7 +621,8 @@ class PostDetailScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
Divider(
|
Divider(
|
||||||
|
@ -295,6 +295,9 @@ class PostDetailViewModel(
|
|||||||
|
|
||||||
private fun applySortType(value: SortType) {
|
private fun applySortType(value: SortType) {
|
||||||
mvi.updateState { it.copy(sortType = value) }
|
mvi.updateState { it.copy(sortType = value) }
|
||||||
|
mvi.scope?.launch {
|
||||||
|
mvi.emitEffect(PostDetailMviModel.Effect.BackToTop)
|
||||||
|
}
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user