improve handling android window mode

Closes #1908

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-29 11:39:38 +08:00
parent 11b6f241b0
commit 7b51b6900f
5 changed files with 80 additions and 14 deletions

View File

@@ -39,6 +39,7 @@ import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/size_ext.dart';
import 'package:PiliPlus/utils/extension/theme_ext.dart';
import 'package:PiliPlus/utils/image_utils.dart';
import 'package:PiliPlus/utils/max_screen_size.dart';
import 'package:PiliPlus/utils/mobile_observer.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
@@ -100,6 +101,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
final size = MediaQuery.sizeOf(context);
maxWidth = size.width;
maxHeight = size.height;
isWindowMode = MaxScreenSize.isWindowMode(
width: maxWidth,
height: maxHeight,
);
isPortrait = size.isPortrait;
plPlayerController.screenRatio = maxHeight / maxWidth;
}
@@ -194,6 +199,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
late double maxWidth;
late double maxHeight;
bool isWindowMode = false;
late EdgeInsets padding;
late bool isPortrait;
@@ -402,7 +408,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
primary: !plPlayerController.removeSafeArea,
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: isFullScreen && !isPortrait
appBar: isWindowMode && isFullScreen && !isPortrait
? null
: _buildAppBar(isFullScreen),
body: isPortrait
@@ -424,7 +430,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
Widget _buildPH(bool isFullScreen) {
final height = maxWidth / Style.aspectRatio16x9;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: height;
final bottomHeight = maxHeight - padding.top - height - kToolbarHeight;
return Column(
@@ -453,7 +459,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
Widget _buildPP(bool isFullScreen) {
final bottomHeight = 70 + padding.bottom;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: maxHeight - bottomHeight;
return Stack(
clipBehavior: Clip.none,
@@ -707,7 +713,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
final videoHeight = maxHeight - padding.top - kToolbarHeight;
final width = isFullScreen ? maxWidth : videoWidth;
final height = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: videoHeight;
return Padding(
padding: isFullScreen