mod: 首页推荐代码

This commit is contained in:
guozhigq
2023-08-18 18:22:20 +08:00
parent 47a3c964c0
commit b55568ef2a
4 changed files with 57 additions and 82 deletions

View File

@ -8,9 +8,8 @@ import 'package:pilipala/utils/storage.dart';
class RcmdController extends GetxController {
final ScrollController scrollController = ScrollController();
int _currentPage = 0;
int crossAxisCount = 2;
RxList<RecVideoItemAppModel> videoList = [RecVideoItemAppModel()].obs;
bool isLoadingMore = false;
RxList<RecVideoItemAppModel> videoList = <RecVideoItemAppModel>[].obs;
bool isLoadingMore = true;
OverlayEntry? popupDialog;
Box recVideo = GStrorage.recVideo;
@ -29,6 +28,9 @@ class RcmdController extends GetxController {
// 获取推荐
Future queryRcmdFeed(type) async {
if (isLoadingMore == false) {
return;
}
if (type == 'onRefresh') {
_currentPage = 0;
}
@ -37,7 +39,7 @@ class RcmdController extends GetxController {
);
if (res['status']) {
if (type == 'init') {
if (videoList.length > 1) {
if (videoList.isNotEmpty) {
videoList.addAll(res['data']);
} else {
videoList.value = res['data'];
@ -56,6 +58,7 @@ class RcmdController extends GetxController {
// 下拉刷新
Future onRefresh() async {
isLoadingMore = true;
queryRcmdFeed('onRefresh');
}