Skip to content

Commit

Permalink
[comment] minor: simplify CommentColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Mar 4, 2025
1 parent 55adc28 commit fa452e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
* Copyright (C) 2024-2025 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
Expand All @@ -22,6 +22,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.paging.compose.collectAsLazyPagingItemsWithLifecycle
import me.him188.ani.app.tools.formatDateTime
import me.him188.ani.app.ui.comment.Comment
import me.him188.ani.app.ui.comment.CommentColumn
Expand Down Expand Up @@ -52,7 +53,7 @@ fun EpisodeCommentColumn(

Column(modifier) {
CommentColumn(
state = state,
state.list.collectAsLazyPagingItemsWithLifecycle(),
lazyStaggeredGridState = lazyStaggeredGridState,
connectedScrollState = connectedScrollState,
modifier = Modifier.weight(1f).fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.unit.dp
import androidx.paging.compose.collectAsLazyPagingItemsWithLifecycle
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.itemContentType
import androidx.paging.compose.itemKey
import me.him188.ani.app.ui.foundation.LocalPlatform
Expand All @@ -44,16 +44,14 @@ import me.him188.ani.utils.platform.isMobile

@Composable
fun CommentColumn(
state: CommentState,
items: LazyPagingItems<UIComment>,
modifier: Modifier = Modifier,
hasDividerLine: Boolean = true,
contentPadding: PaddingValues = PaddingValues(0.dp),
connectedScrollState: ConnectedScrollState? = null,
lazyStaggeredGridState: LazyStaggeredGridState = rememberLazyStaggeredGridState(),
commentItem: @Composable LazyStaggeredGridItemScope.(index: Int, item: UIComment) -> Unit
) {
val items = state.list.collectAsLazyPagingItemsWithLifecycle()

PullToRefreshBox(
isRefreshing = items.isLoadingFirstPageOrRefreshing,
onRefresh = { items.refresh() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
* Copyright (C) 2024-2025 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
Expand All @@ -24,6 +24,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.paging.compose.collectAsLazyPagingItemsWithLifecycle
import me.him188.ani.app.tools.formatDateTime
import me.him188.ani.app.ui.comment.Comment
import me.him188.ani.app.ui.comment.CommentColumn
Expand All @@ -46,7 +47,7 @@ fun SubjectDetailsDefaults.SubjectCommentColumn(
) {
Box(modifier, contentAlignment = Alignment.TopCenter) {
CommentColumn(
state = state,
state.list.collectAsLazyPagingItemsWithLifecycle(),
modifier = Modifier
.widthIn(max = BottomSheetDefaults.SheetMaxWidth)
.fillMaxHeight(),
Expand Down

0 comments on commit fa452e9

Please sign in to comment.