opt video page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-08 11:28:50 +08:00
parent c7dabba3b2
commit fdb817cadd
2 changed files with 417 additions and 444 deletions

View File

@@ -487,13 +487,16 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
} }
Widget get childWhenDisabled => SafeArea( Widget get childWhenDisabled {
top: !removeSafeArea && final isPortrait =
MediaQuery.of(context).orientation == Orientation.portrait && MediaQuery.orientationOf(context) == Orientation.portrait;
isFullScreen, final useSafeArea = !removeSafeArea && isPortrait && isFullScreen;
bottom: !removeSafeArea && final size = MediaQuery.sizeOf(context);
MediaQuery.of(context).orientation == Orientation.portrait && final double width = size.width;
isFullScreen, final double height = size.height;
return SafeArea(
top: useSafeArea,
bottom: useSafeArea,
left: false, left: false,
right: false, right: false,
child: Scaffold( child: Scaffold(
@@ -508,7 +511,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
bool shouldShow = bool shouldShow =
videoDetailController.scrollRatio.value != 0 && videoDetailController.scrollRatio.value != 0 &&
videoDetailController.scrollCtr.offset != 0 && videoDetailController.scrollCtr.offset != 0 &&
context.orientation == Orientation.portrait; isPortrait;
return Stack( return Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: [ children: [
@@ -519,8 +522,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
? shouldShow ? shouldShow
? null ? null
: SystemUiOverlayStyle( : SystemUiOverlayStyle(
statusBarIconBrightness: statusBarIconBrightness: Brightness.light,
Brightness.light,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness:
themeData.brightness.reverse, themeData.brightness.reverse,
) )
@@ -555,9 +557,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
controller: videoDetailController.scrollCtr, controller: videoDetailController.scrollCtr,
onlyOneScrollInBody: true, onlyOneScrollInBody: true,
pinnedHeaderSliverHeightBuilder: () { pinnedHeaderSliverHeightBuilder: () {
double height = isFullScreen || double pinnedHeight = isFullScreen || !isPortrait
context.orientation == Orientation.landscape ? height
? MediaQuery.sizeOf(context).height
: videoDetailController.isExpanding || : videoDetailController.isExpanding ||
videoDetailController.isCollapsing videoDetailController.isCollapsing
? animHeight ? animHeight
@@ -580,10 +581,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
refreshPage(); refreshPage();
}); });
} }
return height; return pinnedHeight;
}, },
headerSliverBuilder: headerSliverBuilder: (context, innerBoxIsScrolled) {
(BuildContext context, bool innerBoxIsScrolled) {
return [ return [
SliverAppBar( SliverAppBar(
elevation: 0, elevation: 0,
@@ -591,9 +591,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
primary: false, primary: false,
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
pinned: true, pinned: true,
expandedHeight: isFullScreen || expandedHeight: isFullScreen || !isPortrait
context.orientation == Orientation.landscape ? height
? MediaQuery.sizeOf(context).height
: videoDetailController.isExpanding || : videoDetailController.isExpanding ||
videoDetailController.isCollapsing videoDetailController.isCollapsing
? animHeight ? animHeight
@@ -603,17 +602,14 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
children: [ children: [
Builder( Builder(
builder: (context) { builder: (context) {
final double videoWidth = context.width; if (!isPortrait &&
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!videoDetailController.horizontalScreen && !videoDetailController.horizontalScreen &&
!isFullScreen && !isFullScreen &&
isShowing && isShowing &&
mounted) { mounted) {
hideStatusBar(); hideStatusBar();
} }
if (MediaQuery.of(context).orientation == if (isPortrait &&
Orientation.portrait &&
!isFullScreen && !isFullScreen &&
isShowing && isShowing &&
mounted) { mounted) {
@@ -623,27 +619,20 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
} }
return SizedBox( return SizedBox(
height: MediaQuery.of(context).orientation == height: !isPortrait || isFullScreen
Orientation.landscape || ? height -
isFullScreen (!isPortrait || removeSafeArea
? MediaQuery.sizeOf(context).height -
(MediaQuery.of(context).orientation ==
Orientation.landscape ||
removeSafeArea
? 0 ? 0
: MediaQuery.of(this.context) : MediaQuery.of(this.context).padding.top)
.padding
.top)
: videoDetailController.isExpanding || : videoDetailController.isExpanding ||
videoDetailController.isCollapsing videoDetailController.isCollapsing
? animHeight ? animHeight
: videoDetailController.videoHeight, : videoDetailController.videoHeight,
width: context.width, width: width,
child: videoPlayer( child: videoPlayer(
videoWidth, width,
context.orientation == Orientation.landscape || !isPortrait || isFullScreen
isFullScreen ? height
? context.height
: videoDetailController.isExpanding || : videoDetailController.isExpanding ||
videoDetailController.isCollapsing videoDetailController.isCollapsing
? animHeight ? animHeight
@@ -655,8 +644,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Obx( Obx(
() { () {
Widget toolbar() => Opacity( Widget toolbar() => Opacity(
opacity: opacity: videoDetailController.scrollRatio.value,
videoDetailController.scrollRatio.value,
child: Container( child: Container(
color: themeData.colorScheme.surface, color: themeData.colorScheme.surface,
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
@@ -699,8 +687,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
videoDetailController videoDetailController
.plPlayerController .plPlayerController
.backToHome = true; .backToHome = true;
Get.until((route) => Get.until(
route.isFirst); (route) => route.isFirst);
}, },
), ),
), ),
@@ -713,8 +701,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
children: [ children: [
Icon( Icon(
Icons.play_arrow_rounded, Icons.play_arrow_rounded,
color: themeData color:
.colorScheme.primary, themeData.colorScheme.primary,
), ),
Text( Text(
'${videoDetailController.playedTime == null ? '立即' : plPlayerController!.playerStatus.status.value == PlayerStatus.completed ? '重新' : '继续'}播放', '${videoDetailController.playedTime == null ? '立即' : plPlayerController!.playerStatus.status.value == PlayerStatus.completed ? '重新' : '继续'}播放',
@@ -762,13 +750,11 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
context); context);
break; break;
case 'savePic': case 'savePic':
DownloadUtils DownloadUtils.downloadImg(
.downloadImg(
context, context,
[ [
videoDetailController videoDetailController
.videoItem[ .videoItem['pic']
'pic']
], ],
); );
break; break;
@@ -784,16 +770,14 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
if (videoDetailController if (videoDetailController
.epId == .epId ==
null) null)
const PopupMenuItem< const PopupMenuItem<String>(
String>(
value: 'note', value: 'note',
child: Text('查看笔记'), child: Text('查看笔记'),
), ),
if (videoDetailController if (videoDetailController
.videoItem['pic'] != .videoItem['pic'] !=
null) null)
const PopupMenuItem< const PopupMenuItem<String>(
String>(
value: 'savePic', value: 'savePic',
child: Text('保存封面'), child: Text('保存封面'),
), ),
@@ -810,9 +794,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
tooltip: "更多设置", tooltip: "更多设置",
style: ButtonStyle( style: ButtonStyle(
padding: padding:
WidgetStateProperty WidgetStateProperty.all(
.all(EdgeInsets EdgeInsets.zero),
.zero),
), ),
onPressed: () => onPressed: () =>
videoDetailController videoDetailController
@@ -823,8 +806,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Icons.more_vert_outlined, Icons.more_vert_outlined,
size: 19, size: 19,
color: themeData color: themeData
.colorScheme .colorScheme.onSurface,
.onSurface,
), ),
), ),
), ),
@@ -836,7 +818,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
); );
return videoDetailController.scrollRatio.value == 0 || return videoDetailController.scrollRatio.value == 0 ||
videoDetailController.scrollCtr.offset == 0 || videoDetailController.scrollCtr.offset == 0 ||
context.orientation != Orientation.portrait !isPortrait
? const SizedBox.shrink() ? const SizedBox.shrink()
: Positioned.fill( : Positioned.fill(
bottom: -2, bottom: -2,
@@ -859,8 +841,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
videoDetailController.queryVideoUrl(); videoDetailController.queryVideoUrl();
return; return;
} }
videoDetailController.scrollRatio.value = videoDetailController.scrollRatio.value = 0;
0;
if (plPlayerController == null || if (plPlayerController == null ||
videoDetailController.playedTime == videoDetailController.playedTime ==
null) { null) {
@@ -921,22 +902,25 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
), ),
), ),
); );
}
Widget get childWhenDisabledAlmostSquareInner => Obx( Widget get childWhenDisabledAlmostSquareInner => Obx(
() { () {
final size = MediaQuery.sizeOf(context);
final double width = size.width;
final double height = size.height;
final padding = MediaQuery.paddingOf(context);
if (enableVerticalExpand && if (enableVerticalExpand &&
videoDetailController.direction.value == 'vertical') { videoDetailController.direction.value == 'vertical') {
final double videoHeight = context.height - final double videoHeight =
(removeSafeArea height - (removeSafeArea ? 0 : padding.vertical);
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom));
final double videoWidth = videoHeight * 9 / 16; final double videoWidth = videoHeight * 9 / 16;
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? width : videoWidth,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
Expanded( Expanded(
@@ -965,20 +949,15 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
], ],
); );
} }
final double videoHeight = context.height / 2.5; final double videoHeight = height / 2.5;
final double videoWidth = context.width;
return Column( return Column(
children: [ children: [
SizedBox( SizedBox(
width: videoWidth, width: width,
height: isFullScreen height: isFullScreen
? context.height - ? height - (removeSafeArea ? 0 : padding.vertical)
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom))
: videoHeight, : videoHeight,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(width, videoHeight),
), ),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
@@ -1013,10 +992,14 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Widget get childWhenDisabledLandscapeInner => Obx( Widget get childWhenDisabledLandscapeInner => Obx(
() { () {
final size = MediaQuery.sizeOf(context);
final double width = size.width;
final double height = size.height;
final padding = MediaQuery.paddingOf(context);
if (enableVerticalExpand && if (enableVerticalExpand &&
videoDetailController.direction.value == 'vertical') { videoDetailController.direction.value == 'vertical') {
final double videoHeight = context.height - final double videoHeight =
(removeSafeArea ? 0 : MediaQuery.of(context).padding.top); height - (removeSafeArea ? 0 : padding.top);
final double videoWidth = videoHeight * 9 / 16; final double videoWidth = videoHeight * 9 / 16;
return Row( return Row(
children: [ children: [
@@ -1025,7 +1008,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
isFullScreen ? const SizedBox.shrink() : videoIntro()), isFullScreen ? const SizedBox.shrink() : videoIntro()),
SizedBox( SizedBox(
height: videoHeight, height: videoHeight,
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? width : videoWidth,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
Expanded( Expanded(
@@ -1059,10 +1042,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
); );
} }
double videoWidth = double videoWidth =
clampDouble(context.height / context.width * 1.08, 0.5, 0.7) * clampDouble(height / width * 1.08, 0.5, 0.7) * width;
context.width; if (width >= 560) {
if (context.width >= 560) { videoWidth = min(videoWidth, width - 280);
videoWidth = min(videoWidth, context.width - 280);
} }
final double videoHeight = videoWidth * 9 / 16; final double videoHeight = videoWidth * 9 / 16;
return Row( return Row(
@@ -1070,19 +1052,17 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Column( Column(
children: [ children: [
SizedBox( SizedBox(
width: isFullScreen ? context.width : videoWidth, width: isFullScreen ? width : videoWidth,
height: isFullScreen ? context.height : videoHeight, height: isFullScreen ? height : videoHeight,
child: videoPlayer(videoWidth, videoHeight), child: videoPlayer(videoWidth, videoHeight),
), ),
Offstage( Offstage(
offstage: isFullScreen, offstage: isFullScreen,
child: SizedBox( child: SizedBox(
width: videoWidth, width: videoWidth,
height: context.height - height: height -
videoHeight - videoHeight -
(removeSafeArea (removeSafeArea ? 0 : padding.top),
? 0
: MediaQuery.of(context).padding.top),
child: videoIntro(false, false), child: videoIntro(false, false),
), ),
), ),
@@ -1091,14 +1071,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Offstage( Offstage(
offstage: isFullScreen, offstage: isFullScreen,
child: SizedBox( child: SizedBox(
width: (context.width - width: width -
videoWidth - videoWidth -
(removeSafeArea (removeSafeArea ? 0 : padding.horizontal),
? 0 height: height - (removeSafeArea ? 0 : padding.top),
: (MediaQuery.of(context).padding.left +
MediaQuery.of(context).padding.right))),
height: context.height -
(removeSafeArea ? 0 : MediaQuery.of(context).padding.top),
child: Scaffold( child: Scaffold(
key: videoDetailController.childKey, key: videoDetailController.childKey,
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
@@ -1591,7 +1567,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
return PopScope( return PopScope(
canPop: !isFullScreen && canPop: !isFullScreen &&
(videoDetailController.horizontalScreen || (videoDetailController.horizontalScreen ||
MediaQuery.of(context).orientation == Orientation.portrait), MediaQuery.orientationOf(context) == Orientation.portrait),
onPopInvokedWithResult: _onPopInvokedWithResult, onPopInvokedWithResult: _onPopInvokedWithResult,
child: Stack( child: Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
@@ -1753,6 +1729,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} }
Widget videoIntro([bool needRelated = true, bool needCtr = true]) { Widget videoIntro([bool needRelated = true, bool needCtr = true]) {
final bottom = MediaQuery.paddingOf(context).bottom;
Widget introPanel() => Scaffold( Widget introPanel() => Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@@ -1793,8 +1770,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
] else ] else
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
height: MediaQuery.paddingOf(context).bottom + height: bottom + StyleString.safeSpace,
StyleString.safeSpace,
), ),
), ),
] else if (videoDetailController.videoType == ] else if (videoDetailController.videoType ==
@@ -1810,7 +1786,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
height: MediaQuery.paddingOf(context).bottom + height: bottom +
(videoDetailController.isPlayAll && (videoDetailController.isPlayAll &&
MediaQuery.orientationOf(context) == MediaQuery.orientationOf(context) ==
Orientation.landscape Orientation.landscape
@@ -1829,7 +1805,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Positioned( Positioned(
left: 12, left: 12,
right: 12, right: 12,
bottom: MediaQuery.of(context).padding.bottom + 12, bottom: bottom + 12,
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
child: InkWell( child: InkWell(
@@ -2233,7 +2209,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
if (isFullScreen) { if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false); plPlayerController!.triggerFullScreen(status: false);
} }
if (MediaQuery.of(context).orientation == Orientation.landscape && if (MediaQuery.orientationOf(context) == Orientation.landscape &&
!videoDetailController.horizontalScreen) { !videoDetailController.horizontalScreen) {
verticalScreenForTwoSeconds(); verticalScreenForTwoSeconds();
} }

View File

@@ -1801,15 +1801,12 @@ Widget buildSeekPreviewWidget(PlPlayerController plPlayerController) {
if (plPlayerController.videoShot == null) { if (plPlayerController.videoShot == null) {
plPlayerController.getVideoShot(); plPlayerController.getVideoShot();
} }
return SizedBox.shrink( return const SizedBox.shrink();
key: ValueKey(plPlayerController.previewDx.value),
);
} }
VideoShotData data = plPlayerController.videoShot!['data']; VideoShotData data = plPlayerController.videoShot!['data'];
return LayoutBuilder( return LayoutBuilder(
key: ValueKey(plPlayerController.previewDx.value),
builder: (context, constraints) { builder: (context, constraints) {
try { try {
double scale = plPlayerController.isFullScreen.value && double scale = plPlayerController.isFullScreen.value &&