我开始了解 Jetpack Compose。我把这个放在一起app https://github.com/4gus71n/TheOneApp在我探索不同的日常用例时,该项目中的每个功能模块都应该解决不同的场景。
该功能模块之一 -chatexample
功能模块,尝试实现一个简单的ViewPager
其中每个页面都是Fragment
,第一页“消息”应该显示分页RecyclerView
缠绕在一个SwipeRefreshLayout
。现在,我们的目标是使用 Jetpack Compose 来实现这一切。这是我现在遇到的问题:
The 拉动刷新指示器 https://github.com/4gus71n/TheOneApp/blob/main/features/chatexample/src/main/java/com/example/chatexample/ui/main/ChatExampleScreen.kt#L68我用来实现 Pull-To-Refresh 操作的功能按预期工作,到目前为止一切看起来都非常简单,但我无法弄清楚为什么 ProgresBar 保持在顶部。
到目前为止我已经尝试过;进行着Modifier
来自父母Scaffold
一路过去。确保我明确设置尺寸以适合最大高度和宽度。添加一个空的Box
in the when https://github.com/4gus71n/TheOneApp/blob/main/features/chatexample/src/main/java/com/example/chatexample/ui/main/ChatExampleScreen.kt#L65声明 - 但到目前为止没有任何效果,我猜我可以删除PullRefreshIndicator
如果我发现 ViewModel 不应该令人耳目一新,但我认为这不是正确的做法。
为了快速解释我在这里使用的可组合项,我有:
<Surface>
<Scaffold> // Set with a topBar
<Column>
<ScrollableTabRow>
<Tab/> // Set for the first "Messages" tab
<Tab/> // Set for the second "Dashboard" tab
</ScrollableTabRow>
<HorizontalPager>
// ChatExampleScreen
<Box> // A Box set with the pullRefresh modifier
// Depending on the ChatExamleViewModel we might pull different composables here
</PullRefreshIndicator>
</Box>
// Another ChatExampleScreen for the second tab
</HorizontalPager>
</Column>
<Scaffold>
</Surface>
老实说,我不明白如何PullRefreshIndicator
这是在一个完全不同的可组合项中(ChatExampleScreen
)与ScrollableTabRow
那是外面。
希望这能让用户界面更容易理解。如有任何提示、建议或推荐,我们将不胜感激。谢谢! ????
Edit:完全清楚的是,我在这里想要实现的是在每个页面上都有一个 PullRefreshIndicator。像这样的事情:
在每个页面上,您向下拉,会看到进度条出现,完成后,它会在同一页面内消失。不与上面的选项卡重叠。