繁体   English   中英

伴奏在 LazyColumn 内滑动刷新

[英]Accompanist SwipeRefresh Inside LazyColumn

我正在尝试将 SwipeRefresh 布局放置在 LazyColumn 和 scope 内,以包括 2 个项目调用和一个项目调用,在项目 {LazyRow(inside LazyColumn)} 下方和另一个项目{}下方。

所以我想要实现的是:

LazyColumn(
        Modifier
            .fillMaxSize()
            .background(colorResource(id = R.color.colorBackground))
    ) {
        item {
           LazyRow(
                Modifier
                    .wrapContentHeight()
                    .fillMaxWidth()
                    .background(colorResource(id = R.color.colorBackground)),
                listState
            ) { items()}
        }
        item { }
        -- this is where I want to place the swipe Refresh --
        item {}// box for holding a drawable
        item {} // another box
        items{ } // efficiently list items here
    }

我认为我可以做的是,我可以制作一个巨大的可滚动列,而不是使用lazyList 及其 dsl,但这会导致页面失去底部的 items{} 块的所有性能提升。 有没有比使用 Column 更有效的方法?

您应将LazyColumn放入SwipeRefresh可组合中。 例如:

SwipeRefresh(
        state = swipeRefreshState,
        onRefresh = onRefresh,
        indicator = { state, refreshTrigger ->
            SwipeRefreshIndicator(
                state = state,
                refreshTriggerDistance = refreshTrigger
            )
        }
    ) {
            LazyColumn(
                modifier = Modifier
                    .fillMaxSize()
                    .background(Color.White),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                item {
                 
                        Row(
                            modifier = Modifier.fillMaxWidth(),
                            horizontalArrangement = Arrangement.SpaceEvenly
                        ) {
                            someSections.forEach { section ->
                                SomeComposable(...)
                            }
                        }
                    }
                }
            }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM