修复竖屏全屏尺寸、返回,手势切换问题,还原pinnedHeader
This commit is contained in:
@ -234,24 +234,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final videoHeight = MediaQuery.of(context).size.width * 9 / 16;
|
||||
// final double pinnedHeaderHeight =
|
||||
// statusBarHeight + kToolbarHeight + videoHeight;
|
||||
if (MediaQuery.of(context).orientation == Orientation.landscape) {
|
||||
final double pinnedHeaderHeight =
|
||||
statusBarHeight + kToolbarHeight + videoHeight;
|
||||
if (MediaQuery.of(context).orientation == Orientation.landscape ||
|
||||
plPlayerController!.isFullScreen.value) {
|
||||
enterFullScreen();
|
||||
} else {
|
||||
exitFullScreen();
|
||||
}
|
||||
Widget childWhenDisabled = PopScope(
|
||||
canPop: !plPlayerController!.isFullScreen.value,
|
||||
onPopInvoked: (bool didPop) {
|
||||
if (plPlayerController!.isFullScreen.value) {
|
||||
plPlayerController!.triggerFullScreen(status: false);
|
||||
}
|
||||
if (MediaQuery.of(context).orientation == Orientation.landscape) {
|
||||
verticalScreen();
|
||||
}
|
||||
},
|
||||
child: SafeArea(
|
||||
Widget childWhenDisabled = SafeArea(
|
||||
top: MediaQuery.of(context).orientation == Orientation.portrait,
|
||||
bottom: MediaQuery.of(context).orientation == Orientation.portrait,
|
||||
left: !plPlayerController!.isFullScreen.value,
|
||||
@ -267,8 +258,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
headerSliverBuilder:
|
||||
(BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
Obx(
|
||||
() => SliverAppBar(
|
||||
Obx(() => PopScope(
|
||||
canPop: !plPlayerController!.isFullScreen.value,
|
||||
onPopInvoked: (bool didPop) {
|
||||
if (plPlayerController!.isFullScreen.value) {
|
||||
plPlayerController!
|
||||
.triggerFullScreen(status: false);
|
||||
}
|
||||
if (MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape) {
|
||||
verticalScreen();
|
||||
}
|
||||
},
|
||||
child: SliverAppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
pinned: false,
|
||||
elevation: 0,
|
||||
@ -278,7 +280,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
plPlayerController!.isFullScreen.value ||
|
||||
MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape
|
||||
? MediaQuery.of(context).size.height
|
||||
? MediaQuery.of(context).size.height -
|
||||
(MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape
|
||||
? 0
|
||||
: statusBarHeight)
|
||||
: videoHeight,
|
||||
backgroundColor: Colors.black,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
@ -416,7 +422,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
},
|
||||
),
|
||||
)),
|
||||
),
|
||||
)),
|
||||
];
|
||||
},
|
||||
// pinnedHeaderSliverHeightBuilder: () {
|
||||
@ -425,9 +431,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// : pinnedHeaderHeight;
|
||||
// },
|
||||
/// 不收回
|
||||
// pinnedHeaderSliverHeightBuilder: () {
|
||||
// return pinnedHeaderHeight;
|
||||
// },
|
||||
pinnedHeaderSliverHeightBuilder: () {
|
||||
return pinnedHeaderHeight;
|
||||
},
|
||||
onlyOneScrollInBody: true,
|
||||
body: Container(
|
||||
key: Key(heroTag),
|
||||
@ -464,12 +470,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
if (videoDetailController.videoType ==
|
||||
SearchType.video) ...[
|
||||
const VideoIntroPanel(),
|
||||
] else if (videoDetailController
|
||||
.videoType ==
|
||||
] else if (videoDetailController.videoType ==
|
||||
SearchType.media_bangumi) ...[
|
||||
Obx(() => BangumiIntroPanel(
|
||||
cid: videoDetailController
|
||||
.cid.value)),
|
||||
cid: videoDetailController.cid.value)),
|
||||
],
|
||||
// if (videoDetailController.videoType ==
|
||||
// SearchType.video) ...[
|
||||
@ -525,7 +529,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// )
|
||||
],
|
||||
),
|
||||
));
|
||||
);
|
||||
Widget childWhenEnabled = FutureBuilder(
|
||||
key: Key(heroTag),
|
||||
future: _futureBuilderFuture,
|
||||
|
||||
@ -25,6 +25,7 @@ import 'widgets/backward_seek.dart';
|
||||
import 'widgets/bottom_control.dart';
|
||||
import 'widgets/common_btn.dart';
|
||||
import 'widgets/forward_seek.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class PLVideoPlayer extends StatefulWidget {
|
||||
final PlPlayerController controller;
|
||||
@ -76,6 +77,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
late bool enableBackgroundPlay;
|
||||
late double screenWidth;
|
||||
|
||||
// 用于记录上一次全屏切换手势触发时间,避免误触
|
||||
DateTime? lastFullScreenToggleTime;
|
||||
|
||||
void onDoubleTapSeekBackward() {
|
||||
_ctr.onDoubleTapSeekBackward();
|
||||
}
|
||||
@ -503,11 +507,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
final tapPosition = details.localPosition.dx;
|
||||
final sectionWidth = totalWidth / 3;
|
||||
final delta = details.delta.dy;
|
||||
|
||||
/// 锁定时禁用
|
||||
if (_.controlsLock.value) {
|
||||
return;
|
||||
}
|
||||
if (lastFullScreenToggleTime != null &&
|
||||
DateTime.now().difference(lastFullScreenToggleTime!) <
|
||||
const Duration(milliseconds: 500)) {
|
||||
return;
|
||||
}
|
||||
if (tapPosition < sectionWidth) {
|
||||
// 左边区域 👈
|
||||
double level = (_.isFullScreen.value
|
||||
@ -523,12 +531,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
const double threshold = 7.0; // 滑动阈值
|
||||
if (dy > _distance && dy > threshold) {
|
||||
if (_.isFullScreen.value) {
|
||||
lastFullScreenToggleTime = DateTime.now();
|
||||
// 下滑退出全屏
|
||||
await widget.controller.triggerFullScreen(status: false);
|
||||
}
|
||||
_distance = 0.0;
|
||||
} else if (dy < _distance && dy < -threshold) {
|
||||
if (!_.isFullScreen.value) {
|
||||
lastFullScreenToggleTime = DateTime.now();
|
||||
// 上滑进入全屏
|
||||
await widget.controller.triggerFullScreen();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user