opt: video page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-03 21:14:17 +08:00
parent 731a7dd3e5
commit 979df1585e
3 changed files with 69 additions and 89 deletions

View File

@@ -7,7 +7,6 @@ import 'package:PiliPalaX/models/bangumi/info.dart' as bangumi;
import 'package:PiliPalaX/models/video_detail_res.dart' as video;
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
@@ -24,6 +23,7 @@ class ListSheetContent extends StatefulWidget {
this.aid,
required this.currentCid,
required this.changeFucCall,
required this.onClose,
});
final dynamic index;
@@ -33,6 +33,7 @@ class ListSheetContent extends StatefulWidget {
final int? aid;
final int currentCid;
final Function changeFucCall;
final VoidCallback onClose;
@override
State<ListSheetContent> createState() => _ListSheetContentState();
@@ -136,7 +137,7 @@ class _ListSheetContentState extends State<ListSheetContent>
}
}
SmartDialog.showToast('切换到:$title');
Get.back();
widget.onClose();
widget.changeFucCall(
episode is bangumi.EpisodeItem ? episode.epId : null,
episode.runtimeType.toString() == "EpisodeItem"
@@ -326,7 +327,7 @@ class _ListSheetContentState extends State<ListSheetContent>
_mediumButton(
tooltip: '关闭',
icon: Icons.close,
onPressed: Get.back,
onPressed: widget.onClose,
),
],
),

View File

@@ -214,6 +214,8 @@ class VideoDetailController extends GetxController
PlayerStatus? playerStatus;
StreamSubscription<Duration>? positionSubscription;
PersistentBottomSheetController? bsController;
@override
void onInit() {
super.onInit();
@@ -1043,15 +1045,17 @@ class VideoDetailController extends GetxController
),
);
}
plPlayerController.isFullScreen.value
? scaffoldKey.currentState?.showBottomSheet(
enableDrag: false,
(context) => _postPanel(false),
)
: childKey.currentState?.showBottomSheet(
enableDrag: false,
(context) => _postPanel(),
);
if (plPlayerController.isFullScreen.value) {
bsController = scaffoldKey.currentState?.showBottomSheet(
enableDrag: false,
(context) => _postPanel(false),
);
} else {
childKey.currentState?.showBottomSheet(
enableDrag: false,
(context) => _postPanel(),
);
}
}
Widget _postPanel([bool isChild = true]) => StatefulBuilder(
@@ -1206,7 +1210,14 @@ class VideoDetailController extends GetxController
iconButton(
context: context,
tooltip: '关闭',
onPressed: Get.back,
onPressed: () {
if (bsController != null) {
bsController!.close();
bsController = null;
} else {
Get.back();
}
},
icon: Icons.close,
),
const SizedBox(width: 16),

View File

@@ -541,23 +541,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
(horizontalScreen ||
MediaQuery.of(context).orientation ==
Orientation.portrait),
onPopInvokedWithResult:
(bool didPop, Object? result) {
if (plPlayerController?.controlsLock.value ==
true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!
.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight),
),
);
@@ -608,20 +592,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight),
),
),
@@ -664,20 +635,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight),
),
),
@@ -722,20 +680,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
width: isFullScreen ? context.width : videoWidth,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight),
),
),
@@ -803,20 +748,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
height: isFullScreen ? context.height : videoHeight,
child: PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) {
if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
onPopInvokedWithResult: _onPopInvokedWithResult,
child: videoPlayer(videoWidth, videoHeight),
),
),
@@ -1408,9 +1340,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoDetailController.videoType == SearchType.media_bangumi
? bangumiIntroController.changeSeasonOrbangu
: videoIntroController.changeSeasonOrbangu,
onClose: () {
if (videoDetailController.bsController != null) {
videoDetailController.bsController!.close();
videoDetailController.bsController = null;
} else {
Get.back();
}
},
);
if (isFullScreen) {
videoDetailController.scaffoldKey.currentState?.showBottomSheet(
videoDetailController.bsController =
videoDetailController.scaffoldKey.currentState?.showBottomSheet(
(context) => listSheetContent(),
);
} else {
@@ -1463,7 +1404,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
size: 30,
icon: Icons.clear,
tooltip: '关闭',
onPressed: Get.back,
onPressed: () {
if (videoDetailController.bsController != null) {
videoDetailController.bsController!.close();
videoDetailController.bsController = null;
} else {
Get.back();
}
},
),
const SizedBox(width: 16),
],
@@ -1565,7 +1513,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
if (isFullScreen) {
videoDetailController.scaffoldKey.currentState?.showBottomSheet(
videoDetailController.bsController =
videoDetailController.scaffoldKey.currentState?.showBottomSheet(
(context) => listSheetContent(context, true),
);
} else {
@@ -1574,4 +1523,23 @@ class _VideoDetailPageState extends State<VideoDetailPage>
);
}
}
void _onPopInvokedWithResult(didPop, result) {
if (videoDetailController.bsController != null) {
videoDetailController.bsController!.close();
videoDetailController.bsController = null;
return;
}
if (plPlayerController?.controlsLock.value == true) {
plPlayerController?.onLockControl(false);
return;
}
if (isFullScreen) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation == Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
}
}