feat(library): 支持设备追剧与观看历史
This commit is contained in:
1 parent
4c3acb047c
commit
0d785bf1f8
12 files changed
+232
-76
No files matched your search
@@ -35,7 +35,6 @@ class WatchRecordsPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Theme(
|
||||
data: AppTheme.dark(),
|
||||
@@ -49,11 +48,7 @@ class WatchRecordsPage extends StatelessWidget {
|
||||
title: l10n.watchHistory,
|
||||
backKey: const Key('watch-records-back'),
|
||||
),
|
||||
Expanded(
|
||||
child: signedIn
|
||||
? const _WatchRecordsBody()
|
||||
: const AuthGatePanel(),
|
||||
),
|
||||
Expanded(child: const _WatchRecordsBody()),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -71,10 +66,15 @@ class _WatchRecordsBody extends StatefulWidget {
|
||||
|
||||
class _WatchRecordsBodyState extends State<_WatchRecordsBody> {
|
||||
late final WatchRecordsController controller;
|
||||
late final AuthController _auth;
|
||||
late bool _signedIn;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_auth = context.read<AuthController>();
|
||||
_signedIn = _auth.isSignedIn;
|
||||
_auth.addListener(_handleAuthChanged);
|
||||
controller = WatchRecordsBinding().create(
|
||||
history: context.read<WatchHistoryRepository>(),
|
||||
catalog: context.read<CatalogRepository>(),
|
||||
@@ -82,8 +82,16 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> {
|
||||
unawaited(controller.load());
|
||||
}
|
||||
|
||||
void _handleAuthChanged() {
|
||||
final signedIn = _auth.isSignedIn;
|
||||
if (_signedIn == signedIn || !mounted) return;
|
||||
_signedIn = signedIn;
|
||||
unawaited(controller.load());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_auth.removeListener(_handleAuthChanged);
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -98,6 +106,9 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> {
|
||||
|
||||
Widget _content(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
if (controller.lastErrorCode == 200007) {
|
||||
return const AuthGatePanel();
|
||||
}
|
||||
if (controller.loading && controller.records.isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(key: Key('watch-records-loading')),
|
||||
|
||||
Reference in new issue
Block a user