opt: fullScreen logic
This commit is contained in:
@ -502,7 +502,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sizeContext = MediaQuery.sizeOf(context);
|
||||
final _context = MediaQuery.of(context);
|
||||
final orientation = MediaQuery.orientationOf(context);
|
||||
late final double verticalHeight = sizeContext.width * 22 / 16;
|
||||
late double defaultVideoHeight = vdCtr.videoDirection.value == 'vertical'
|
||||
? verticalHeight
|
||||
@ -517,12 +517,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
});
|
||||
|
||||
// 竖屏
|
||||
final bool isPortrait = _context.orientation == Orientation.portrait;
|
||||
final bool isPortrait = orientation == Orientation.portrait;
|
||||
// 横屏
|
||||
final bool isLandscape = _context.orientation == Orientation.landscape;
|
||||
final bool isLandscape = orientation == Orientation.landscape;
|
||||
final Rx<bool> isFullScreen = plPlayerController?.isFullScreen ?? false.obs;
|
||||
// 全屏时高度撑满
|
||||
if (isLandscape || isFullScreen.value == true) {
|
||||
if (isLandscape || isFullScreen.value) {
|
||||
videoHeight.value = Get.size.height;
|
||||
enterFullScreen();
|
||||
} else {
|
||||
@ -634,10 +634,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
|
||||
Widget childWhenDisabled = SafeArea(
|
||||
top: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||
plPlayerController?.isFullScreen.value == true,
|
||||
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||
plPlayerController?.isFullScreen.value == true,
|
||||
top: isPortrait && isFullScreen.value,
|
||||
bottom: isPortrait && isFullScreen.value,
|
||||
left: false,
|
||||
right: false,
|
||||
child: Stack(
|
||||
@ -660,22 +658,25 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
return <Widget>[
|
||||
Obx(
|
||||
() {
|
||||
final Orientation orientation =
|
||||
MediaQuery.of(context).orientation;
|
||||
final bool isLandscape =
|
||||
MediaQuery.orientationOf(context) ==
|
||||
Orientation.landscape;
|
||||
final bool isFullScreen =
|
||||
plPlayerController?.isFullScreen.value == true;
|
||||
final double expandedHeight =
|
||||
orientation == Orientation.landscape || isFullScreen
|
||||
? (MediaQuery.sizeOf(context).height -
|
||||
(orientation == Orientation.landscape
|
||||
? 0
|
||||
: MediaQuery.of(context).padding.top))
|
||||
: videoHeight.value;
|
||||
if (orientation == Orientation.landscape ||
|
||||
isFullScreen) {
|
||||
plPlayerController?.isFullScreen.value ?? false;
|
||||
|
||||
late double expandedHeight;
|
||||
if (isLandscape || isFullScreen) {
|
||||
enterFullScreen();
|
||||
expandedHeight = (MediaQuery.sizeOf(context).height -
|
||||
(isLandscape
|
||||
? 0
|
||||
: MediaQuery.paddingOf(context).top));
|
||||
} else {
|
||||
exitFullScreen();
|
||||
if (vdCtr.videoDirection.value == 'vertical') {
|
||||
videoHeight.value = verticalHeight;
|
||||
}
|
||||
expandedHeight = videoHeight.value;
|
||||
}
|
||||
return SliverAppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
@ -687,21 +688,24 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
backgroundColor: Colors.black,
|
||||
flexibleSpace: SizedBox.expand(
|
||||
child: PopScope(
|
||||
canPop:
|
||||
plPlayerController?.isFullScreen.value != true,
|
||||
canPop: !isFullScreen,
|
||||
onPopInvoked: (bool didPop) {
|
||||
if (plPlayerController?.controlsLock.value ==
|
||||
true) {
|
||||
plPlayerController?.onLockControl(false);
|
||||
if (plPlayerController != null) {
|
||||
if (plPlayerController!.controlsLock.value) {
|
||||
plPlayerController!.onLockControl(false);
|
||||
return;
|
||||
}
|
||||
if (plPlayerController?.isFullScreen.value ==
|
||||
true) {
|
||||
if (isFullScreen) {
|
||||
plPlayerController!
|
||||
.triggerFullScreen(status: false);
|
||||
if (vdCtr.videoDirection.value ==
|
||||
'vertical') {
|
||||
videoHeight.value = verticalHeight;
|
||||
}
|
||||
if (MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isLandscape) {
|
||||
verticalScreen();
|
||||
}
|
||||
},
|
||||
@ -746,9 +750,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
/// 不收回
|
||||
pinnedHeaderSliverHeightBuilder: () {
|
||||
return MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape ||
|
||||
plPlayerController?.isFullScreen.value == true
|
||||
return isLandscape || isFullScreen.value
|
||||
? MediaQuery.sizeOf(context).height
|
||||
: playerStatus.value != PlayerStatus.playing
|
||||
? kToolbarHeight
|
||||
|
@ -732,6 +732,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
lastFullScreenToggleTime = DateTime.now();
|
||||
// 下滑退出全屏
|
||||
await widget.controller.triggerFullScreen(status: flag);
|
||||
widget.fullScreenCb?.call(flag);
|
||||
}
|
||||
_distance.value = 0.0;
|
||||
} else if (dy < _distance.value &&
|
||||
@ -741,6 +742,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
lastFullScreenToggleTime = DateTime.now();
|
||||
// 上滑进入全屏
|
||||
await widget.controller.triggerFullScreen(status: !flag);
|
||||
widget.fullScreenCb?.call(!flag);
|
||||
}
|
||||
_distance.value = 0.0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user