feat: 动态页返回顶部&双击刷新

This commit is contained in:
guozhigq
2023-07-10 13:54:03 +08:00
parent 98ef6876ce
commit b1cd8bbed3
3 changed files with 38 additions and 5 deletions

View File

@ -40,6 +40,7 @@ class DynamicsController extends GetxController {
'enabled': true
},
];
bool flag = false;
Future queryFollowDynamic({type = 'init'}) async {
// if (type == 'init') {
@ -129,4 +130,21 @@ class DynamicsController extends GetxController {
queryFollowDynamic();
}
onRefresh() async {
page = 1;
queryFollowUp();
await queryFollowDynamic();
}
// 返回顶部并刷新
void animateToTop() async {
if (scrollController.offset >=
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
}
}

View File

@ -117,11 +117,7 @@ class _DynamicsPageState extends State<DynamicsPage>
),
),
body: RefreshIndicator(
onRefresh: () async {
_dynamicsController.page = 1;
_dynamicsController.queryFollowUp();
await _dynamicsController.queryFollowDynamic();
},
onRefresh: () => _dynamicsController.onRefresh(),
child: CustomScrollView(
controller: _dynamicsController.scrollController,
slivers: [