feat: 稍后再看下拉刷新

This commit is contained in:
guozhigq
2024-10-15 00:17:46 +08:00
parent 3f9b35b56b
commit 63a6c048e6
2 changed files with 66 additions and 59 deletions

View File

@ -22,11 +22,11 @@ class LaterController extends GetxController {
userInfo = userInfoCache.get('userInfoCache'); userInfo = userInfoCache.get('userInfoCache');
} }
Future queryLaterList() async { Future queryLaterList({type = 'init'}) async {
if (userInfo == null) { if (userInfo == null) {
return {'status': false, 'msg': '账号未登录', 'code': -101}; return {'status': false, 'msg': '账号未登录', 'code': -101};
} }
isLoading.value = true; isLoading.value = type == 'init';
var res = await UserHttp.seeYouLater(); var res = await UserHttp.seeYouLater();
if (res['status']) { if (res['status']) {
count = res['data']['count']; count = res['data']['count'];

View File

@ -66,8 +66,13 @@ class _LaterPageState extends State<LaterPage> {
const SizedBox(width: 8), const SizedBox(width: 8),
], ],
), ),
body: CustomScrollView( body: RefreshIndicator(
onRefresh: () async {
await _laterController.queryLaterList(type: 'onRefresh');
},
child: CustomScrollView(
controller: _laterController.scrollController, controller: _laterController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [ slivers: [
FutureBuilder( FutureBuilder(
future: _futureBuilderFuture, future: _futureBuilderFuture,
@ -81,12 +86,13 @@ class _LaterPageState extends State<LaterPage> {
? SliverList( ? SliverList(
delegate: delegate:
SliverChildBuilderDelegate((context, index) { SliverChildBuilderDelegate((context, index) {
var videoItem = _laterController.laterList[index]; var videoItem =
_laterController.laterList[index];
return VideoCardH( return VideoCardH(
videoItem: videoItem, videoItem: videoItem,
source: 'later', source: 'later',
onPressedFn: () => _laterController.toViewDel( onPressedFn: () => _laterController
aid: videoItem.aid)); .toViewDel(aid: videoItem.aid));
}, childCount: _laterController.laterList.length), }, childCount: _laterController.laterList.length),
) )
: _laterController.isLoading.value : _laterController.isLoading.value
@ -128,6 +134,7 @@ class _LaterPageState extends State<LaterPage> {
) )
], ],
), ),
),
floatingActionButton: Obx( floatingActionButton: Obx(
() => _laterController.laterList.isNotEmpty () => _laterController.laterList.isNotEmpty
? FloatingActionButton.extended( ? FloatingActionButton.extended(