Jetpack Compose Material3 下拉刷新功能

huangapple go评论131阅读模式
英文:

Jetpack Compose Material3 Pull to Refresh functionality

问题

我正在尝试根据这个指南,从Material2规范迁移项目到Material 3 Compose库。

Material2中的当前LazyColumn已经整合了下拉刷新功能,在这里找到

然而,在Material3中,我没有找到类似的功能。
有一个问题跟踪器在这里,但他们说这个功能将仅在今年中期考虑,这太长时间了。

有没有人对如何处理这种情况有任何想法?下拉刷新是我们应用程序用户流程中重要的步骤,所以没有它不是一个选择。

我们是否应该使用accompanist/swipeToRefresh,即使它已经不推荐使用了?

我还不擅长编写自定义Compose组件,所以如果有人能帮助我解决这个问题,我会很感激。

英文:

I am trying to migrate a project from Material2 specs to Material 3 compose library following this guide.

The current LazyColumn in Material2 has integrate Pull to refresh functionality, found here

However, i did not find any such functionality for Material3.
There is an issue tracker open here but they say this functionality will be considered only mid this year, which is too long to wait.

Does anyone have any idea on how this situation should be handled? Pull to refresh is an important flow of our apps user flow, so not having it is not an option.

Should we use accompanist/swipeToRefresh even though it is deprecated?

I am not proficient in writing custom compose components yet, so any help in figuring this out would be appreciated

答案1

得分: 17

我们的团队也遇到了同样的问题。最终,我们选择将PullToRefresh组件的MD2实现作为临时解决方案引入我们的项目中,然后将所有MD2的引用更新为它们的MD3版本。

完整的MD2实现包括以下文件:

  • PullRefresh.kt
  • PullRefreshIndicator.kt
  • PullRefreshIndicatorTransform.kt
  • PullRefreshState.kt

这种方法是在这个讨论中建议的。你可以在这里找到帖子作者的完整解决方案here

英文:

Our team ran into this same problem. Ultimately, we opted to bring the MD2 implementation of the PullToRefresh component into our project as a temporary workaround. Then, we just updated any MD2 references to their MD3 counterparts.

The full MD2 implementation consists of the following files:

  • PullRefresh.kt
  • PullRefreshIndicator.kt
  • PullRefreshIndicatorTransform.kt
  • PullRefreshState.kt

This approach was suggested in this discussion. You can find the op's full solution here.

huangapple
  • 本文由 发表于 2023年3月9日 18:14:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683184.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定