feat:支持排行榜功能

This commit is contained in:
yezi
2024-03-09 19:39:21 +08:00
parent ed0b43eff1
commit bf37c33291
12 changed files with 728 additions and 1 deletions

View File

@ -0,0 +1,53 @@
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/model_hot_video_item.dart';
class ZoneController extends GetxController {
final ScrollController scrollController = ScrollController();
RxList<HotVideoItemModel> videoList = <HotVideoItemModel>[].obs;
bool isLoadingMore = false;
bool flag = false;
OverlayEntry? popupDialog;
int zoneID = 0;
// 获取推荐
Future queryRankFeed(type, rid) async {
zoneID = rid;
var res = await VideoHttp.getRankVideoList(zoneID);
if (res['status']) {
if (type == 'init') {
videoList.value = res['data'];
} else if (type == 'onRefresh') {
videoList.clear();
videoList.addAll(res['data']);
} else if (type == 'onLoad') {
videoList.clear();
videoList.addAll(res['data']);
}
}
isLoadingMore = false;
return res;
}
// 下拉刷新
Future onRefresh() async {
queryRankFeed('onRefresh', zoneID);
}
// 上拉加载
Future onLoad() async {
queryRankFeed('onLoad', zoneID);
}
// 返回顶部并刷新
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);
}
}
}