mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-14 21:24:02 +08:00
@@ -1,14 +1,15 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/home/rcmd/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
|
||||
class RcmdController extends CommonListController {
|
||||
late bool enableSaveLastData = Pref.enableSaveLastData;
|
||||
final bool appRcmd = Pref.appRcmd;
|
||||
|
||||
class RcmdController
|
||||
extends
|
||||
CommonListController<
|
||||
List<RcmdVideoItemAppModel>,
|
||||
RcmdVideoItemAppModel
|
||||
> {
|
||||
int? lastRefreshAt;
|
||||
late bool savedRcmdTip = Pref.savedRcmdTip;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -18,20 +19,15 @@ class RcmdController extends CommonListController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() {
|
||||
return appRcmd
|
||||
? VideoHttp.rcmdVideoListApp(freshIdx: page)
|
||||
: VideoHttp.rcmdVideoList(freshIdx: page, ps: 20);
|
||||
}
|
||||
Future<LoadingState<List<RcmdVideoItemAppModel>>> customGetData() =>
|
||||
VideoHttp.rcmdVideoListApp(freshIdx: page);
|
||||
|
||||
@override
|
||||
void handleListResponse(List dataList) {
|
||||
if (enableSaveLastData && page == 0) {
|
||||
void handleListResponse(List<RcmdVideoItemAppModel> dataList) {
|
||||
if (page == 0) {
|
||||
if (loadingState.value case Success(:final response)) {
|
||||
if (response != null && response.isNotEmpty) {
|
||||
if (savedRcmdTip) {
|
||||
lastRefreshAt = dataList.length;
|
||||
}
|
||||
lastRefreshAt = dataList.length;
|
||||
if (response.length > 200) {
|
||||
dataList.addAll(response.take(50));
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_v.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/home/rcmd/result.dart';
|
||||
import 'package:PiliPlus/pages/rcmd/controller.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
@@ -60,7 +61,7 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
|
||||
Widget _buildBody(
|
||||
ColorScheme colorScheme,
|
||||
LoadingState<List<dynamic>?> loadingState,
|
||||
LoadingState<List<RcmdVideoItemAppModel>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => _buildSkeleton,
|
||||
|
||||
Reference in New Issue
Block a user