fix: issues #42 收藏夹只显示前50个视频
This commit is contained in:
@ -15,6 +15,8 @@ class FavDetailController extends GetxController {
|
|||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxMap favInfo = {}.obs;
|
RxMap favInfo = {}.obs;
|
||||||
RxList<FavDetailItemData> favList = [FavDetailItemData()].obs;
|
RxList<FavDetailItemData> favList = [FavDetailItemData()].obs;
|
||||||
|
RxString loadingText = '加载中...'.obs;
|
||||||
|
int mediaCount = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -27,6 +29,11 @@ class FavDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> queryUserFavFolderDetail({type = 'init'}) async {
|
Future<dynamic> queryUserFavFolderDetail({type = 'init'}) async {
|
||||||
|
if (type == 'onLoad' && favList.length >= mediaCount) {
|
||||||
|
loadingText.value = '没有更多了';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isLoadingMore = true;
|
||||||
var res = await await UserHttp.userFavFolderDetail(
|
var res = await await UserHttp.userFavFolderDetail(
|
||||||
pn: currentPage,
|
pn: currentPage,
|
||||||
ps: 20,
|
ps: 20,
|
||||||
@ -36,11 +43,16 @@ class FavDetailController extends GetxController {
|
|||||||
favInfo.value = res['data'].info;
|
favInfo.value = res['data'].info;
|
||||||
if (currentPage == 1 && type == 'init') {
|
if (currentPage == 1 && type == 'init') {
|
||||||
favList.value = res['data'].medias;
|
favList.value = res['data'].medias;
|
||||||
} else if (type == 'onload') {
|
mediaCount = res['data'].info['media_count'];
|
||||||
|
} else if (type == 'onLoad') {
|
||||||
favList.addAll(res['data'].medias);
|
favList.addAll(res['data'].medias);
|
||||||
}
|
}
|
||||||
|
if (favList.length >= mediaCount) {
|
||||||
|
loadingText.value = '没有更多了';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentPage += 1;
|
currentPage += 1;
|
||||||
|
isLoadingMore = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +76,6 @@ class FavDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
queryUserFavFolderDetail(type: 'onload');
|
queryUserFavFolderDetail(type: 'onLoad');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
import 'package:pilipala/pages/favDetail/index.dart';
|
import 'package:pilipala/pages/favDetail/index.dart';
|
||||||
|
|
||||||
import 'widget/fav_video_card.dart';
|
import 'widget/fav_video_card.dart';
|
||||||
@ -37,10 +40,9 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
|
|
||||||
if (_controller.position.pixels >=
|
if (_controller.position.pixels >=
|
||||||
_controller.position.maxScrollExtent - 200) {
|
_controller.position.maxScrollExtent - 200) {
|
||||||
if (!_favDetailController.isLoadingMore) {
|
EasyThrottle.throttle('favDetail', const Duration(seconds: 1), () {
|
||||||
_favDetailController.isLoadingMore = true;
|
|
||||||
_favDetailController.onLoad();
|
_favDetailController.onLoad();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -183,12 +185,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
Map data = snapshot.data;
|
Map data = snapshot.data;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
if (_favDetailController.item!.mediaCount == 0) {
|
if (_favDetailController.item!.mediaCount == 0) {
|
||||||
return const SliverToBoxAdapter(
|
return const NoData();
|
||||||
child: SizedBox(
|
|
||||||
height: 300,
|
|
||||||
child: Center(child: Text('没有内容')),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => SliverList(
|
() => SliverList(
|
||||||
@ -207,18 +204,30 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return const SliverToBoxAdapter(
|
// 骨架屏
|
||||||
child: SizedBox(
|
return SliverList(
|
||||||
height: 300,
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
child: Center(child: Text('加载中')),
|
return const VideoCardHSkeleton();
|
||||||
),
|
}, childCount: 10),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: SizedBox(
|
child: Container(
|
||||||
height: MediaQuery.of(context).padding.bottom + 20,
|
height: MediaQuery.of(context).padding.bottom + 60,
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
|
child: Center(
|
||||||
|
child: Obx(
|
||||||
|
() => Text(
|
||||||
|
_favDetailController.loadingText.value,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
fontSize: 13),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user