fix: video theme, view later

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-11 11:54:39 +08:00
parent af6188be77
commit a6a1de169b
6 changed files with 312 additions and 345 deletions

View File

@@ -652,6 +652,7 @@ class VideoIntroController extends GetxController
} catch (_) {} } catch (_) {}
} }
hasLater.value = false;
this.bvid = bvid; this.bvid = bvid;
lastPlayCid.value = cid; lastPlayCid.value = cid;
queryVideoIntro(); queryVideoIntro();

View File

@@ -21,6 +21,7 @@ class VideoReplyReplyController extends ReplyController
required this.dialog, required this.dialog,
required this.replyType, required this.replyType,
required this.isDialogue, required this.isDialogue,
required this.getThemeData,
}); });
final int? dialog; final int? dialog;
final bool isDialogue; final bool isDialogue;
@@ -60,6 +61,8 @@ class VideoReplyReplyController extends ReplyController
return super.onRefresh(); return super.onRefresh();
} }
final ThemeData Function() getThemeData;
@override @override
bool customHandleResponse(Success response) { bool customHandleResponse(Success response) {
if (GlobalData().grpcReply) { if (GlobalData().grpcReply) {
@@ -81,8 +84,8 @@ class VideoReplyReplyController extends ReplyController
vsync: this, vsync: this,
); );
colorAnimation = ColorTween( colorAnimation = ColorTween(
begin: Theme.of(Get.context!).colorScheme.onInverseSurface, begin: getThemeData().colorScheme.onInverseSurface,
end: Theme.of(Get.context!).colorScheme.surface, end: getThemeData().colorScheme.surface,
).animate(controller!); ).animate(controller!);
WidgetsBinding.instance.addPostFrameCallback((_) async { WidgetsBinding.instance.addPostFrameCallback((_) async {
if (index != null) { if (index != null) {

View File

@@ -80,6 +80,7 @@ class _VideoReplyReplyPanelState
dialog: widget.dialog, dialog: widget.dialog,
replyType: widget.replyType, replyType: widget.replyType,
isDialogue: widget.isDialogue, isDialogue: widget.isDialogue,
getThemeData: () => Theme.of(context),
), ),
tag: '${widget.rpid}${widget.dialog}${widget.isDialogue}', tag: '${widget.rpid}${widget.dialog}${widget.isDialogue}',
); );
@@ -473,9 +474,9 @@ class _VideoReplyReplyPanelState
animation: _videoReplyReplyController.colorAnimation!, animation: _videoReplyReplyController.colorAnimation!,
builder: (context, child) { builder: (context, child) {
return ColoredBox( return ColoredBox(
color: _videoReplyReplyController color:
.colorAnimation?.value ?? _videoReplyReplyController.colorAnimation?.value ??
Theme.of(Get.context!).colorScheme.onInverseSurface, Theme.of(context).colorScheme.onInverseSurface,
child: _replyItem(loadingState.response[index], index), child: _replyItem(loadingState.response[index], index),
); );
}, },

View File

@@ -590,14 +590,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: MediaQuery.of(context).padding.top) : MediaQuery.of(context).padding.top)
: videoHeight, : videoHeight,
width: context.width, width: context.width,
child: PopScope(
canPop: !isFullScreen &&
(horizontalScreen ||
MediaQuery.of(context).orientation ==
Orientation.portrait),
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
),
); );
}, },
), ),
@@ -648,12 +641,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
key: videoDetailController.childKey, key: videoDetailController.childKey,
@@ -693,12 +682,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: (MediaQuery.of(context).padding.top + : (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)) MediaQuery.of(context).padding.bottom))
: videoHeight, : videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
key: videoDetailController.childKey, key: videoDetailController.childKey,
@@ -745,12 +730,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Expanded( child: Expanded(
child: Scaffold( child: Scaffold(
@@ -829,12 +810,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
SizedBox( SizedBox(
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
height: isFullScreen ? context.height : videoHeight, height: isFullScreen ? context.height : videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Offstage( Offstage(
offstage: isFullScreen, offstage: isFullScreen,
child: SizedBox( child: SizedBox(
@@ -1367,7 +1344,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
); );
} }
Widget videoPlayer(double videoWidth, double videoHeight) => Stack( Widget videoPlayer(double videoWidth, double videoHeight) => PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: Stack(
children: [ children: [
Positioned.fill(child: ColoredBox(color: Colors.black)), Positioned.fill(child: ColoredBox(color: Colors.black)),
@@ -1460,14 +1440,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
child: Padding( child: Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
vertical: plPlayerController?.showControls.value == true vertical:
plPlayerController?.showControls.value == true
? 75 ? 75
: 16, : 16,
), ),
child: Wrap( child: Wrap(
spacing: 25, spacing: 25,
runSpacing: 10, runSpacing: 10,
children: (videoDetailController.steinEdgeInfo!['edges'] children:
(videoDetailController.steinEdgeInfo!['edges']
['questions'][0]['choices'] as List) ['questions'][0]['choices'] as List)
.map((item) { .map((item) {
return FilledButton.tonal( return FilledButton.tonal(
@@ -1513,6 +1495,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}, },
), ),
], ],
),
); );
Widget videoIntro([bool needRelated = true]) { Widget videoIntro([bool needRelated = true]) {

View File

@@ -768,12 +768,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
? animHeight ? animHeight
: videoDetailController.videoHeight, : videoDetailController.videoHeight,
width: context.width, width: context.width,
child: PopScope(
canPop: !isFullScreen &&
(horizontalScreen ||
MediaQuery.of(context).orientation ==
Orientation.portrait),
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer( child: videoPlayer(
videoWidth, videoWidth,
context.orientation == Orientation.landscape || context.orientation == Orientation.landscape ||
@@ -784,7 +778,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
? animHeight ? animHeight
: videoDetailController.videoHeight, : videoDetailController.videoHeight,
), ),
),
); );
}, },
), ),
@@ -1026,12 +1019,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
key: videoDetailController.childKey, key: videoDetailController.childKey,
@@ -1071,12 +1060,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
: (MediaQuery.of(context).padding.top + : (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)) MediaQuery.of(context).padding.bottom))
: videoHeight, : videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
key: videoDetailController.childKey, key: videoDetailController.childKey,
@@ -1123,12 +1108,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Expanded( Expanded(
child: Expanded( child: Expanded(
child: Scaffold( child: Scaffold(
@@ -1208,12 +1189,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
SizedBox( SizedBox(
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? context.width : videoWidth,
height: isFullScreen ? context.height : videoHeight, height: isFullScreen ? context.height : videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
),
Offstage( Offstage(
offstage: isFullScreen, offstage: isFullScreen,
child: SizedBox( child: SizedBox(
@@ -1752,7 +1729,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
Widget videoPlayer(double videoWidth, double videoHeight) { Widget videoPlayer(double videoWidth, double videoHeight) {
return Stack( return PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: _onPopInvokedWithResult,
child: Stack(
children: [ children: [
Positioned.fill(child: ColoredBox(color: Colors.black)), Positioned.fill(child: ColoredBox(color: Colors.black)),
@@ -1889,7 +1869,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
null, null,
true, true,
); );
videoDetailController.getSteinEdgeInfo(item['id']); videoDetailController
.getSteinEdgeInfo(item['id']);
}, },
child: Text(item['option']), child: Text(item['option']),
); );
@@ -1906,6 +1887,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
}, },
), ),
], ],
),
); );
} }

View File

@@ -21,7 +21,6 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:media_kit/media_kit.dart'; import 'package:media_kit/media_kit.dart';
import 'package:PiliPlus/http/user.dart';
import 'package:PiliPlus/models/video/play/quality.dart'; import 'package:PiliPlus/models/video/play/quality.dart';
import 'package:PiliPlus/models/video/play/url.dart'; import 'package:PiliPlus/models/video/play/url.dart';
import 'package:PiliPlus/pages/video/detail/index.dart'; import 'package:PiliPlus/pages/video/detail/index.dart';
@@ -147,9 +146,7 @@ class _HeaderControlState extends State<HeaderControl> {
dense: true, dense: true,
onTap: () async { onTap: () async {
Get.back(); Get.back();
final res = videoIntroController.viewLater();
await UserHttp.toViewLater(bvid: videoDetailCtr.bvid);
SmartDialog.showToast(res['msg']);
}, },
leading: const Icon(Icons.watch_later_outlined, size: 20), leading: const Icon(Icons.watch_later_outlined, size: 20),
title: const Text('添加至「稍后再看」', style: titleStyle), title: const Text('添加至「稍后再看」', style: titleStyle),