feat(home): 首页按内容类型分频道 Feed 并支持分页
This commit is contained in:
1 parent
4d0be47ee3
commit
ae61d9ec4c
22 files changed
+1001
-71
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/data/models/feed_page.dart';
|
||||
import 'package:fruitshorts/core/data/models/home_feed.dart';
|
||||
import 'package:fruitshorts/core/data/models/search_result.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/catalog_repository.dart';
|
||||
@@ -18,6 +19,23 @@ class FakeCatalogRepository implements CatalogRepository, SearchRepository {
|
||||
@override
|
||||
Future<HomeFeed> fetchDiscoverFeed() async => _feed();
|
||||
|
||||
@override
|
||||
Future<FeedPage> fetchFeed({
|
||||
List<String> types = const [],
|
||||
String? cursor,
|
||||
int size = 10,
|
||||
}) async {
|
||||
final filtered = types.isEmpty
|
||||
? dramas
|
||||
: dramas.where((drama) => _matchesFeedTypes(drama, types)).toList();
|
||||
return FeedPage(dramas: filtered.take(size).toList());
|
||||
}
|
||||
|
||||
bool _matchesFeedTypes(Drama drama, List<String> types) {
|
||||
final dramaType = drama.id == 'the-signal-demo' ? 'ANIME' : 'LIVE';
|
||||
return types.contains(dramaType);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Drama> fetchDrama(String dramaId) async {
|
||||
return dramas.firstWhere((drama) => drama.id == dramaId);
|
||||
|
||||
Reference in new issue
Block a user