Merge pull request #366 from orz12/fix-liveroom&statusBar-when-fullscreen

修复非异形屏全屏与直播间全屏
This commit is contained in:
guozhigq
2023-12-31 11:12:36 +08:00
committed by GitHub
2 changed files with 82 additions and 53 deletions

View File

@ -54,7 +54,11 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget childWhenDisabled = Scaffold( Widget childWhenDisabled = Scaffold(
primary: true, primary: true,
appBar: AppBar( appBar: PreferredSize(
preferredSize: Size.fromHeight(
MediaQuery.of(context).orientation == Orientation.portrait ? 56 : 0,
),
child: AppBar(
centerTitle: false, centerTitle: false,
titleSpacing: 0, titleSpacing: 0,
title: _liveRoomController.liveItem != null title: _liveRoomController.liveItem != null
@ -94,12 +98,28 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
// const SizedBox(width: 12), // const SizedBox(width: 12),
// ], // ],
), ),
),
body: Column( body: Column(
children: [ children: [
Stack( Stack(
children: [ children: [
AspectRatio( PopScope(
aspectRatio: 16 / 9, canPop: plPlayerController?.isFullScreen.value != true,
onPopInvoked: (bool didPop) {
if (plPlayerController?.isFullScreen.value == true) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape) {
verticalScreen();
}
},
child: SizedBox(
width: Get.size.width,
height: MediaQuery.of(context).orientation ==
Orientation.landscape
? Get.size.height
: Get.size.width * 9 / 16,
child: plPlayerController!.videoPlayerController != null child: plPlayerController!.videoPlayerController != null
? PLVideoPlayer( ? PLVideoPlayer(
controller: plPlayerController!, controller: plPlayerController!,
@ -111,6 +131,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
) )
: const SizedBox(), : const SizedBox(),
), ),
),
// if (_liveRoomController.liveItem != null && // if (_liveRoomController.liveItem != null &&
// _liveRoomController.liveItem.cover != null) // _liveRoomController.liveItem.cover != null)
// Visibility( // Visibility(

View File

@ -243,7 +243,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
exitFullScreen(); exitFullScreen();
} }
Widget childWhenDisabled = SafeArea( Widget childWhenDisabled = SafeArea(
top: MediaQuery.of(context).orientation == Orientation.portrait, top: MediaQuery.of(context).orientation == Orientation.portrait &&
plPlayerController?.isFullScreen.value == true,
bottom: MediaQuery.of(context).orientation == Orientation.portrait && bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
plPlayerController?.isFullScreen.value == true, plPlayerController?.isFullScreen.value == true,
left: plPlayerController?.isFullScreen.value != true, left: plPlayerController?.isFullScreen.value != true,
@ -254,10 +255,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey, key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black, backgroundColor: Colors.black,
appBar: PreferredSize(
preferredSize: const Size.fromHeight(0),
child: AppBar(
backgroundColor: Theme.of(context).colorScheme.background,
elevation: 0,
),
),
body: ExtendedNestedScrollView( body: ExtendedNestedScrollView(
controller: _extendNestCtr, controller: _extendNestCtr,
headerSliverBuilder: headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) { (BuildContext _context, bool innerBoxIsScrolled) {
return <Widget>[ return <Widget>[
Obx(() => SliverAppBar( Obx(() => SliverAppBar(
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
@ -272,7 +280,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
(MediaQuery.of(context).orientation == (MediaQuery.of(context).orientation ==
Orientation.landscape Orientation.landscape
? 0 ? 0
: statusBarHeight) : MediaQuery.of(context).padding.top)
: videoHeight, : videoHeight,
backgroundColor: Colors.black, backgroundColor: Colors.black,
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(