feat(app): 剧场页九宫格与极简我的页

This commit is contained in:
Zhou Weidong committed 2026-10-20 05:28:51 +08:00
1 parent dc8ca7b743
commit 35338cbfc8
46 files changed
+2353 -4358

No files matched your search

+19 -53
View File
@@ -7,12 +7,12 @@ 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 '../../core/data/repositories/catalog_repository.dart';
import '../../l10n/app_localizations.dart';
import '../discover/discover_logic.dart';
import '../discover/discover_types.dart';
import '../drama_detail/drama_detail_view.dart';
import '../mine/mine_logic.dart';
import '../favorites/favorites_page.dart';
import '../mine/mine_types.dart';
import '../player/player_view.dart';
import '../watch_records/watch_records_page.dart';
class HomeLogic extends ChangeNotifier {
HomeLogic(List<Drama> dramas) : currentDrama = dramas.first;
@@ -21,34 +21,21 @@ class HomeLogic extends ChangeNotifier {
Drama currentDrama;
int tab = 0;
int searchRequest = 0;
int sectionRequest = 0;
int resumeRequest = 0;
int backRequest = 0;
int mySection = 0;
bool drawerOpen = false;
bool detailOpen = false;
bool videoImmersive = false;
bool profile = false;
bool _disposed = false;
void notify() {
if (!_disposed) notifyListeners();
}
void select(
int nextTab, {
bool search = false,
bool watchlist = false,
bool resume = false,
int? mySection,
}) {
void select(int nextTab, {bool search = false, bool resume = false}) {
FocusManager.instance.primaryFocus?.unfocus();
tab = nextTab;
if (search) searchRequest++;
if (watchlist || mySection != null) {
this.mySection = mySection ?? 1;
sectionRequest++;
}
if (resume) resumeRequest++;
notify();
}
@@ -59,11 +46,6 @@ class HomeLogic extends ChangeNotifier {
notify();
}
void selectFromMenu(int nextTab, {int? mySection}) {
drawerOpen = false;
select(nextTab, mySection: mySection);
}
Future<void> openCurrentSeries(BuildContext context) async {
detailOpen = true;
notify();
@@ -87,20 +69,6 @@ class HomeLogic extends ChangeNotifier {
);
}
/// Resolves a banner link that is not in the loaded feed, then opens detail.
Future<void> openDramaById(BuildContext context, String dramaId) async {
try {
final drama = await context.read<CatalogRepository>().fetchDrama(dramaId);
if (context.mounted) openDrama(context, drama);
} catch (_) {
if (!context.mounted) return;
final message = AppLocalizations.of(context)!.detailLoadFailed;
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(message)));
}
}
Future<void> playDrama(BuildContext context, Drama drama) async {
// 列表卡片只有一集预览,进入播放前补齐完整剧集,否则选集列表是空的。
var playable = drama;
@@ -122,31 +90,29 @@ class HomeLogic extends ChangeNotifier {
);
}
void openProfile() {
profile = true;
select(2, mySection: 0);
}
void openProfile() => select(2);
void openLibrary({int section = 1}) {
profile = false;
select(2, mySection: section);
}
void discoverAction(BuildContext context, DiscoverPageAction action) {
void discoverAction(DiscoverPageAction action) {
switch (action) {
case DiscoverPageAction.home:
select(0);
case DiscoverPageAction.my:
select(2);
case DiscoverPageAction.watchlist:
openLibrary();
case DiscoverPageAction.resume:
select(0, resume: true);
case DiscoverPageAction.detail:
openDrama(context, currentDrama);
}
}
void openFavorites(BuildContext context) {
Navigator.of(
context,
).push(MaterialPageRoute<void>(builder: (_) => const FavoritesPage()));
}
void openHistory(BuildContext context) {
Navigator.of(
context,
).push(MaterialPageRoute<void>(builder: (_) => const WatchRecordsPage()));
}
void myAction(MyPageAction action) {
switch (action) {
case MyPageAction.home: