fix(flutter): 剧场与榜单卡片直接进播放页
This commit is contained in:
1 parent
04a1a4ee82
commit
720fd26935
6 files changed
+72
-47
No files matched your search
@@ -1,17 +1,13 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/data/models/drama.dart';
|
||||
import '../../core/data/services/catalog_controller.dart';
|
||||
import '../../core/data/services/download_controller.dart';
|
||||
import '../../core/data/services/wallet_controller.dart';
|
||||
import '../discover/discover_types.dart';
|
||||
import '../drama_detail/drama_detail_view.dart';
|
||||
import '../favorites/favorites_page.dart';
|
||||
import '../mine/mine_types.dart';
|
||||
import '../player/player_view.dart';
|
||||
import '../player/open_player.dart';
|
||||
import '../watch_records/watch_records_page.dart';
|
||||
|
||||
class HomeLogic extends ChangeNotifier {
|
||||
@@ -73,29 +69,7 @@ class HomeLogic extends ChangeNotifier {
|
||||
BuildContext context,
|
||||
Drama drama, {
|
||||
String? episodeId,
|
||||
}) async {
|
||||
// 列表卡片只有一集预览,进入播放前补齐完整剧集,否则选集列表是空的。
|
||||
var playable = drama;
|
||||
try {
|
||||
playable = await context.read<CatalogController>().requireDetail(drama);
|
||||
} catch (_) {
|
||||
// 取详情失败就用卡片自带的那一集起播。
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
final index = episodeId == null
|
||||
? 0
|
||||
: playable.episodes.indexWhere((episode) => episode.id == episodeId);
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => PlayerPage(
|
||||
drama: playable,
|
||||
initialIndex: index < 0 ? 0 : index,
|
||||
wallet: context.read<WalletController>(),
|
||||
downloads: context.read<DownloadController>(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}) => playDramaFromCatalog(context, drama, episodeId: episodeId);
|
||||
|
||||
void openProfile() => select(3);
|
||||
|
||||
|
||||
Reference in new issue
Block a user